[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.2 and 1.18

version 1.2, 2009/09/21 23:12:08 version 1.18, 2009/10/03 16:36:06
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  void              mdoc_aq_post(MDOC_ARGS);  static  void              mdoc_aq_post(MDOC_ARGS);
 static  int               mdoc_aq_pre(MDOC_ARGS);  static  int               mdoc_aq_pre(MDOC_ARGS);
 static  int               mdoc_ar_pre(MDOC_ARGS);  static  int               mdoc_ar_pre(MDOC_ARGS);
 static  int               mdoc_bd_pre(MDOC_ARGS);  static  int               mdoc_bd_pre(MDOC_ARGS);
   static  int               mdoc_bf_pre(MDOC_ARGS);
 static  void              mdoc_bl_post(MDOC_ARGS);  static  void              mdoc_bl_post(MDOC_ARGS);
 static  int               mdoc_bl_pre(MDOC_ARGS);  static  int               mdoc_bl_pre(MDOC_ARGS);
   static  void              mdoc_bq_post(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_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);
 static  void              mdoc_dq_post(MDOC_ARGS);  static  void              mdoc_dq_post(MDOC_ARGS);
Line 83  static int    mdoc_em_pre(MDOC_ARGS);
Line 92  static int    mdoc_em_pre(MDOC_ARGS);
 static  int               mdoc_er_pre(MDOC_ARGS);  static  int               mdoc_er_pre(MDOC_ARGS);
 static  int               mdoc_ev_pre(MDOC_ARGS);  static  int               mdoc_ev_pre(MDOC_ARGS);
 static  int               mdoc_ex_pre(MDOC_ARGS);  static  int               mdoc_ex_pre(MDOC_ARGS);
   static  void              mdoc_fo_post(MDOC_ARGS);
   static  int               mdoc_fo_pre(MDOC_ARGS);
   static  int               mdoc_ic_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_nd_pre(MDOC_ARGS);  static  int               mdoc_nd_pre(MDOC_ARGS);
 static  int               mdoc_nm_pre(MDOC_ARGS);  static  int               mdoc_nm_pre(MDOC_ARGS);
 static  int               mdoc_ns_pre(MDOC_ARGS);  static  int               mdoc_ns_pre(MDOC_ARGS);
 static  void              mdoc_op_post(MDOC_ARGS);  static  void              mdoc_op_post(MDOC_ARGS);
 static  int               mdoc_op_pre(MDOC_ARGS);  static  int               mdoc_op_pre(MDOC_ARGS);
 static  int               mdoc_pa_pre(MDOC_ARGS);  static  int               mdoc_pa_pre(MDOC_ARGS);
   static  void              mdoc_pf_post(MDOC_ARGS);
   static  int               mdoc_pf_pre(MDOC_ARGS);
 static  void              mdoc_pq_post(MDOC_ARGS);  static  void              mdoc_pq_post(MDOC_ARGS);
 static  int               mdoc_pq_pre(MDOC_ARGS);  static  int               mdoc_pq_pre(MDOC_ARGS);
 static  void              mdoc_qq_post(MDOC_ARGS);  static  int               mdoc_rs_pre(MDOC_ARGS);
 static  int               mdoc_qq_pre(MDOC_ARGS);  static  int               mdoc_rv_pre(MDOC_ARGS);
 static  int               mdoc_sh_pre(MDOC_ARGS);  static  int               mdoc_sh_pre(MDOC_ARGS);
 static  int               mdoc_sp_pre(MDOC_ARGS);  static  int               mdoc_sp_pre(MDOC_ARGS);
 static  void              mdoc_sq_post(MDOC_ARGS);  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_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);
 static  int               mdoc_xx_pre(MDOC_ARGS);  static  int               mdoc_xx_pre(MDOC_ARGS);
