[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.5 and 1.13

version 1.5, 2009/09/24 09:50:31 version 1.13, 2009/09/26 17:35:49
Line 15 
Line 15 
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #include <sys/types.h>  #include <sys/types.h>
   #include <sys/param.h>
 #include <sys/queue.h>  #include <sys/queue.h>
   
 #include <assert.h>  #include <assert.h>
Line 59  static int    mdoc_tbl_block_pre(MDOC_ARGS, int, int, 
Line 60  static int    mdoc_tbl_block_pre(MDOC_ARGS, int, int, 
 static  int               mdoc_tbl_body_pre(MDOC_ARGS, int, int);  static  int               mdoc_tbl_body_pre(MDOC_ARGS, int, int);
 static  int               mdoc_tbl_head_pre(MDOC_ARGS, int, int);  static  int               mdoc_tbl_head_pre(MDOC_ARGS, int, int);
   
   static  void              mdoc__x_post(MDOC_ARGS);
   static  int               mdoc__x_pre(MDOC_ARGS);
 static  int               mdoc_ad_pre(MDOC_ARGS);  static  int               mdoc_ad_pre(MDOC_ARGS);
 static  int               mdoc_an_pre(MDOC_ARGS);  static  int               mdoc_an_pre(MDOC_ARGS);
 static  int               mdoc_ap_pre(MDOC_ARGS);  static  int               mdoc_ap_pre(MDOC_ARGS);
Line 73  static void    mdoc_bq_post(MDOC_ARGS);
Line 76  static void    mdoc_bq_post(MDOC_ARGS);
 static  int               mdoc_bq_pre(MDOC_ARGS);  static  int               mdoc_bq_pre(MDOC_ARGS);
 static  void              mdoc_brq_post(MDOC_ARGS);  static  void              mdoc_brq_post(MDOC_ARGS);
 static  int               mdoc_brq_pre(MDOC_ARGS);  static  int               mdoc_brq_pre(MDOC_ARGS);
   static  int               mdoc_bt_pre(MDOC_ARGS);
 static  int               mdoc_bx_pre(MDOC_ARGS);  static  int               mdoc_bx_pre(MDOC_ARGS);
 static  int               mdoc_cd_pre(MDOC_ARGS);  static  int               mdoc_cd_pre(MDOC_ARGS);
 static  int               mdoc_d1_pre(MDOC_ARGS);  static  int               mdoc_d1_pre(MDOC_ARGS);
Line 93  static int    mdoc_fo_pre(MDOC_ARGS);
Line 97  static int    mdoc_fo_pre(MDOC_ARGS);
 static  int               mdoc_ic_pre(MDOC_ARGS);  static  int               mdoc_ic_pre(MDOC_ARGS);
 static  int               mdoc_in_pre(MDOC_ARGS);  static  int               mdoc_in_pre(MDOC_ARGS);
 static  int               mdoc_it_pre(MDOC_ARGS);  static  int               mdoc_it_pre(MDOC_ARGS);
   static  int               mdoc_lb_pre(MDOC_ARGS);
   static  int               mdoc_li_pre(MDOC_ARGS);
 static  int               mdoc_lk_pre(MDOC_ARGS);  static  int               mdoc_lk_pre(MDOC_ARGS);
 static  int               mdoc_mt_pre(MDOC_ARGS);  static  int               mdoc_mt_pre(MDOC_ARGS);
 static  int               mdoc_ms_pre(MDOC_ARGS);  static  int               mdoc_ms_pre(MDOC_ARGS);
Line 114  static void    mdoc_sq_post(MDOC_ARGS);
Line 120  static void    mdoc_sq_post(MDOC_ARGS);
 static  int               mdoc_sq_pre(MDOC_ARGS);  static  int               mdoc_sq_pre(MDOC_ARGS);
 static  int               mdoc_ss_pre(MDOC_ARGS);  static  int               mdoc_ss_pre(MDOC_ARGS);
 static  int               mdoc_sx_pre(MDOC_ARGS);  static  int               mdoc_sx_pre(MDOC_ARGS);
   static  int               mdoc_sy_pre(MDOC_ARGS);
   static  int               mdoc_ud_pre(MDOC_ARGS);
 static  int               mdoc_va_pre(MDOC_ARGS);  static  int               mdoc_va_pre(MDOC_ARGS);
 static  int               mdoc_vt_pre(MDOC_ARGS);  static  int               mdoc_vt_pre(MDOC_ARGS);
 static  int               mdoc_xr_pre(MDOC_ARGS);  static  int               mdoc_xr_pre(MDOC_ARGS);
Line 155  static const struct htmlmdoc mdocs[MDOC_MAX] = {
Line 163  static const struct htmlmdoc mdocs[MDOC_MAX] = {
         {mdoc_ft_pre, NULL}, /* Ft */          {mdoc_ft_pre, NULL}, /* Ft */
         {mdoc_ic_pre, NULL}, /* Ic */          {mdoc_ic_pre, NULL}, /* Ic */
         {mdoc_in_pre, NULL}, /* In */          {mdoc_in_pre, NULL}, /* In */
         {NULL, NULL}, /* Li */          {mdoc_li_pre, NULL}, /* Li */
         {mdoc_nd_pre, NULL}, /* Nd */          {mdoc_nd_pre, NULL}, /* Nd */
         {mdoc_nm_pre, NULL}, /* Nm */          {mdoc_nm_pre, NULL}, /* Nm */
         {mdoc_op_pre, mdoc_op_post}, /* Op */          {mdoc_op_pre, mdoc_op_post}, /* Op */
Line 166  static const struct htmlmdoc mdocs[MDOC_MAX] = {
Line 174  static const struct htmlmdoc mdocs[MDOC_MAX] = {
         {mdoc_va_pre, NULL}, /* Va */          {mdoc_va_pre, NULL}, /* Va */
         {mdoc_vt_pre, NULL}, /* Vt */          {mdoc_vt_pre, NULL}, /* Vt */
         {mdoc_xr_pre, NULL}, /* Xr */          {mdoc_xr_pre, NULL}, /* Xr */
         {NULL, NULL}, /* %A */          {mdoc__x_pre, mdoc__x_post}, /* %A */
         {NULL, NULL}, /* %B */          {mdoc__x_pre, mdoc__x_post}, /* %B */
         {NULL, NULL}, /* %D */          {mdoc__x_pre, mdoc__x_post}, /* %D */
         {NULL, NULL}, /* %I */          {mdoc__x_pre, mdoc__x_post}, /* %I */
         {NULL, NULL}, /* %J */          {mdoc__x_pre, mdoc__x_post}, /* %J */
         {NULL, NULL}, /* %N */          {mdoc__x_pre, mdoc__x_post}, /* %N */
         {NULL, NULL}, /* %O */          {mdoc__x_pre, mdoc__x_post}, /* %O */
         {NULL, NULL}, /* %P */          {mdoc__x_pre, mdoc__x_post}, /* %P */
         {NULL, NULL}, /* %R */          {mdoc__x_pre, mdoc__x_post}, /* %R */
         {NULL, NULL}, /* %T */          {mdoc__x_pre, mdoc__x_post}, /* %T */
         {NULL, NULL}, /* %V */          {mdoc__x_pre, mdoc__x_post}, /* %V */
         {NULL, NULL}, /* Ac */          {NULL, NULL}, /* Ac */
         {mdoc_aq_pre, mdoc_aq_post}, /* Ao */          {mdoc_aq_pre, mdoc_aq_post}, /* Ao */
         {mdoc_aq_pre, mdoc_aq_post}, /* Aq */          {mdoc_aq_pre, mdoc_aq_post}, /* Aq */
Line 214  static const struct htmlmdoc mdocs[MDOC_MAX] = {
Line 222  static const struct htmlmdoc mdocs[MDOC_MAX] = {
         {NULL, NULL}, /* Sc */          {NULL, NULL}, /* Sc */
         {mdoc_sq_pre, mdoc_sq_post}, /* So */          {mdoc_sq_pre, mdoc_sq_post}, /* So */
         {mdoc_sq_pre, mdoc_sq_post}, /* Sq */          {mdoc_sq_pre, mdoc_sq_post}, /* Sq */
         {NULL, NULL}, /* Sm */          {NULL, NULL}, /* Sm */ /* FIXME - no idea. */
         {mdoc_sx_pre, NULL}, /* Sx */          {mdoc_sx_pre, NULL}, /* Sx */
         {NULL, NULL}, /* Sy */          {mdoc_sy_pre, NULL}, /* Sy */
         {NULL, NULL}, /* Tn */          {NULL, NULL}, /* Tn */
         {mdoc_xx_pre, NULL}, /* Ux */          {mdoc_xx_pre, NULL}, /* Ux */
         {NULL, NULL}, /* Xc */          {NULL, NULL}, /* Xc */
Line 227  static const struct htmlmdoc mdocs[MDOC_MAX] = {
Line 235  static const struct htmlmdoc mdocs[MDOC_MAX] = {
         {NULL, NULL}, /* Oc */          {NULL, NULL}, /* Oc */
         {NULL, NULL}, /* Bk */          {NULL, NULL}, /* Bk */
         {NULL, NULL}, /* Ek */          {NULL, NULL}, /* Ek */
         {NULL, NULL}, /* Bt */          {mdoc_bt_pre, NULL}, /* Bt */
         {NULL, NULL}, /* Hf */          {NULL, NULL}, /* Hf */
         {NULL, NULL}, /* Fr */          {NULL, NULL}, /* Fr */
         {NULL, NULL}, /* Ud */          {mdoc_ud_pre, NULL}, /* Ud */
         {NULL, NULL}, /* Lb */          {mdoc_lb_pre, NULL}, /* Lb */
         {mdoc_sp_pre, NULL}, /* Lp */          {mdoc_sp_pre, NULL}, /* Lp */
         {mdoc_lk_pre, NULL}, /* Lk */          {mdoc_lk_pre, NULL}, /* Lk */
         {mdoc_mt_pre, NULL}, /* Mt */          {mdoc_mt_pre, NULL}, /* Mt */
         {mdoc_brq_pre, mdoc_brq_post}, /* Brq */          {mdoc_brq_pre, mdoc_brq_post}, /* Brq */
         {mdoc_brq_pre, mdoc_brq_post}, /* Bro */          {mdoc_brq_pre, mdoc_brq_post}, /* Bro */
         {NULL, NULL}, /* Brc */          {NULL, NULL}, /* Brc */
         {NULL, NULL}, /* %C */          {mdoc__x_pre, mdoc__x_post}, /* %C */
         {NULL, NULL}, /* Es */  /* TODO */          {NULL, NULL}, /* Es */  /* TODO */
         {NULL, NULL}, /* En */  /* TODO */          {NULL, NULL}, /* En */  /* TODO */
         {mdoc_xx_pre, NULL}, /* Dx */          {mdoc_xx_pre, NULL}, /* Dx */
         {NULL, NULL}, /* %Q */          {mdoc__x_pre, mdoc__x_post}, /* %Q */
         {mdoc_sp_pre, NULL}, /* br */          {mdoc_sp_pre, NULL}, /* br */
         {mdoc_sp_pre, NULL}, /* sp */          {mdoc_sp_pre, NULL}, /* sp */
 };  };
Line 517  mdoc_root_pre(MDOC_ARGS)
Line 525  mdoc_root_pre(MDOC_ARGS)
         tt = print_otag(h, TAG_TR, 0, NULL);          tt = print_otag(h, TAG_TR, 0, NULL);
   
         tag[0].key = ATTR_STYLE;          tag[0].key = ATTR_STYLE;
         tag[0].val = "width: 33%;";          tag[0].val = "width: 10%;";
         print_otag(h, TAG_TD, 1, tag);          print_otag(h, TAG_TD, 1, tag);
         print_text(h, title);          print_text(h, title);
         print_stagq(h, tt);          print_stagq(h, tt);
   
         tag[0].key = ATTR_STYLE;          tag[0].key = ATTR_STYLE;
         tag[0].val = "width: 33%; text-align: center;";          tag[0].val = "width: 80%; white-space: nowrap; text-align: center;";
         print_otag(h, TAG_TD, 1, tag);          print_otag(h, TAG_TD, 1, tag);
         print_text(h, b);          print_text(h, b);
         print_stagq(h, tt);          print_stagq(h, tt);
   
         tag[0].key = ATTR_STYLE;          tag[0].key = ATTR_STYLE;
         tag[0].val = "width: 33%; text-align: right;";          tag[0].val = "width: 10%; text-align: right;";
         print_otag(h, TAG_TD, 1, tag);          print_otag(h, TAG_TD, 1, tag);
         print_text(h, title);          print_text(h, title);
         print_tagq(h, t);          print_tagq(h, t);
Line 1319  mdoc_bd_pre(MDOC_ARGS)
Line 1327  mdoc_bd_pre(MDOC_ARGS)
                 switch (bl->args->argv[i].arg) {                  switch (bl->args->argv[i].arg) {
                 case (MDOC_Offset):                  case (MDOC_Offset):
                         assert(bl->args->argv[i].sz);                          assert(bl->args->argv[i].sz);
                         o = a2offs (bl->args->argv[i].value[0]);                          o = a2offs(bl->args->argv[i].value[0]);
                         break;                          break;
                 case (MDOC_Compact):                  case (MDOC_Compact):
                         c = 1;                          c = 1;
Line 1555  mdoc_ft_pre(MDOC_ARGS)
Line 1563  mdoc_ft_pre(MDOC_ARGS)
         }          }
   
         tag.key = ATTR_CLASS;          tag.key = ATTR_CLASS;
         tag.val = "type";          tag.val = "ftype";
         print_otag(h, TAG_SPAN, 1, &tag);          print_otag(h, TAG_SPAN, 1, &tag);
         return(1);          return(1);
 }  }
Line 1568  mdoc_fn_pre(MDOC_ARGS)
Line 1576  mdoc_fn_pre(MDOC_ARGS)
         struct tag              *t;          struct tag              *t;
         struct htmlpair          tag;          struct htmlpair          tag;
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
           char                     nbuf[BUFSIZ];
           const char              *sp, *ep;
           int                      sz;
   
         if (SEC_SYNOPSIS == n->sec) {          if (SEC_SYNOPSIS == n->sec) {
                 if (n->next) {                  if (n->next) {
Line 1578  mdoc_fn_pre(MDOC_ARGS)
Line 1589  mdoc_fn_pre(MDOC_ARGS)
                         print_otag(h, TAG_DIV, 0, NULL);                          print_otag(h, TAG_DIV, 0, NULL);
         }          }
   
           /* Split apart into type and name. */
   
         tag.key = ATTR_CLASS;          tag.key = ATTR_CLASS;
         tag.val = "type";          tag.val = "ftype";
           t = print_otag(h, TAG_SPAN, 1, &tag);
   
         /* FIXME: can be "type funcname" "type varname"... */          assert(n->child->string);
           sp = n->child->string;
           while (NULL != (ep = strchr(sp, ' '))) {
                   sz = MIN((int)(ep - sp), BUFSIZ - 1);
                   (void)memcpy(nbuf, sp, (size_t)sz);
                   nbuf[sz] = '\0';
                   print_text(h, nbuf);
                   sp = ++ep;
           }
   
           print_tagq(h, t);
   
           tag.key = ATTR_CLASS;
           tag.val = "fname";
         t = print_otag(h, TAG_SPAN, 1, &tag);          t = print_otag(h, TAG_SPAN, 1, &tag);
         print_text(h, n->child->string);  
           if (sp) {
                   (void)strlcpy(nbuf, sp, BUFSIZ);
                   print_text(h, nbuf);
           }
   
         print_tagq(h, t);          print_tagq(h, t);
   
         h->flags |= HTML_NOSPACE;          h->flags |= HTML_NOSPACE;
Line 1986  mdoc_pf_post(MDOC_ARGS)
Line 2017  mdoc_pf_post(MDOC_ARGS)
 static int  static int
 mdoc_rs_pre(MDOC_ARGS)  mdoc_rs_pre(MDOC_ARGS)
 {  {
         struct htmlpair tag[2];          struct htmlpair tag;
         int             i;  
   
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
   
         tag[i = 0].key = ATTR_CLASS;          if (n->prev && SEC_SEE_ALSO == n->sec) {
         tag[i++].val = "ref";                  tag.key = ATTR_STYLE;
                   tag.val = "margin-top: 1em;";
         if (n->prev && SEC_SYNOPSIS == n->sec) {                  print_otag(h, TAG_DIV, 1, &tag);
                 tag[i].key = ATTR_STYLE;  
                 tag[i++].val = "margin-top: 1em;";  
         } else if (SEC_SYNOPSIS != n->sec) {  
                 tag[i].key = ATTR_STYLE;  
                 tag[i++].val = "display: inline; margin-right: 1em";  
         }          }
   
         /* FIXME: div's have spaces stripped--we want them. */          tag.key = ATTR_CLASS;
           tag.val = "ref";
           print_otag(h, TAG_SPAN, 1, &tag);
           return(1);
   }
   
         print_otag(h, TAG_DIV, i, tag);  
   
   /* ARGSUSED */
   static int
   mdoc_li_pre(MDOC_ARGS)
   {
           struct htmlpair tag;
   
           tag.key = ATTR_CLASS;
           tag.val = "lit";
   
           print_otag(h, TAG_SPAN, 1, &tag);
         return(1);          return(1);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_sy_pre(MDOC_ARGS)
   {
           struct htmlpair tag;
   
           tag.key = ATTR_CLASS;
           tag.val = "symb";
   
           print_otag(h, TAG_SPAN, 1, &tag);
           return(1);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_bt_pre(MDOC_ARGS)
   {
   
           print_text(h, "is currently in beta test.");
           return(0);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_ud_pre(MDOC_ARGS)
   {
   
           print_text(h, "currently under development.");
           return(0);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_lb_pre(MDOC_ARGS)
   {
           struct htmlpair tag;
   
           tag.key = ATTR_CLASS;
           tag.val = "lib";
   
           if (SEC_SYNOPSIS == n->sec)
                   print_otag(h, TAG_DIV, 0, NULL);
   
           print_otag(h, TAG_SPAN, 1, &tag);
           return(1);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc__x_pre(MDOC_ARGS)
   {
           struct htmlpair tag;
   
           tag.key = ATTR_CLASS;
   
           switch (n->tok) {
           case(MDOC__A):
                   tag.val = "ref-auth";
                   break;
           case(MDOC__B):
                   tag.val = "ref-book";
                   break;
           case(MDOC__C):
                   tag.val = "ref-city";
                   break;
           case(MDOC__D):
                   tag.val = "ref-date";
                   break;
           case(MDOC__I):
                   tag.val = "ref-issue";
                   break;
           case(MDOC__J):
                   tag.val = "ref-jrnl";
                   break;
           case(MDOC__N):
                   tag.val = "ref-num";
                   break;
           case(MDOC__O):
                   tag.val = "ref-opt";
                   break;
           case(MDOC__P):
                   tag.val = "ref-page";
                   break;
           case(MDOC__Q):
                   tag.val = "ref-corp";
                   break;
           case(MDOC__R):
                   tag.val = "ref-rep";
                   break;
           case(MDOC__T):
                   print_text(h, "\\(lq");
                   h->flags |= HTML_NOSPACE;
                   tag.val = "ref-title";
                   break;
           case(MDOC__V):
                   tag.val = "ref-vol";
                   break;
           default:
                   abort();
                   /* NOTREACHED */
           }
   
           print_otag(h, TAG_SPAN, 1, &tag);
           return(1);
   }
   
   
   /* ARGSUSED */
   static void
   mdoc__x_post(MDOC_ARGS)
   {
   
           h->flags |= HTML_NOSPACE;
           switch (n->tok) {
           case (MDOC__T):
                   print_text(h, "\\(rq");
                   h->flags |= HTML_NOSPACE;
                   break;
           default:
                   break;
           }
           print_text(h, n->next ? "," : ".");
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.13

CVSweb