[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.93 and 1.106

version 1.93, 2010/07/04 21:59:30 version 1.106, 2010/09/25 16:41:33
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010 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 73  static int    mdoc_aq_pre(MDOC_ARGS);
Line 72  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  int               mdoc_bf_pre(MDOC_ARGS);
   static  void              mdoc_bk_post(MDOC_ARGS);
   static  int               mdoc_bk_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  void              mdoc_bq_post(MDOC_ARGS);
Line 124  static int    mdoc_pq_pre(MDOC_ARGS);
Line 125  static int    mdoc_pq_pre(MDOC_ARGS);
 static  int               mdoc_rs_pre(MDOC_ARGS);  static  int               mdoc_rs_pre(MDOC_ARGS);
 static  int               mdoc_rv_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_sm_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);
Line 208  static const struct htmlmdoc mdocs[MDOC_MAX] = {
Line 210  static const struct htmlmdoc mdocs[MDOC_MAX] = {
         {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 */
         {mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */          {mdoc_ms_pre, NULL}, /* Ms */
         {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 */
Line 226  static const struct htmlmdoc mdocs[MDOC_MAX] = {
Line 228  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 */ /* FIXME - no idea. */          {mdoc_sm_pre, NULL}, /* Sm */
         {mdoc_sx_pre, NULL}, /* Sx */          {mdoc_sx_pre, NULL}, /* Sx */
         {mdoc_sy_pre, NULL}, /* Sy */          {mdoc_sy_pre, NULL}, /* Sy */
         {NULL, NULL}, /* Tn */          {NULL, NULL}, /* Tn */
Line 237  static const struct htmlmdoc mdocs[MDOC_MAX] = {
Line 239  static const struct htmlmdoc mdocs[MDOC_MAX] = {
         {NULL, NULL}, /* Fc */          {NULL, NULL}, /* Fc */
         {mdoc_op_pre, mdoc_op_post}, /* Oo */          {mdoc_op_pre, mdoc_op_post}, /* Oo */
         {NULL, NULL}, /* Oc */          {NULL, NULL}, /* Oc */
         {NULL, NULL}, /* Bk */          {mdoc_bk_pre, mdoc_bk_post}, /* Bk */
         {NULL, NULL}, /* Ek */          {NULL, NULL}, /* Ek */
         {mdoc_bt_pre, NULL}, /* Bt */          {mdoc_bt_pre, NULL}, /* Bt */
         {NULL, NULL}, /* Hf */          {NULL, NULL}, /* Hf */
Line 442  print_mdoc_node(MDOC_ARGS)
Line 444  print_mdoc_node(MDOC_ARGS)
                 break;                  break;
         }          }
   
           if (HTML_KEEP & h->flags) {
                   if (n->prev && n->prev->line != n->line) {
                           h->flags &= ~HTML_KEEP;
                           h->flags |= HTML_PREKEEP;
                   } else if (NULL == n->prev) {
                           if (n->parent && n->parent->line != n->line) {
                                   h->flags &= ~HTML_KEEP;
                                   h->flags |= HTML_PREKEEP;
                           }
                   }
           }
   
         if (child && n->child)          if (child && n->child)
                 print_mdoc_nodelist(m, n->child, h);                  print_mdoc_nodelist(m, n->child, h);
   
Line 1169  mdoc_bl_pre(MDOC_ARGS)
Line 1183  mdoc_bl_pre(MDOC_ARGS)
         ord = malloc(sizeof(struct ord));          ord = malloc(sizeof(struct ord));
         if (NULL == ord) {          if (NULL == ord) {
                 perror(NULL);                  perror(NULL);
                 exit(EXIT_FAILURE);                  exit((int)MANDOCLEVEL_SYSERR);
         }          }
         ord->cookie = n;          ord->cookie = n;
         ord->pos = 1;          ord->pos = 1;
Line 1443  mdoc_bd_pre(MDOC_ARGS)
Line 1457  mdoc_bd_pre(MDOC_ARGS)
         print_otag(h, TAG_DIV, 2, tag);          print_otag(h, TAG_DIV, 2, tag);
   
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 h->flags |= HTML_NOSPACE;  
                 print_mdoc_node(m, nn, h);                  print_mdoc_node(m, nn, h);
                 if (NULL == nn->next)                  if (nn->next && nn->next->line == nn->line)
                         continue;                          continue;
                 if (nn->prev && nn->prev->line < nn->line)                  print_text(h, "\n");
                         print_text(h, "\n");                  h->flags |= HTML_NOSPACE;
                 else if (NULL == nn->prev)  
                         print_text(h, "\n");  
         }          }
   
         return(0);          return(0);
Line 1709  mdoc_fn_pre(MDOC_ARGS)
Line 1720  mdoc_fn_pre(MDOC_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
   mdoc_sm_pre(MDOC_ARGS)
   {
   
           assert(n->child && MDOC_TEXT == n->child->type);
           if (0 == strcmp("on", n->child->string)) {
                   /* FIXME: no p->col to check... */
                   h->flags &= ~HTML_NOSPACE;
                   h->flags &= ~HTML_NONOSPACE;
           } else
                   h->flags |= HTML_NONOSPACE;
   
           return(0);
   }
   
   
   /* ARGSUSED */
   static int
 mdoc_sp_pre(MDOC_ARGS)  mdoc_sp_pre(MDOC_ARGS)
 {  {
         int              len;          int              len;
Line 1724  mdoc_sp_pre(MDOC_ARGS)
Line 1752  mdoc_sp_pre(MDOC_ARGS)
                 len = 0;                  len = 0;
                 break;                  break;
         default:          default:
                   assert(n->parent);
                   if ((NULL == n->next || NULL == n->prev) &&
                                   (MDOC_Ss == n->parent->tok ||
                                    MDOC_Sh == n->parent->tok))
                           return(0);
                 len = 1;                  len = 1;
                 break;                  break;
         }          }
Line 2075  static int
Line 2108  static int
 mdoc_rs_pre(MDOC_ARGS)  mdoc_rs_pre(MDOC_ARGS)
 {  {
         struct htmlpair  tag;          struct htmlpair  tag;
         struct roffsu    su;  
   
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
   
         if (n->prev && SEC_SEE_ALSO == n->sec) {          if (n->prev && SEC_SEE_ALSO == n->sec) {
                 SCALE_VS_INIT(&su, 1);                  print_otag(h, TAG_BR, 0, NULL);
                 bufcat_su(h, "margin-top", &su);                  print_otag(h, TAG_BR, 0, NULL);
                 PAIR_STYLE_INIT(&tag, h);          }
                 print_otag(h, TAG_DIV, 1, &tag);  
         }  
   
         PAIR_CLASS_INIT(&tag, "ref");          PAIR_CLASS_INIT(&tag, "ref");
         print_otag(h, TAG_SPAN, 1, &tag);          print_otag(h, TAG_SPAN, 1, &tag);
Line 2161  mdoc__x_pre(MDOC_ARGS)
Line 2191  mdoc__x_pre(MDOC_ARGS)
         switch (n->tok) {          switch (n->tok) {
         case(MDOC__A):          case(MDOC__A):
                 PAIR_CLASS_INIT(&tag[0], "ref-auth");                  PAIR_CLASS_INIT(&tag[0], "ref-auth");
                   if (n->prev && MDOC__A == n->prev->tok)
                           if (NULL == n->next || MDOC__A != n->next->tok)
                                   print_text(h, "and");
                 break;                  break;
         case(MDOC__B):          case(MDOC__B):
                 PAIR_CLASS_INIT(&tag[0], "ref-book");                  PAIR_CLASS_INIT(&tag[0], "ref-book");
Line 2213  mdoc__x_pre(MDOC_ARGS)
Line 2246  mdoc__x_pre(MDOC_ARGS)
   
         PAIR_HREF_INIT(&tag[1], n->child->string);          PAIR_HREF_INIT(&tag[1], n->child->string);
         print_otag(h, TAG_A, 2, tag);          print_otag(h, TAG_A, 2, tag);
   
         return(1);          return(1);
 }  }
   
Line 2222  static void
Line 2256  static void
 mdoc__x_post(MDOC_ARGS)  mdoc__x_post(MDOC_ARGS)
 {  {
   
           if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
                   if (NULL == n->next->next || MDOC__A != n->next->next->tok)
                           if (NULL == n->prev || MDOC__A != n->prev->tok)
                                   return;
   
         /* TODO: %U */          /* TODO: %U */
   
         h->flags |= HTML_NOSPACE;          if (NULL == n->parent || MDOC_Rs != n->parent->tok)
                   return;
   
         print_text(h, n->next ? "," : ".");          print_text(h, n->next ? "," : ".");
   }
   
   
   /* ARGSUSED */
   static int
   mdoc_bk_pre(MDOC_ARGS)
   {
   
           switch (n->type) {
           case (MDOC_BLOCK):
                   break;
           case (MDOC_HEAD):
                   return(0);
           case (MDOC_BODY):
                   h->flags |= HTML_PREKEEP;
                   break;
           default:
                   abort();
                   /* NOTREACHED */
           }
   
           return(1);
   }
   
   
   /* ARGSUSED */
   static void
   mdoc_bk_post(MDOC_ARGS)
   {
   
           if (MDOC_BODY == n->type)
                   h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
 }  }

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.106

CVSweb