[BACK]Return to html.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/html.c between version 1.257 and 1.263

version 1.257, 2019/08/29 17:57:29 version 1.263, 2020/02/27 22:28:13
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2011-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 65  static const struct htmldata htmltags[TAG_MAX] = {
Line 65  static const struct htmldata htmltags[TAG_MAX] = {
         {"title",       HTML_NLAROUND},          {"title",       HTML_NLAROUND},
         {"body",        HTML_NLALL},          {"body",        HTML_NLALL},
         {"div",         HTML_NLAROUND},          {"div",         HTML_NLAROUND},
         {"div",         0},  
         {"section",     HTML_NLALL},          {"section",     HTML_NLALL},
         {"table",       HTML_NLALL | HTML_INDENT},          {"table",       HTML_NLALL | HTML_INDENT},
         {"tr",          HTML_NLALL | HTML_INDENT},          {"tr",          HTML_NLALL | HTML_INDENT},
Line 89  static const struct htmldata htmltags[TAG_MAX] = {
Line 88  static const struct htmldata htmltags[TAG_MAX] = {
         {"span",        HTML_INPHRASE | HTML_TOPHRASE},          {"span",        HTML_INPHRASE | HTML_TOPHRASE},
         {"var",         HTML_INPHRASE | HTML_TOPHRASE},          {"var",         HTML_INPHRASE | HTML_TOPHRASE},
         {"br",          HTML_INPHRASE | HTML_NOSTACK | HTML_NLALL},          {"br",          HTML_INPHRASE | HTML_NOSTACK | HTML_NLALL},
           {"mark",        HTML_INPHRASE },
         {"math",        HTML_INPHRASE | HTML_NLALL | HTML_INDENT},          {"math",        HTML_INPHRASE | HTML_NLALL | HTML_INDENT},
         {"mrow",        0},          {"mrow",        0},
         {"mi",          0},          {"mi",          0},
Line 272  print_metaf(struct html *h)
Line 272  print_metaf(struct html *h)
 void  void
 html_close_paragraph(struct html *h)  html_close_paragraph(struct html *h)
 {  {
         struct tag      *t;          struct tag      *this, *next;
           int              flags;
   
         for (t = h->tag; t != NULL && t->closed == 0; t = t->next) {          this = h->tag;
                 switch(t->tag) {          for (;;) {
                 case TAG_P:                  next = this->next;
                 case TAG_PRE:                  flags = htmltags[this->tag].flags;
                         print_tagq(h, t);                  if (flags & (HTML_INPHRASE | HTML_TOPHRASE))
                           print_ctag(h, this);
                   if ((flags & HTML_INPHRASE) == 0)
                         break;                          break;
                 case TAG_A:                  this = next;
                         print_tagq(h, t);  
                         continue;  
                 default:  
                         continue;  
                 }  
                 break;  
         }          }
 }  }
   
Line 594  print_otag(struct html *h, enum htmltag tag, const cha
Line 591  print_otag(struct html *h, enum htmltag tag, const cha
                         assert((htmltags[t->tag].flags & HTML_TOPHRASE) == 0);                          assert((htmltags[t->tag].flags & HTML_TOPHRASE) == 0);
                         break;                          break;
                 }                  }
         }  
   
           /*
            * Always wrap phrasing elements in a paragraph
            * unless already contained in some flow container;
            * never put them directly into a section.
            */
   
           } else if (tflags & HTML_TOPHRASE && h->tag->tag == TAG_SECTION)
                   print_otag(h, TAG_P, "c", "Pp");
   
         /* Push this tag onto the stack of open scopes. */          /* Push this tag onto the stack of open scopes. */
   
         if ((tflags & HTML_NOSTACK) == 0) {          if ((tflags & HTML_NOSTACK) == 0) {
Line 800  print_gen_comment(struct html *h, struct roff_node *n)
Line 805  print_gen_comment(struct html *h, struct roff_node *n)
 void  void
 print_text(struct html *h, const char *word)  print_text(struct html *h, const char *word)
 {  {
           /*
            * Always wrap text in a paragraph unless already contained in
            * some flow container; never put it directly into a section.
            */
   
           if (h->tag->tag == TAG_SECTION)
                   print_otag(h, TAG_P, "c", "Pp");
   
           /* Output whitespace before this text? */
   
         if (h->col && (h->flags & HTML_NOSPACE) == 0) {          if (h->col && (h->flags & HTML_NOSPACE) == 0) {
                 if ( ! (HTML_KEEP & h->flags)) {                  if ( ! (HTML_KEEP & h->flags)) {
                         if (HTML_PREKEEP & h->flags)                          if (HTML_PREKEEP & h->flags)
Line 809  print_text(struct html *h, const char *word)
Line 824  print_text(struct html *h, const char *word)
                         print_word(h, "&#x00A0;");                          print_word(h, "&#x00A0;");
         }          }
   
           /*
            * Print the text, optionally surrounded by HTML whitespace,
            * optionally manually switching fonts before and after.
            */
   
         assert(h->metaf == NULL);          assert(h->metaf == NULL);
         print_metaf(h);          print_metaf(h);
         print_indent(h);          print_indent(h);
Line 949  print_indent(struct html *h)
Line 969  print_indent(struct html *h)
 {  {
         size_t   i;          size_t   i;
   
         if (h->col)          if (h->col || h->noindent)
                 return;                  return;
   
         if (h->noindent == 0) {          h->col = h->indent * 2;
                 h->col = h->indent * 2;          for (i = 0; i < h->col; i++)
                 for (i = 0; i < h->col; i++)                  putchar(' ');
                         putchar(' ');  
         }  
         h->flags &= ~HTML_NOSPACE;  
 }  }
   
 /*  /*

Legend:
Removed from v.1.257  
changed lines
  Added in v.1.263

CVSweb