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

Diff for /mandoc/mdoc_html.c between version 1.82 and 1.92

version 1.82, 2010/06/12 12:10:55 version 1.92, 2010/07/02 12:54:33
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>   * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
  *   *
  * 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 30 
Line 30 
 #include "mandoc.h"  #include "mandoc.h"
 #include "out.h"  #include "out.h"
 #include "html.h"  #include "html.h"
   #include "regs.h"
 #include "mdoc.h"  #include "mdoc.h"
 #include "main.h"  #include "main.h"
   
Line 303  synopsis_pre(struct html *h, const struct mdoc_node *n
Line 304  synopsis_pre(struct html *h, const struct mdoc_node *n
         struct roffsu    su;          struct roffsu    su;
         struct htmlpair  tag;          struct htmlpair  tag;
   
         if (NULL == n->prev || SEC_SYNOPSIS != n->sec)          if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
                 return;                  return;
   
         SCALE_VS_INIT(&su, 1);          SCALE_VS_INIT(&su, 1);
Line 436  print_mdoc_node(MDOC_ARGS)
Line 437  print_mdoc_node(MDOC_ARGS)
                 print_text(h, n->string);                  print_text(h, n->string);
                 return;                  return;
         default:          default:
                 if (mdocs[n->tok].pre)                  if (mdocs[n->tok].pre && ENDBODY_NOT == n->end)
                         child = (*mdocs[n->tok].pre)(m, n, h);                          child = (*mdocs[n->tok].pre)(m, n, h);
                 break;                  break;
         }          }
Line 452  print_mdoc_node(MDOC_ARGS)
Line 453  print_mdoc_node(MDOC_ARGS)
                 mdoc_root_post(m, n, h);                  mdoc_root_post(m, n, h);
                 break;                  break;
         default:          default:
                 if (mdocs[n->tok].post)                  if (mdocs[n->tok].post && ENDBODY_NOT == n->end)
                         (*mdocs[n->tok].post)(m, n, h);                          (*mdocs[n->tok].post)(m, n, h);
                 break;                  break;
         }          }
Line 735  mdoc_op_post(MDOC_ARGS)
Line 736  mdoc_op_post(MDOC_ARGS)
 static int  static int
 mdoc_nm_pre(MDOC_ARGS)  mdoc_nm_pre(MDOC_ARGS)
 {  {
         struct htmlpair tag;          struct htmlpair  tag;
           struct roffsu    su;
           const char      *cp;
   
         if (NULL == n->child && NULL == m->name)          /*
                 return(1);           * Accomodate for `Nm' being both an element (which may have
            * NULL children AND no m->name) and a block.
            */
   
         synopsis_pre(h, n);          cp = NULL;
   
         PAIR_CLASS_INIT(&tag, "name");          if (MDOC_ELEM == n->type) {
         print_otag(h, TAG_SPAN, 1, &tag);                  if (NULL == n->child && NULL == m->name)
         if (NULL == n->child)                          return(1);
                 print_text(h, m->name);                  synopsis_pre(h, n);
                   PAIR_CLASS_INIT(&tag, "name");
                   print_otag(h, TAG_SPAN, 1, &tag);
                   if (NULL == n->child)
                           print_text(h, m->name);
           } else if (MDOC_BLOCK == n->type) {
                   synopsis_pre(h, n);
   
                   bufcat_style(h, "clear", "both");
                   if (n->head->child || m->name) {
                           if (n->head->child && MDOC_TEXT ==
                                           n->head->child->type)
                                   cp = n->head->child->string;
                           if (NULL == cp || '\0' == *cp)
                                   cp = m->name;
   
                           SCALE_HS_INIT(&su, (double)strlen(cp));
                           bufcat_su(h, "padding-left", &su);
                   }
   
                   PAIR_STYLE_INIT(&tag, h);
                   print_otag(h, TAG_DIV, 1, &tag);
           } else if (MDOC_HEAD == n->type) {
                   if (NULL == n->child && NULL == m->name)
                           return(1);
   
                   if (n->child && MDOC_TEXT == n->child->type)
                           cp = n->child->string;
                   if (NULL == cp || '\0' == *cp)
                           cp = m->name;
   
                   SCALE_HS_INIT(&su, (double)strlen(cp));
   
                   bufcat_style(h, "float", "left");
                   bufcat_su(h, "min-width", &su);
                   SCALE_INVERT(&su);
                   bufcat_su(h, "margin-left", &su);
   
                   PAIR_STYLE_INIT(&tag, h);
                   print_otag(h, TAG_DIV, 1, &tag);
   
                   if (NULL == n->child)
                           print_text(h, m->name);
           } else if (MDOC_BODY == n->type) {
                   SCALE_HS_INIT(&su, 2);
                   bufcat_su(h, "margin-left", &su);
                   PAIR_STYLE_INIT(&tag, h);
                   print_otag(h, TAG_DIV, 1, &tag);
           }
   
         return(1);          return(1);
 }  }
   