Line 112  extern size_t      strlcat(char *, const char *, size_
Line 133  extern size_t      strlcat(char *, const char *, size_
 #endif  #endif
   
 static  const struct htmlmdoc mdocs[MDOC_MAX] = {  static  const struct htmlmdoc mdocs[MDOC_MAX] = {
         {NULL, NULL}, /* Ap */          {mdoc_ap_pre, NULL}, /* Ap */
         {NULL, NULL}, /* Dd */          {NULL, NULL}, /* Dd */
         {NULL, NULL}, /* Dt */          {NULL, NULL}, /* Dt */
         {NULL, NULL}, /* Os */          {NULL, NULL}, /* Os */
Line 140  static const struct htmlmdoc mdocs[MDOC_MAX] = {
Line 161  static const struct htmlmdoc mdocs[MDOC_MAX] = {
         {mdoc_fl_pre, NULL}, /* Fl */          {mdoc_fl_pre, NULL}, /* Fl */
         {mdoc_fn_pre, NULL}, /* Fn */          {mdoc_fn_pre, NULL}, /* Fn */
         {mdoc_ft_pre, NULL}, /* Ft */          {mdoc_ft_pre, NULL}, /* Ft */
         {NULL, NULL}, /* Ic */          {mdoc_ic_pre, NULL}, /* Ic */
         {NULL, 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 */
         {NULL, NULL}, /* Ot */          {NULL, NULL}, /* Ot */
         {mdoc_pa_pre, NULL}, /* Pa */          {mdoc_pa_pre, NULL}, /* Pa */
         {NULL, NULL}, /* Rv */          {mdoc_rv_pre, NULL}, /* Rv */
         {NULL, NULL}, /* St */          {NULL, NULL}, /* St */
         {NULL, 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 */
         {NULL, NULL}, /* At */          {NULL, NULL}, /* At */
         {NULL, NULL}, /* Bc */          {NULL, NULL}, /* Bc */
         {NULL, NULL}, /* Bf */          {mdoc_bf_pre, NULL}, /* Bf */
         {NULL, NULL}, /* Bo */          {mdoc_bq_pre, mdoc_bq_post}, /* Bo */
         {NULL, NULL}, /* Bq */          {mdoc_bq_pre, mdoc_bq_post}, /* Bq */
         {mdoc_xx_pre, NULL}, /* Bsx */          {mdoc_xx_pre, NULL}, /* Bsx */
         {NULL, NULL}, /* Bx */          {mdoc_bx_pre, NULL}, /* Bx */
         {NULL, NULL}, /* Db */          {NULL, NULL}, /* Db */
         {NULL, NULL}, /* Dc */          {NULL, NULL}, /* Dc */
         {NULL, NULL}, /* Do */          {mdoc_dq_pre, mdoc_dq_post}, /* Do */
         {mdoc_dq_pre, mdoc_dq_post}, /* Dq */          {mdoc_dq_pre, mdoc_dq_post}, /* Dq */
         {NULL, NULL}, /* Ec */          {NULL, NULL}, /* Ec */
         {NULL, NULL}, /* Ef */          {NULL, NULL}, /* Ef */
         {mdoc_em_pre, NULL}, /* Em */          {mdoc_em_pre, NULL}, /* Em */
         {NULL, NULL}, /* Eo */          {NULL, NULL}, /* Eo */
         {mdoc_xx_pre, NULL}, /* Fx */          {mdoc_xx_pre, NULL}, /* Fx */
         {NULL, NULL}, /* Ms */          {mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */
         {NULL, NULL}, /* No */          {NULL, NULL}, /* No */
         {mdoc_ns_pre, NULL}, /* Ns */          {mdoc_ns_pre, NULL}, /* Ns */
         {mdoc_xx_pre, NULL}, /* Nx */          {mdoc_xx_pre, NULL}, /* Nx */
         {mdoc_xx_pre, NULL}, /* Ox */          {mdoc_xx_pre, NULL}, /* Ox */
         {NULL, NULL}, /* Pc */          {NULL, NULL}, /* Pc */
         {NULL, NULL}, /* Pf */          {mdoc_pf_pre, mdoc_pf_post}, /* Pf */
         {mdoc_pq_pre, mdoc_pq_post}, /* Po */          {mdoc_pq_pre, mdoc_pq_post}, /* Po */
         {mdoc_pq_pre, mdoc_pq_post}, /* Pq */          {mdoc_pq_pre, mdoc_pq_post}, /* Pq */
         {NULL, NULL}, /* Qc */          {NULL, NULL}, /* Qc */
         {NULL, NULL}, /* Ql */          {mdoc_sq_pre, mdoc_sq_post}, /* Ql */
         {mdoc_qq_pre, mdoc_qq_post}, /* Qo */          {mdoc_dq_pre, mdoc_dq_post}, /* Qo */
         {mdoc_qq_pre, mdoc_qq_post}, /* Qq */          {mdoc_dq_pre, mdoc_dq_post}, /* Qq */
         {NULL, NULL}, /* Re */          {NULL, NULL}, /* Re */
         {NULL, NULL}, /* Rs */          {mdoc_rs_pre, NULL}, /* Rs */
         {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 */
         {NULL, NULL}, /* Xo */          {NULL, NULL}, /* Xo */
         {NULL, NULL}, /* Fo */          {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
         {NULL, NULL}, /* Fc */          {NULL, NULL}, /* Fc */
         {NULL, NULL}, /* Oo */          {mdoc_op_pre, mdoc_op_post}, /* Oo */
         {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 */
 };  };
   
 static  char              buf[BUFSIZ]; /* XXX */  
   
 #define bufcat(x)         (void)strlcat(buf, (x), BUFSIZ)  
 #define bufinit()         buf[0] = 0  
 #define buffmt(...)       (void)snprintf(buf, BUFSIZ - 1, __VA_ARGS__)  
   
 void  void
 html_mdoc(void *arg, const struct mdoc *m)  html_mdoc(void *arg, const struct mdoc *m)
 {  {
Line 406  print_mdoc_node(MDOC_ARGS)
Line 422  print_mdoc_node(MDOC_ARGS)
         child = 1;          child = 1;
         t = SLIST_FIRST(&h->tags);          t = SLIST_FIRST(&h->tags);
   
         bufinit();          bufinit(h);
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_ROOT):          case (MDOC_ROOT):
Line 426  print_mdoc_node(MDOC_ARGS)
Line 442  print_mdoc_node(MDOC_ARGS)
   
         print_stagq(h, t);          print_stagq(h, t);
   
         bufinit();          bufinit(h);
   
         switch (n->type) {          switch (n->type) {
         case (MDOC_ROOT):          case (MDOC_ROOT):
Line 504  mdoc_root_pre(MDOC_ARGS)
Line 520  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 539  mdoc_sh_pre(MDOC_ARGS)
Line 555  mdoc_sh_pre(MDOC_ARGS)
                 print_otag(h, TAG_SPAN, 1, tag);                  print_otag(h, TAG_SPAN, 1, tag);
   
                 for (nn = n->child; nn; nn = nn->next) {                  for (nn = n->child; nn; nn = nn->next) {
                         bufcat(nn->string);                          bufcat(h, nn->string);
                         if (nn->next)                          if (nn->next)
                                 bufcat(" ");                                  bufncat(h, " ", 1);
                 }                  }
                 tag[0].key = ATTR_NAME;                  tag[0].key = ATTR_NAME;
                 tag[0].val = buf;                  tag[0].val = h->buf;
                 print_otag(h, TAG_A, 1, tag);                  print_otag(h, TAG_A, 1, tag);
                 return(1);                  return(1);
         } else if (MDOC_BLOCK == n->type) {          } else if (MDOC_BLOCK == n->type) {
Line 556  mdoc_sh_pre(MDOC_ARGS)
Line 572  mdoc_sh_pre(MDOC_ARGS)
                         return(1);                          return(1);
                 }                  }
   
                 bufcat("margin-top: 1em;");                  bufcat(h, "margin-top: 1em;");
                 if (NULL == n->next)                  if (NULL == n->next)
                         bufcat("margin-bottom: 1em;");                          bufcat(h, "margin-bottom: 1em;");
   
                 tag[1].key = ATTR_STYLE;                  tag[1].key = ATTR_STYLE;
                 tag[1].val = buf;                  tag[1].val = h->buf;
   
                 print_otag(h, TAG_DIV, 2, tag);                  print_otag(h, TAG_DIV, 2, tag);
                 return(1);                  return(1);
         }          }
   
         buffmt("margin-left: %dem;", INDENT);          buffmt(h, "margin-left: %dem;", INDENT);
   
         tag[0].key = ATTR_CLASS;          tag[0].key = ATTR_CLASS;
         tag[0].val = "sec-body";          tag[0].val = "sec-body";
         tag[1].key = ATTR_STYLE;          tag[1].key = ATTR_STYLE;
         tag[1].val = buf;          tag[1].val = h->buf;
   
         print_otag(h, TAG_DIV, 2, tag);          print_otag(h, TAG_DIV, 2, tag);
         return(1);          return(1);
Line 593  mdoc_ss_pre(MDOC_ARGS)
Line 609  mdoc_ss_pre(MDOC_ARGS)
                 tag[i].key = ATTR_CLASS;                  tag[i].key = ATTR_CLASS;
                 tag[i++].val = "ssec-body";                  tag[i++].val = "ssec-body";
                 if (n->parent->next && n->child) {                  if (n->parent->next && n->child) {
                         bufcat("margin-bottom: 1em;");                          bufcat(h, "margin-bottom: 1em;");
                         tag[i].key = ATTR_STYLE;                          tag[i].key = ATTR_STYLE;
                         tag[i++].val = buf;                          tag[i++].val = h->buf;
                 }                  }
                 print_otag(h, TAG_DIV, i, tag);                  print_otag(h, TAG_DIV, i, tag);
                 return(1);                  return(1);
Line 603  mdoc_ss_pre(MDOC_ARGS)
Line 619  mdoc_ss_pre(MDOC_ARGS)
                 tag[i].key = ATTR_CLASS;                  tag[i].key = ATTR_CLASS;
                 tag[i++].val = "ssec-block";                  tag[i++].val = "ssec-block";
                 if (n->prev) {                  if (n->prev) {
                         bufcat("margin-top: 1em;");                          bufcat(h, "margin-top: 1em;");
                         tag[i].key = ATTR_STYLE;                          tag[i].key = ATTR_STYLE;
                         tag[i++].val = buf;                          tag[i++].val = h->buf;
                 }                  }
                 print_otag(h, TAG_DIV, i, tag);                  print_otag(h, TAG_DIV, i, tag);
                 return(1);                  return(1);
         }          }
   
         buffmt("margin-left: -%dem;", INDENT - HALFINDENT);          buffmt(h, "margin-left: -%dem;", INDENT - HALFINDENT);
   
         tag[0].key = ATTR_CLASS;          tag[0].key = ATTR_CLASS;
         tag[0].val = "ssec-head";          tag[0].val = "ssec-head";
         tag[1].key = ATTR_STYLE;          tag[1].key = ATTR_STYLE;
         tag[1].val = buf;          tag[1].val = h->buf;
   
         print_otag(h, TAG_DIV, 2, tag);          print_otag(h, TAG_DIV, 2, tag);
         print_otag(h, TAG_SPAN, 1, tag);          print_otag(h, TAG_SPAN, 1, tag);
   
         bufinit();          bufinit(h);
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 bufcat(nn->string);                  bufcat(h, nn->string);
                 if (nn->next)                  if (nn->next)
                         bufcat(" ");                          bufcat(h, " ");
         }          }
         tag[0].key = ATTR_NAME;          tag[0].key = ATTR_NAME;
         tag[0].val = buf;          tag[0].val = h->buf;
         print_otag(h, TAG_A, 1, tag);          print_otag(h, TAG_A, 1, tag);
   
         return(1);          return(1);
Line 730  static int
Line 746  static int
 mdoc_xr_pre(MDOC_ARGS)  mdoc_xr_pre(MDOC_ARGS)
 {  {
         struct htmlpair          tag[2];          struct htmlpair          tag[2];
         const char              *name, *sec;  
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
           int                      i;
   
         nn = n->child;          i = 0;
         name = nn && nn->string ? nn->string : "";          tag[i].key = ATTR_CLASS;
         nn = nn ? nn->next : NULL;          tag[i++].val = "link-man";
         sec = nn && nn->string ? nn->string : "";  
   
         buffmt("%s%s%s.html", name, name && sec ? "." : "", sec);          if (h->base_man) {
                   buffmt_man(h, n->child->string, n->child->next ?
                                   n->child->next->string : NULL);
                   tag[i].key = ATTR_HREF;
                   tag[i++].val = h->buf;
           }
   
         tag[0].key = ATTR_CLASS;          print_otag(h, TAG_A, i, tag);
         tag[0].val = "link-man";  
         tag[1].key = ATTR_HREF;  
         tag[1].val = buf;  
         print_otag(h, TAG_A, 2, tag);  
   
         nn = n->child;          nn = n->child;
         print_text(h, nn->string);          print_text(h, nn->string);
   
         if (NULL == (nn = nn->next))          if (NULL == (nn = nn->next))
                 return(0);                  return(0);
   
Line 827  mdoc_xx_pre(MDOC_ARGS)
Line 844  mdoc_xx_pre(MDOC_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
   mdoc_bx_pre(MDOC_ARGS)
   {
           const struct mdoc_node  *nn;
           struct htmlpair          tag;
   
           tag.key = ATTR_CLASS;
           tag.val = "unix";
   
           print_otag(h, TAG_SPAN, 1, &tag);
   
           for (nn = n->child; nn; nn = nn->next)
                   print_mdoc_node(m, nn, h);
   
           if (n->child)
                   h->flags |= HTML_NOSPACE;
   
           print_text(h, "BSD");
           return(0);
   }
   
   
   /* ARGSUSED */
   static int
 mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int c)  mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int c)
 {  {
         struct htmlpair  tag;          struct htmlpair          tag;
           const struct mdoc_node  *nn;
   
         switch (t) {          switch (t) {
         case (MDOC_Column):          case (MDOC_Column):
Line 837  mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int
Line 878  mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int
         case (MDOC_Item):          case (MDOC_Item):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Ohang):          case (MDOC_Ohang):
                 buffmt("margin-left: %dem; clear: both;", o);                  buffmt(h, "margin-left: %dem; clear: both;", o);
                 break;                  break;
         default:          default:
                 buffmt("margin-left: %dem; clear: both;", w + o);                  buffmt(h, "margin-left: %dem; clear: both;", w + o);
                 break;                  break;
         }          }
   
         if ( ! c && MDOC_Column != t) {          if ( ! c && MDOC_Column != t) {
                if (n->prev && n->prev->body->child)                  for (nn = n; nn; nn = nn->parent) {
                        bufcat("padding-top: 1em;");                          if (MDOC_BLOCK != nn->type)
                else if (NULL == n->prev)                                  continue;
                        bufcat("padding-top: 1em;");                          switch (nn->tok) {
                           case (MDOC_Ss):
                                   /* FALLTHROUGH */
                           case (MDOC_Sh):
                                   c = 1;
                                   break;
                           default:
                                   break;
                           }
                           if (nn->prev)
                                   break;
                   }
                   if (MDOC_Diag == t && n->prev)
                           if (NULL == n->prev->body->child)
                                   c = 1;
                   if ( ! c)
                           bufcat(h, "padding-top: 1em;");
         }          }
   
         tag.key = ATTR_STYLE;          tag.key = ATTR_STYLE;
         tag.val = buf;          tag.val = h->buf;
         print_otag(h, TAG_DIV, 1, &tag);          print_otag(h, TAG_DIV, 1, &tag);
         return(1);          return(1);
 }  }
Line 883  mdoc_tbl_head_pre(MDOC_ARGS, int t, int w)
Line 940  mdoc_tbl_head_pre(MDOC_ARGS, int t, int w)
                 print_otag(h, TAG_DIV, 0, NULL);                  print_otag(h, TAG_DIV, 0, NULL);
                 break;                  break;
         case (MDOC_Column):          case (MDOC_Column):
                 buffmt("min-width: %dem;", w);                  buffmt(h, "min-width: %dem;", w);
                 bufcat("clear: none;");                  bufcat(h, "clear: none;");
                 if (n->next && MDOC_HEAD == n->next->type)                  if (n->next && MDOC_HEAD == n->next->type)
                         bufcat("float: left;");                          bufcat(h, "float: left;");
                 tag.key = ATTR_STYLE;                  tag.key = ATTR_STYLE;
                 tag.val = buf;                  tag.val = h->buf;
                 print_otag(h, TAG_DIV, 1, &tag);                  print_otag(h, TAG_DIV, 1, &tag);
                 break;                  break;
         default:          default:
                 buffmt("margin-left: -%dem;", w);                  buffmt(h, "margin-left: -%dem; min-width: %dem;",
                 bufcat("clear: left;");                                  w, w ? w - 1 : 0);
                   bufcat(h, "clear: left;");
                 if (n->next && n->next->child)                  if (n->next && n->next->child)
                         bufcat("float: left;");                          bufcat(h, "float: left;");
                 bufcat("padding-right: 1em;");                  bufcat(h, "padding-right: 1em;");
                 tag.key = ATTR_STYLE;                  tag.key = ATTR_STYLE;
                 tag.val = buf;                  tag.val = h->buf;
                 print_otag(h, TAG_DIV, 1, &tag);                  print_otag(h, TAG_DIV, 1, &tag);
                 break;                  break;
         }          }
Line 920  mdoc_tbl_head_pre(MDOC_ARGS, int t, int w)
Line 978  mdoc_tbl_head_pre(MDOC_ARGS, int t, int w)
                 print_text(h, "\\(en");                  print_text(h, "\\(en");
                 return(0);                  return(0);
         case (MDOC_Hyphen):          case (MDOC_Hyphen):
                 print_text(h, "\\-");                  print_text(h, "\\(hy");
                 return(0);                  return(0);
         case (MDOC_Bullet):          case (MDOC_Bullet):
                 print_text(h, "\\(bu");                  print_text(h, "\\(bu");
Line 943  mdoc_tbl_pre(MDOC_ARGS, int type)
Line 1001  mdoc_tbl_pre(MDOC_ARGS, int type)
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 bl = bl->parent;                  bl = bl->parent;
   
         /* FIXME: fmt_vspace() equivalent. */  
   
         assert(bl->args);          assert(bl->args);
   
         w = o = c = 0;          w = o = c = 0;
Line 1020  mdoc_bl_pre(MDOC_ARGS)
Line 1076  mdoc_bl_pre(MDOC_ARGS)
         if (MDOC_Enum != a2list(n))          if (MDOC_Enum != a2list(n))
                 return(1);                  return(1);
   
           /* Allocate an -enum on the stack of indices. */
   
         ord = malloc(sizeof(struct ord));          ord = malloc(sizeof(struct ord));
         if (NULL == ord)          if (NULL == ord)
                 err(EXIT_FAILURE, "malloc");                  err(EXIT_FAILURE, "malloc");
Line 1198  mdoc_d1_pre(MDOC_ARGS)
Line 1256  mdoc_d1_pre(MDOC_ARGS)
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
   
         buffmt("margin-left: %dem;", INDENT);          buffmt(h, "margin-left: %dem;", INDENT);
   
         tag[0].key = ATTR_CLASS;          tag[0].key = ATTR_CLASS;
         tag[0].val = "lit-block";          tag[0].val = "lit";
         tag[1].key = ATTR_STYLE;          tag[1].key = ATTR_STYLE;
         tag[1].val = buf;          tag[1].val = h->buf;
   
         print_otag(h, TAG_DIV, 2, tag);          print_otag(h, TAG_DIV, 2, tag);
         return(1);          return(1);
Line 1217  mdoc_sx_pre(MDOC_ARGS)
Line 1275  mdoc_sx_pre(MDOC_ARGS)
         struct htmlpair          tag[2];          struct htmlpair          tag[2];
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
   
         bufcat("#");          bufcat(h, "#");
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 bufcat(nn->string);                  bufcat(h, nn->string);
                 if (nn->next)                  if (nn->next)
                         bufcat(" ");                          bufcat(h, " ");
         }          }
   
         tag[0].key = ATTR_HREF;          tag[0].key = ATTR_HREF;
         tag[0].val = buf;          tag[0].val = h->buf;
         tag[1].key = ATTR_CLASS;          tag[1].key = ATTR_CLASS;
         tag[1].val = "link-sec";          tag[1].val = "link-sec";
   
Line 1265  mdoc_bd_pre(MDOC_ARGS)
Line 1323  mdoc_bd_pre(MDOC_ARGS)
 {  {
         struct htmlpair          tag[2];          struct htmlpair          tag[2];
         int                      t, c, o, i;          int                      t, c, o, i;
         const struct mdoc_node  *bl;          const struct mdoc_node  *bl, *nn;
   
         /* FIXME: fmt_vspace() shit. */  
   
         if (MDOC_BLOCK == n->type)          if (MDOC_BLOCK == n->type)
                 bl = n;                  bl = n;
         else if (MDOC_HEAD == n->type)          else if (MDOC_HEAD == n->type)
Line 1282  mdoc_bd_pre(MDOC_ARGS)
Line 1338  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 1300  mdoc_bd_pre(MDOC_ARGS)
Line 1356  mdoc_bd_pre(MDOC_ARGS)
   
         if (MDOC_BLOCK == n->type) {          if (MDOC_BLOCK == n->type) {
                 if (o)                  if (o)
                         buffmt("margin-left: %dem;", o);                          buffmt(h, "margin-left: %dem;", o);
                 bufcat("margin-top: 1em;");                  if ( ! c) {
                           for (nn = n; nn; nn = nn->parent) {
                                   if (MDOC_BLOCK != nn->type)
                                           continue;
                                   switch (nn->tok) {
                                   case (MDOC_Ss):
                                           /* FALLTHROUGH */
                                   case (MDOC_Sh):
                                           c = 1;
                                           break;
                                   default:
                                           break;
                                   }
                                   if (nn->prev)
                                           break;
                           }
                           if ( ! c)
                                   bufcat(h, "margin-top: 1em;");
                   }
                 tag[0].key = ATTR_STYLE;                  tag[0].key = ATTR_STYLE;
                 tag[0].val = buf;                  tag[0].val = h->buf;
                 print_otag(h, TAG_DIV, 1, tag);                  print_otag(h, TAG_DIV, 1, tag);
                 return(1);                  return(1);
         }          }
   
         switch (t) {          if (MDOC_Unfilled != t && MDOC_Literal != t)
         case (MDOC_Unfilled):  
         case (MDOC_Literal):  
                 break;  
         default:  
                 return(1);                  return(1);
         }  
   
         bufcat("white-space: pre;");          bufcat(h, "white-space: pre;");
         tag[0].key = ATTR_STYLE;          tag[0].key = ATTR_STYLE;
         tag[0].val = buf;          tag[0].val = h->buf;
         tag[1].key = ATTR_CLASS;          tag[1].key = ATTR_CLASS;
         tag[1].val = "lit-block";          tag[1].val = "lit";
   
         print_otag(h, TAG_DIV, 2, tag);          print_otag(h, TAG_DIV, 2, tag);
   
         for (n = n->child; n; n = n->next) {          for (nn = n->child; nn; nn = nn->next) {
                 h->flags |= HTML_NOSPACE;                  print_mdoc_node(m, nn, h);
                 print_mdoc_node(m, n, h);                  if (NULL == nn->next)
                 if (n->next)                          continue;
                   if (nn->prev && nn->prev->line < nn->line)
                         print_text(h, "\n");                          print_text(h, "\n");
         }          }
   
Line 1351  mdoc_pa_pre(MDOC_ARGS)
Line 1421  mdoc_pa_pre(MDOC_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 mdoc_qq_pre(MDOC_ARGS)  
 {  
   
         if (MDOC_BODY != n->type)  
                 return(1);  
         print_text(h, "\\*q");  
         h->flags |= HTML_NOSPACE;  
         return(1);  
 }  
   
   
 /* ARGSUSED */  
 static void  
 mdoc_qq_post(MDOC_ARGS)  
 {  
   
         if (MDOC_BODY != n->type)  
                 return;  
         h->flags |= HTML_NOSPACE;  
         print_text(h, "\\*q");  
 }  
   
   
 /* ARGSUSED */  
 static int  
 mdoc_ad_pre(MDOC_ARGS)  mdoc_ad_pre(MDOC_ARGS)
 {  {
         struct htmlpair tag;          struct htmlpair tag;
Line 1536  mdoc_ft_pre(MDOC_ARGS)
Line 1581  mdoc_ft_pre(MDOC_ARGS)
         if (SEC_SYNOPSIS == n->sec) {          if (SEC_SYNOPSIS == n->sec) {
                 if (n->prev && MDOC_Fo == n->prev->tok) {                  if (n->prev && MDOC_Fo == n->prev->tok) {
                         tag.key = ATTR_STYLE;                          tag.key = ATTR_STYLE;
                         tag.val = "magin-bottom: 1em;";                          tag.val = "margin-top: 1em;";
                         print_otag(h, TAG_DIV, 1, &tag);                          print_otag(h, TAG_DIV, 1, &tag);
                 } else                  } else
                         print_otag(h, TAG_DIV, 0, NULL);                          print_otag(h, TAG_DIV, 0, NULL);
         }          }
   
         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 1554  static int
Line 1599  static int
 mdoc_fn_pre(MDOC_ARGS)  mdoc_fn_pre(MDOC_ARGS)
 {  {
         struct tag              *t;          struct tag              *t;
         struct htmlpair          tag;          struct htmlpair          tag[2];
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
           char                     nbuf[BUFSIZ];
           const char              *sp, *ep;
           int                      sz, i;
   
         if (SEC_SYNOPSIS == n->sec) {          if (SEC_SYNOPSIS == n->sec) {
                 if (n->next) {                  bufcat(h, "margin-left: 6em;");
                         tag.key = ATTR_STYLE;                  bufcat(h, "text-indent: -6em;");
                         tag.val = "margin-bottom: 1em";                  if (n->next)
                         print_otag(h, TAG_DIV, 1, &tag);                          bufcat(h, "margin-bottom: 1em;");
                 } else                  tag[0].key = ATTR_STYLE;
                         print_otag(h, TAG_DIV, 0, NULL);                  tag[0].val = h->buf;
                   print_otag(h, TAG_DIV, 1, tag);
         }          }
   
         tag.key = ATTR_CLASS;          /* Split apart into type and name. */
         tag.val = "type";  
   
         t = print_otag(h, TAG_SPAN, 1, &tag);          tag[0].key = ATTR_CLASS;
         print_text(h, n->child->string);          tag[0].val = "ftype";
           t = print_otag(h, TAG_SPAN, 1, tag);
   
           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);          print_tagq(h, t);
   
           tag[0].key = ATTR_CLASS;
           tag[0].val = "fname";
           t = print_otag(h, TAG_SPAN, 1, tag);
   
           if (sp) {
                   (void)strlcpy(nbuf, sp, BUFSIZ);
                   print_text(h, nbuf);
           }
   
           print_tagq(h, t);
   
         h->flags |= HTML_NOSPACE;          h->flags |= HTML_NOSPACE;
         print_text(h, "(");          print_text(h, "(");
   
         for (nn = n->child->next; nn; nn = nn->next) {          for (nn = n->child->next; nn; nn = nn->next) {
                 tag.key = ATTR_CLASS;                  i = 0;
                 tag.val = "farg";                  tag[i].key = ATTR_CLASS;
                 t = print_otag(h, TAG_SPAN, 1, &tag);                  tag[i++].val = "farg";
                   if (SEC_SYNOPSIS == n->sec) {
                           tag[i].key = ATTR_STYLE;
                           tag[i++].val = "white-space: nowrap;";
                   }
   
                   t = print_otag(h, TAG_SPAN, i, tag);
                 print_text(h, nn->string);                  print_text(h, nn->string);
                 print_tagq(h, t);                  print_tagq(h, t);
                 if (nn->next)                  if (nn->next)
Line 1614  mdoc_sp_pre(MDOC_ARGS)
Line 1691  mdoc_sp_pre(MDOC_ARGS)
                 break;                  break;
         }          }
   
         buffmt("height: %dem", len);          buffmt(h, "height: %dem", len);
         tag.key = ATTR_STYLE;          tag.key = ATTR_STYLE;
         tag.val = buf;          tag.val = h->buf;
         print_otag(h, TAG_DIV, 1, &tag);          print_otag(h, TAG_DIV, 1, &tag);
         return(1);          return(1);
   
Line 1686  mdoc_mt_pre(MDOC_ARGS)
Line 1763  mdoc_mt_pre(MDOC_ARGS)
         tag[0].val = "link-mail";          tag[0].val = "link-mail";
   
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 bufinit();                  bufinit(h);
                 bufcat("mailto:");                  bufcat(h, "mailto:");
                 bufcat(nn->string);                  bufcat(h, nn->string);
   
                 tag[1].key = ATTR_HREF;                  tag[1].key = ATTR_HREF;
                 tag[1].val = buf;                  tag[1].val = h->buf;
   
                 t = print_otag(h, TAG_A, 2, tag);                  t = print_otag(h, TAG_A, 2, tag);
                 print_text(h, nn->string);                  print_text(h, nn->string);
Line 1699  mdoc_mt_pre(MDOC_ARGS)
Line 1776  mdoc_mt_pre(MDOC_ARGS)
         }          }
   
         return(0);          return(0);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_fo_pre(MDOC_ARGS)
   {
           struct htmlpair tag;
   
           if (MDOC_BODY == n->type) {
                   h->flags |= HTML_NOSPACE;
                   print_text(h, "(");
                   h->flags |= HTML_NOSPACE;
                   return(1);
           } else if (MDOC_BLOCK == n->type)
                   return(1);
   
           tag.key = ATTR_CLASS;
           tag.val = "fname";
           print_otag(h, TAG_SPAN, 1, &tag);
           return(1);
   }
   
   
   /* ARGSUSED */
   static void
   mdoc_fo_post(MDOC_ARGS)
   {
           if (MDOC_BODY != n->type)
                   return;
           h->flags |= HTML_NOSPACE;
           print_text(h, ")");
           h->flags |= HTML_NOSPACE;
           print_text(h, ";");
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_in_pre(MDOC_ARGS)
   {
           const struct mdoc_node  *nn;
           struct htmlpair          tag[2];
           struct tag              *t;
           int                      i;
   
           if (SEC_SYNOPSIS == n->sec) {
                   if (n->next && MDOC_In != n->next->tok) {
                           tag[0].key = ATTR_STYLE;
                           tag[0].val = "margin-bottom: 1em;";
                           print_otag(h, TAG_DIV, 1, tag);
                   } else
                           print_otag(h, TAG_DIV, 0, NULL);
           }
   
           tag[0].key = ATTR_CLASS;
           tag[0].val = "includes";
   
           print_otag(h, TAG_SPAN, 1, tag);
   
           if (SEC_SYNOPSIS == n->sec)
                   print_text(h, "#include");
   
           print_text(h, "<");
           h->flags |= HTML_NOSPACE;
   
           /* XXX -- see warning in termp_in_post(). */
   
           for (nn = n->child; nn; nn = nn->next) {
                   assert(MDOC_TEXT == nn->type);
                   i = 0;
                   tag[i].key = ATTR_CLASS;
                   tag[i++].val = "link-includes";
                   if (h->base_includes) {
                           buffmt_includes(h, nn->string);
                           tag[i].key = ATTR_HREF;
                           tag[i++].val = h->buf;
                   }
                   t = print_otag(h, TAG_A, i, tag);
                   print_mdoc_node(m, nn, h);
                   print_tagq(h, t);
           }
   
           h->flags |= HTML_NOSPACE;
           print_text(h, ">");
   
           return(0);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_ic_pre(MDOC_ARGS)
   {
           struct htmlpair tag;
   
           tag.key = ATTR_CLASS;
           tag.val = "cmd";
   
           print_otag(h, TAG_SPAN, 1, &tag);
           return(1);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_rv_pre(MDOC_ARGS)
   {
           const struct mdoc_node  *nn;
           struct htmlpair          tag;
           struct tag              *t;
   
           print_otag(h, TAG_DIV, 0, NULL);
   
           print_text(h, "The");
   
           for (nn = n->child; nn; nn = nn->next) {
                   tag.key = ATTR_CLASS;
                   tag.val = "fname";
                   t = print_otag(h, TAG_SPAN, 1, &tag);
                   print_text(h, nn->string);
                   print_tagq(h, t);
   
                   h->flags |= HTML_NOSPACE;
                   if (nn->next && NULL == nn->next->next)
                           print_text(h, "(), and");
                   else if (nn->next)
                           print_text(h, "(),");
                   else
                           print_text(h, "()");
           }
   
           if (n->child->next)
                   print_text(h, "functions return");
           else
                   print_text(h, "function returns");
   
           print_text(h, "the value 0 if successful; otherwise the value "
                           "-1 is returned and the global variable");
   
           tag.key = ATTR_CLASS;
           tag.val = "var";
           t = print_otag(h, TAG_SPAN, 1, &tag);
           print_text(h, "errno");
           print_tagq(h, t);
           print_text(h, "is set to indicate the error.");
           return(0);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_va_pre(MDOC_ARGS)
   {
           struct htmlpair tag;
   
           tag.key = ATTR_CLASS;
           tag.val = "var";
           print_otag(h, TAG_SPAN, 1, &tag);
           return(1);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_bq_pre(MDOC_ARGS)
   {
   
           if (MDOC_BODY != n->type)
                   return(1);
           print_text(h, "\\(lB");
           h->flags |= HTML_NOSPACE;
           return(1);
   }
   
   
   /* ARGSUSED */
   static void
   mdoc_bq_post(MDOC_ARGS)
   {
   
           if (MDOC_BODY != n->type)
                   return;
           h->flags |= HTML_NOSPACE;
           print_text(h, "\\(rB");
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_ap_pre(MDOC_ARGS)
   {
   
           h->flags |= HTML_NOSPACE;
           print_text(h, "\\(aq");
           h->flags |= HTML_NOSPACE;
           return(1);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_bf_pre(MDOC_ARGS)
   {
           int             i;
           struct htmlpair tag[2];
   
           if (MDOC_HEAD == n->type)
                   return(0);
           else if (MDOC_BLOCK != n->type)
                   return(1);
   
           tag[0].key = ATTR_CLASS;
           tag[0].val = NULL;
   
           if (n->head->child) {
                   if ( ! strcmp("Em", n->head->child->string))
                           tag[0].val = "emph";
                   else if ( ! strcmp("Sy", n->head->child->string))
                           tag[0].val = "symb";
                   else if ( ! strcmp("Li", n->head->child->string))
                           tag[0].val = "lit";
           } else {
                   assert(n->args);
                   for (i = 0; i < (int)n->args->argc; i++)
                           switch (n->args->argv[i].arg) {
                           case (MDOC_Symbolic):
                                   tag[0].val = "symb";
                                   break;
                           case (MDOC_Literal):
                                   tag[0].val = "lit";
                                   break;
                           case (MDOC_Emphasis):
                                   tag[0].val = "emph";
                                   break;
                           default:
                                   break;
                           }
           }
   
           /* FIXME: div's have spaces stripped--we want them. */
   
           assert(tag[0].val);
           tag[1].key = ATTR_STYLE;
           tag[1].val = "display: inline; margin-right: 1em;";
           print_otag(h, TAG_DIV, 2, tag);
           return(1);
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_ms_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_pf_pre(MDOC_ARGS)
   {
   
           h->flags |= HTML_IGNDELIM;
           return(1);
   }
   
   
   /* ARGSUSED */
   static void
   mdoc_pf_post(MDOC_ARGS)
   {
   
           h->flags &= ~HTML_IGNDELIM;
           h->flags |= HTML_NOSPACE;
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_rs_pre(MDOC_ARGS)
   {
           struct htmlpair tag;
   
           if (MDOC_BLOCK != n->type)
                   return(1);
   
           if (n->prev && SEC_SEE_ALSO == n->sec) {
                   tag.key = ATTR_STYLE;
                   tag.val = "margin-top: 1em;";
                   print_otag(h, TAG_DIV, 1, &tag);
           }
   
           tag.key = ATTR_CLASS;
           tag.val = "ref";
           print_otag(h, TAG_SPAN, 1, &tag);
           return(1);
   }
   
   
   
   /* 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);
   }
   
   
   /* 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.2  
changed lines
  Added in v.1.18

CVSweb