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

Diff for /mandoc/html.c between version 1.198 and 1.205

version 1.198, 2017/01/19 15:27:34 version 1.205, 2017/02/05 18:15:39
Line 65  static const struct htmldata htmltags[TAG_MAX] = {
Line 65  static const struct htmldata htmltags[TAG_MAX] = {
         {"br",          HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},          {"br",          HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},
         {"a",           0},          {"a",           0},
         {"table",       HTML_NLALL | HTML_INDENT},          {"table",       HTML_NLALL | HTML_INDENT},
         {"tbody",       HTML_NLALL | HTML_INDENT},          {"colgroup",    HTML_NLALL | HTML_INDENT},
         {"col",         HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},          {"col",         HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},
         {"tr",          HTML_NLALL | HTML_INDENT},          {"tr",          HTML_NLALL | HTML_INDENT},
         {"td",          HTML_NLAROUND},          {"td",          HTML_NLAROUND},
Line 75  static const struct htmldata htmltags[TAG_MAX] = {
Line 75  static const struct htmldata htmltags[TAG_MAX] = {
         {"dl",          HTML_NLALL | HTML_INDENT},          {"dl",          HTML_NLALL | HTML_INDENT},
         {"dt",          HTML_NLAROUND},          {"dt",          HTML_NLAROUND},
         {"dd",          HTML_NLAROUND | HTML_INDENT},          {"dd",          HTML_NLAROUND | HTML_INDENT},
         {"blockquote",  HTML_NLALL | HTML_INDENT},  
         {"pre",         HTML_NLALL | HTML_NOINDENT},          {"pre",         HTML_NLALL | HTML_NOINDENT},
         {"b",           0},          {"b",           0},
         {"i",           0},          {"i",           0},
Line 115  static const char *const roffscales[SCALE_MAX] = {
Line 114  static const char *const roffscales[SCALE_MAX] = {
   
 static  void     a2width(const char *, struct roffsu *);  static  void     a2width(const char *, struct roffsu *);
 static  void     print_byte(struct html *, char);  static  void     print_byte(struct html *, char);
 static  void     print_endline(struct html *);  
 static  void     print_endword(struct html *);  static  void     print_endword(struct html *);
 static  void     print_indent(struct html *);  static  void     print_indent(struct html *);
 static  void     print_word(struct html *, const char *);  static  void     print_word(struct html *, const char *);
Line 134  html_alloc(const struct manoutput *outopts)
Line 132  html_alloc(const struct manoutput *outopts)
   
         h = mandoc_calloc(1, sizeof(struct html));          h = mandoc_calloc(1, sizeof(struct html));
   
         h->tags.head = NULL;          h->tag = NULL;
         h->style = outopts->style;          h->style = outopts->style;
         h->base_man = outopts->man;          h->base_man = outopts->man;
         h->base_includes = outopts->includes;          h->base_includes = outopts->includes;
Line 152  html_free(void *p)
Line 150  html_free(void *p)
   
         h = (struct html *)p;          h = (struct html *)p;
   
         while ((tag = h->tags.head) != NULL) {          while ((tag = h->tag) != NULL) {
                 h->tags.head = tag->next;                  h->tag = tag->next;
                 free(tag);                  free(tag);
         }          }
   
Line 178  print_gen_head(struct html *h)
Line 176  print_gen_head(struct html *h)
         print_endline(h);          print_endline(h);
         print_text(h, "td.head-vol { text-align: center; }");          print_text(h, "td.head-vol { text-align: center; }");
         print_endline(h);          print_endline(h);
         print_text(h, "table.foot td { width: 50%; }");  
         print_endline(h);  
         print_text(h, "table.head td { width: 33%; }");  
         print_endline(h);  
         print_text(h, "div.Pp { margin: 1ex 0ex; }");          print_text(h, "div.Pp { margin: 1ex 0ex; }");
         print_tagq(h, t);          print_tagq(h, t);
   
Line 455  print_otag(struct html *h, enum htmltag tag, const cha
Line 449  print_otag(struct html *h, enum htmltag tag, const cha
         char             numbuf[16];          char             numbuf[16];
         struct tag      *t;          struct tag      *t;
         const char      *attr;          const char      *attr;
         char            *s;          char            *arg1, *arg2;
         double           v;          double           v;
         int              i, have_style, tflags;          int              i, have_style, tflags;
   
         tflags = htmltags[tag].flags;          tflags = htmltags[tag].flags;
   
         /* Push this tags 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) {
                 t = mandoc_malloc(sizeof(struct tag));                  t = mandoc_malloc(sizeof(struct tag));
                 t->tag = tag;                  t->tag = tag;
                 t->next = h->tags.head;                  t->next = h->tag;
                 h->tags.head = t;                  h->tag = t;
         } else          } else
                 t = NULL;                  t = NULL;
   
Line 500  print_otag(struct html *h, enum htmltag tag, const cha
Line 494  print_otag(struct html *h, enum htmltag tag, const cha
         have_style = 0;          have_style = 0;
         while (*fmt != '\0') {          while (*fmt != '\0') {
                 if (*fmt == 's') {                  if (*fmt == 's') {
                         print_word(h, " style=\"");  
                         have_style = 1;                          have_style = 1;
                         fmt++;                          fmt++;
                         break;                          break;
                 }                  }
                 s = va_arg(ap, char *);  
                   /* Parse a non-style attribute and its arguments. */
   
                   arg1 = va_arg(ap, char *);
                 switch (*fmt++) {                  switch (*fmt++) {
                 case 'c':                  case 'c':
                         attr = "class";                          attr = "class";
Line 517  print_otag(struct html *h, enum htmltag tag, const cha
Line 513  print_otag(struct html *h, enum htmltag tag, const cha
                         attr = "id";                          attr = "id";
                         break;                          break;
                 case '?':                  case '?':
                         attr = s;                          attr = arg1;
                         s = va_arg(ap, char *);                          arg1 = va_arg(ap, char *);
                         break;                          break;
                 default:                  default:
                         abort();                          abort();
                 }                  }
                   arg2 = NULL;
                   if (*fmt == 'M')
                           arg2 = va_arg(ap, char *);
                   if (arg1 == NULL)
                           continue;
   
                   /* Print the non-style attributes. */
   
                 print_byte(h, ' ');                  print_byte(h, ' ');
                 print_word(h, attr);                  print_word(h, attr);
                 print_byte(h, '=');                  print_byte(h, '=');
                 print_byte(h, '"');                  print_byte(h, '"');
                 switch (*fmt) {                  switch (*fmt) {
                 case 'M':                  case 'M':
                         print_href(h, s, va_arg(ap, char *), 1);                          print_href(h, arg1, arg2, 1);
                         fmt++;                          fmt++;
                         break;                          break;
                 case 'I':                  case 'I':
                         print_href(h, s, NULL, 0);                          print_href(h, arg1, NULL, 0);
                         fmt++;                          fmt++;
                         break;                          break;
                 case 'R':                  case 'R':
Line 541  print_otag(struct html *h, enum htmltag tag, const cha
Line 545  print_otag(struct html *h, enum htmltag tag, const cha
                         fmt++;                          fmt++;
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 default:                  default:
                         print_encode(h, s, NULL, 1);                          print_encode(h, arg1, NULL, 1);
                         break;                          break;
                 }                  }
                 print_byte(h, '"');                  print_byte(h, '"');
Line 549  print_otag(struct html *h, enum htmltag tag, const cha
Line 553  print_otag(struct html *h, enum htmltag tag, const cha
   
         /* Print out styles. */          /* Print out styles. */
   
         s = NULL;  
         su = &mysu;  
         while (*fmt != '\0') {          while (*fmt != '\0') {
                   arg1 = NULL;
                   su = NULL;
   
                 /* First letter: input argument type. */                  /* First letter: input argument type. */
   
                 switch (*fmt++) {                  switch (*fmt++) {
                 case 'h':                  case 'h':
                         i = va_arg(ap, int);                          i = va_arg(ap, int);
                           su = &mysu;
                         SCALE_HS_INIT(su, i);                          SCALE_HS_INIT(su, i);
                         break;                          break;
                 case 's':                  case 's':
                         s = va_arg(ap, char *);                          arg1 = va_arg(ap, char *);
                         break;                          break;
                 case 'u':                  case 'u':
                         su = va_arg(ap, struct roffsu *);                          su = va_arg(ap, struct roffsu *);
                         break;                          break;
                 case 'v':                  case 'v':
                         i = va_arg(ap, int);                          i = va_arg(ap, int);
                           su = &mysu;
                         SCALE_VS_INIT(su, i);                          SCALE_VS_INIT(su, i);
                         break;                          break;
                 case 'w':                  case 'w':
                         s = va_arg(ap, char *);                  case 'W':
                         a2width(s, su);                          if ((arg2 = va_arg(ap, char *)) == NULL)
                                   break;
                           su = &mysu;
                           a2width(arg2, su);
                           if (fmt[-1] == 'W')
                                   su->scale *= -1.0;
                         break;                          break;
                 default:                  default:
                         abort();                          abort();
Line 603  print_otag(struct html *h, enum htmltag tag, const cha
Line 614  print_otag(struct html *h, enum htmltag tag, const cha
                         attr = "min-width";                          attr = "min-width";
                         break;                          break;
                 case '?':                  case '?':
                         print_word(h, s);                          attr = arg1;
                         print_byte(h, ':');                          arg1 = va_arg(ap, char *);
                         print_byte(h, ' ');                          break;
                         print_word(h, va_arg(ap, char *));  
                         print_byte(h, ';');  
                         if (*fmt != '\0')  
                                 print_byte(h, ' ');  
                         continue;  
                 default:                  default:
                         abort();                          abort();
                 }                  }
                 v = su->scale;                  if (su == NULL && arg1 == NULL)
                 if (su->unit == SCALE_MM && (v /= 100.0) == 0.0)                          continue;
                         v = 1.0;  
                 else if (su->unit == SCALE_BU)                  if (have_style == 1)
                         v /= 24.0;                          print_word(h, " style=\"");
                   else
                           print_byte(h, ' ');
                 print_word(h, attr);                  print_word(h, attr);
                 print_byte(h, ':');                  print_byte(h, ':');
                 print_byte(h, ' ');                  print_byte(h, ' ');
                 (void)snprintf(numbuf, sizeof(numbuf), "%.2f", v);                  if (su != NULL) {
                 print_word(h, numbuf);                          v = su->scale;
                 print_word(h, roffscales[su->unit]);                          if (su->unit == SCALE_MM && (v /= 100.0) == 0.0)
                                   v = 1.0;
                           else if (su->unit == SCALE_BU)
                                   v /= 24.0;
                           (void)snprintf(numbuf, sizeof(numbuf), "%.2f", v);
                           print_word(h, numbuf);
                           print_word(h, roffscales[su->unit]);
                   } else
                           print_word(h, arg1);
                 print_byte(h, ';');                  print_byte(h, ';');
                 if (*fmt != '\0')                  have_style = 2;
                         print_byte(h, ' ');  
         }          }
         if (have_style)          if (have_style == 2)
                 print_byte(h, '"');                  print_byte(h, '"');
   
         va_end(ap);          va_end(ap);
Line 684  print_ctag(struct html *h, struct tag *tag)
Line 699  print_ctag(struct html *h, struct tag *tag)
         if (tflags & HTML_NLAFTER)          if (tflags & HTML_NLAFTER)
                 print_endline(h);                  print_endline(h);
   
         h->tags.head = tag->next;          h->tag = tag->next;
         free(tag);          free(tag);
 }  }
   
Line 745  print_tagq(struct html *h, const struct tag *until)
Line 760  print_tagq(struct html *h, const struct tag *until)
 {  {
         struct tag      *tag;          struct tag      *tag;
   
         while ((tag = h->tags.head) != NULL) {          while ((tag = h->tag) != NULL) {
                 print_ctag(h, tag);                  print_ctag(h, tag);
                 if (until && tag == until)                  if (until && tag == until)
                         return;                          return;
Line 757  print_stagq(struct html *h, const struct tag *suntil)
Line 772  print_stagq(struct html *h, const struct tag *suntil)
 {  {
         struct tag      *tag;          struct tag      *tag;
   
         while ((tag = h->tags.head) != NULL) {          while ((tag = h->tag) != NULL) {
                 if (suntil && tag == suntil)                  if (suntil && tag == suntil)
                         return;                          return;
                 print_ctag(h, tag);                  print_ctag(h, tag);
Line 814  print_byte(struct html *h, char c)
Line 829  print_byte(struct html *h, char c)
  * If something was printed on the current output line, end it.   * If something was printed on the current output line, end it.
  * Not to be called right after print_indent().   * Not to be called right after print_indent().
  */   */
 static void  void
 print_endline(struct html *h)  print_endline(struct html *h)
 {  {
         if (h->col == 0)          if (h->col == 0)

Legend:
Removed from v.1.198  
changed lines
  Added in v.1.205

CVSweb