Line 1035  mdoc_it_pre(MDOC_ARGS)
Line 1089  mdoc_it_pre(MDOC_ARGS)
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 bl = bl->parent;                  bl = bl->parent;
   
         type = bl->data.Bl.type;          SCALE_HS_INIT(&offs, 0);
         comp = bl->data.Bl.comp;  
   
         /* Set default width and offset. */          assert(bl->data.Bl);
           type = bl->data.Bl->type;
           comp = bl->data.Bl->comp;
   
         SCALE_HS_INIT(&offs, 0);          if (bl->data.Bl->offs)
                   a2offs(bl->data.Bl->offs, &offs);
   
         switch (type) {          switch (type) {
         case (LIST_enum):          case (LIST_enum):
Line 1057  mdoc_it_pre(MDOC_ARGS)
Line 1113  mdoc_it_pre(MDOC_ARGS)
                 break;                  break;
         }          }
   
         /* Get width, offset, and compact arguments. */          if (bl->data.Bl->width)
                   a2width(bl->data.Bl->width, &width);
   
         wp = -1;          wp = -1;
         for (i = 0; bl->args && i < (int)bl->args->argc; i++)          for (i = 0; bl->args && i < (int)bl->args->argc; i++)
Line 1065  mdoc_it_pre(MDOC_ARGS)
Line 1122  mdoc_it_pre(MDOC_ARGS)
                 case (MDOC_Column):                  case (MDOC_Column):
                         wp = i; /* Save for later. */                          wp = i; /* Save for later. */
                         break;                          break;
                 case (MDOC_Width):  
                         a2width(bl->args->argv[i].value[0], &width);  
                         break;  
                 case (MDOC_Offset):  
                         a2offs(bl->args->argv[i].value[0], &offs);  
                         break;  
                 default:                  default:
                         break;                          break;
                 }                  }
Line 1121  mdoc_bl_pre(MDOC_ARGS)
Line 1172  mdoc_bl_pre(MDOC_ARGS)
                 return(0);                  return(0);
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
         if (LIST_enum != n->data.Bl.type)          assert(n->data.Bl);
           if (LIST_enum != n->data.Bl->type)
                 return(1);                  return(1);
   
         ord = malloc(sizeof(struct ord));          ord = malloc(sizeof(struct ord));
Line 1145  mdoc_bl_post(MDOC_ARGS)
Line 1197  mdoc_bl_post(MDOC_ARGS)
   
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return;                  return;
         if (LIST_enum != n->data.Bl.type)          if (LIST_enum != n->data.Bl->type)
                 return;                  return;
   
         ord = h->ords.head;          ord = h->ords.head;
Line 1360  mdoc_bd_pre(MDOC_ARGS)
Line 1412  mdoc_bd_pre(MDOC_ARGS)
   
         SCALE_VS_INIT(&su, 0);          SCALE_VS_INIT(&su, 0);
   
         if (n->data.Bd.offs)          assert(n->data.Bd);
                 a2offs(n->data.Bd.offs, &su);          if (n->data.Bd->offs)
                   a2offs(n->data.Bd->offs, &su);
   
         comp = n->data.Bd.comp;          comp = n->data.Bd->comp;
   
         /* FIXME: -centered, etc. formatting. */          /* FIXME: -centered, etc. formatting. */
         /* FIXME: does not respect -offset ??? */          /* FIXME: does not respect -offset ??? */
Line 1390  mdoc_bd_pre(MDOC_ARGS)
Line 1443  mdoc_bd_pre(MDOC_ARGS)
                 return(1);                  return(1);
         }          }
   
         if (DISP_unfilled != n->data.Bd.type &&          if (DISP_unfilled != n->data.Bd->type &&
                         DISP_literal != n->data.Bd.type)                          DISP_literal != n->data.Bd->type)
                 return(1);                  return(1);
   
         PAIR_CLASS_INIT(&tag[0], "lit");          PAIR_CLASS_INIT(&tag[0], "lit");
Line 1617  mdoc_fn_pre(MDOC_ARGS)
Line 1670  mdoc_fn_pre(MDOC_ARGS)
          */           */
   
 #if 0  #if 0
         if (SEC_SYNOPSIS == n->sec) {          if (MDOC_SYNPRETTY & n->flags) {
                 nbuf[0] = '\0';                  nbuf[0] = '\0';
                 html_idcat(nbuf, sp, BUFSIZ);                  html_idcat(nbuf, sp, BUFSIZ);
                 PAIR_ID_INIT(&tag[1], nbuf);                  PAIR_ID_INIT(&tag[1], nbuf);
Line 1647  mdoc_fn_pre(MDOC_ARGS)
Line 1700  mdoc_fn_pre(MDOC_ARGS)
   
         for (nn = n->child->next; nn; nn = nn->next) {          for (nn = n->child->next; nn; nn = nn->next) {
                 i = 1;                  i = 1;
                 if (SEC_SYNOPSIS == n->sec)                  if (MDOC_SYNPRETTY & n->flags)
                         i = 2;                          i = 2;
                 t = print_otag(h, TAG_SPAN, i, tag);                  t = print_otag(h, TAG_SPAN, i, tag);
                 print_text(h, nn->string);                  print_text(h, nn->string);
Line 1657  mdoc_fn_pre(MDOC_ARGS)
Line 1710  mdoc_fn_pre(MDOC_ARGS)
         }          }
   
         print_text(h, ")");          print_text(h, ")");
         if (SEC_SYNOPSIS == n->sec)          if (MDOC_SYNPRETTY & n->flags)
                 print_text(h, ";");                  print_text(h, ";");
   
         return(0);          return(0);
Line 1827  mdoc_in_pre(MDOC_ARGS)
Line 1880  mdoc_in_pre(MDOC_ARGS)
         PAIR_CLASS_INIT(&tag[0], "includes");          PAIR_CLASS_INIT(&tag[0], "includes");
         print_otag(h, TAG_SPAN, 1, tag);          print_otag(h, TAG_SPAN, 1, tag);
   
         if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)          if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags)
                 print_text(h, "#include");                  print_text(h, "#include");
   
         print_text(h, "<");          print_text(h, "<");
Line 1962  mdoc_ap_pre(MDOC_ARGS)
Line 2015  mdoc_ap_pre(MDOC_ARGS)
 static int  static int
 mdoc_bf_pre(MDOC_ARGS)  mdoc_bf_pre(MDOC_ARGS)
 {  {
         int              i;  
         struct htmlpair  tag[2];          struct htmlpair  tag[2];
         struct roffsu    su;          struct roffsu    su;
   
         if (MDOC_HEAD == n->type)          if (MDOC_HEAD == n->type)
                 return(0);                  return(0);
         else if (MDOC_BLOCK != n->type)          else if (MDOC_BODY != n->type)
                 return(1);                  return(1);
   
         PAIR_CLASS_INIT(&tag[0], "lit");          assert(n->data.Bf);
   
         if (n->head->child) {          if (FONT_Em == n->data.Bf->font)
                 if ( ! strcmp("Em", n->head->child->string))                  PAIR_CLASS_INIT(&tag[0], "emph");
                         PAIR_CLASS_INIT(&tag[0], "emph");          else if (FONT_Sy == n->data.Bf->font)
                 else if ( ! strcmp("Sy", n->head->child->string))                  PAIR_CLASS_INIT(&tag[0], "symb");
                         PAIR_CLASS_INIT(&tag[0], "symb");          else if (FONT_Li == n->data.Bf->font)
                 else if ( ! strcmp("Li", n->head->child->string))                  PAIR_CLASS_INIT(&tag[0], "lit");
                         PAIR_CLASS_INIT(&tag[0], "lit");          else
         } else {                  PAIR_CLASS_INIT(&tag[0], "none");
                 for (i = 0; n->args && i < (int)n->args->argc; i++)  
                         switch (n->args->argv[i].arg) {  
                         case (MDOC_Symbolic):  
                                 PAIR_CLASS_INIT(&tag[0], "symb");  
                                 break;  
                         case (MDOC_Literal):  
                                 PAIR_CLASS_INIT(&tag[0], "lit");  
                                 break;  
                         case (MDOC_Emphasis):  
                                 PAIR_CLASS_INIT(&tag[0], "emph");  
                                 break;  
                         default:  
                                 break;  
                         }  
         }  
   
         /* FIXME: div's have spaces stripped--we want them. */          /*
            * We want this to be inline-formatted, but needs to be div to
            * accept block children.
            */
         bufcat_style(h, "display", "inline");          bufcat_style(h, "display", "inline");
         SCALE_HS_INIT(&su, 1);          SCALE_HS_INIT(&su, 1);
         bufcat_su(h, "margin-right", &su);          /* Needs a left-margin for spacing. */
           bufcat_su(h, "margin-left", &su);
         PAIR_STYLE_INIT(&tag[1], h);          PAIR_STYLE_INIT(&tag[1], h);
         print_otag(h, TAG_DIV, 2, tag);          print_otag(h, TAG_DIV, 2, tag);
         return(1);          return(1);

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.92

CVSweb