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

Diff for /mandoc/man_html.c between version 1.5 and 1.6

version 1.5, 2009/10/04 10:24:31 version 1.6, 2009/10/04 15:24:54
Line 27 
Line 27 
 #include "html.h"  #include "html.h"
 #include "man.h"  #include "man.h"
   
 #define INDENT            7  /* TODO: preserve ident widths. */
   
   #define INDENT            5
 #define HALFINDENT        3  #define HALFINDENT        3
   
 #define MAN_ARGS          const struct man_meta *m, \  #define MAN_ARGS          const struct man_meta *m, \
Line 47  static void    print_man_node(MAN_ARGS);
Line 49  static void    print_man_node(MAN_ARGS);
 static  int               a2width(const struct man_node *);  static  int               a2width(const struct man_node *);
   
 static  int               man_br_pre(MAN_ARGS);  static  int               man_br_pre(MAN_ARGS);
   static  int               man_HP_pre(MAN_ARGS);
 static  int               man_IP_pre(MAN_ARGS);  static  int               man_IP_pre(MAN_ARGS);
 static  int               man_PP_pre(MAN_ARGS);  static  int               man_PP_pre(MAN_ARGS);
 static  void              man_root_post(MAN_ARGS);  static  void              man_root_post(MAN_ARGS);
Line 64  static const struct htmlman mans[MAN_MAX] = {
Line 67  static const struct htmlman mans[MAN_MAX] = {
         { NULL, NULL }, /* TH */          { NULL, NULL }, /* TH */
         { man_SH_pre, NULL }, /* SH */          { man_SH_pre, NULL }, /* SH */
         { man_SS_pre, NULL }, /* SS */          { man_SS_pre, NULL }, /* SS */
         { NULL, NULL }, /* TP */          { man_IP_pre, NULL }, /* TP */
         { man_PP_pre, NULL }, /* LP */          { man_PP_pre, NULL }, /* LP */
         { man_PP_pre, NULL }, /* PP */          { man_PP_pre, NULL }, /* PP */
         { man_PP_pre, NULL }, /* P */          { man_PP_pre, NULL }, /* P */
         { man_IP_pre, NULL }, /* IP */          { man_IP_pre, NULL }, /* IP */
         { NULL, NULL }, /* HP */          { man_HP_pre, NULL }, /* HP */
         { NULL, NULL }, /* SM */          { NULL, NULL }, /* SM */
         { NULL, NULL }, /* SB */          { NULL, NULL }, /* SB */
         { NULL, NULL }, /* BI */          { NULL, NULL }, /* BI */
Line 209  a2width(const struct man_node *n)
Line 212  a2width(const struct man_node *n)
         int              i, len;          int              i, len;
         const char      *p;          const char      *p;
   
         assert(MAN_TEXT == n->type);          if (MAN_TEXT != n->type)
         assert(n->string);                  return(-1);
   
         p = n->string;          p = n->string;
   
Line 468  man_IP_pre(MAN_ARGS)
Line 471  man_IP_pre(MAN_ARGS)
         int                      len, ival;          int                      len, ival;
         const struct man_node   *nn;          const struct man_node   *nn;
   
         len = 1;          if (MAN_BODY == n->type) {
         if (NULL != (nn = n->parent->head->child))                  print_otag(h, TAG_DIV, 0, NULL);
                   return(1);
           }
   
           nn = MAN_BLOCK == n->type ?
                   n->head->child : n->parent->head->child;
           len = INDENT;
           ival = -1;
   
           /* Calculate the indentation length. */
   
           if (NULL != nn)
                 if (NULL != (nn = nn->next)) {                  if (NULL != (nn = nn->next)) {
                         for ( ; nn->next; nn = nn->next)                          for ( ; nn->next; nn = nn->next)
                                 /* Do nothing. */ ;                                  /* Do nothing. */ ;
Line 483  man_IP_pre(MAN_ARGS)
Line 497  man_IP_pre(MAN_ARGS)
                 tag.val = h->buf;                  tag.val = h->buf;
                 print_otag(h, TAG_DIV, 1, &tag);                  print_otag(h, TAG_DIV, 1, &tag);
                 return(1);                  return(1);
         } else if (MAN_HEAD == n->type) {          }
                 buffmt(h, "margin-left: -%dem; min-width: %dem;",  
                                 len, len - 1);          /* If there's an indent string, print it out. */
                 bufcat(h, "clear: left;");  
                 bufcat(h, "padding-right: 1em;");          buffmt(h, "margin-left: -%dem; min-width: %dem;",
                 if (n->next && n->next->child)                          len, len - 1);
                         bufcat(h, "float: left;");          bufcat(h, "clear: left; padding-right: 1em;");
   
           if (n->next && n->next->child)
                   bufcat(h, "float: left;");
   
           tag.key = ATTR_STYLE;
           tag.val = h->buf;
           print_otag(h, TAG_DIV, 1, &tag);
   
           if (ival < 0)
                   return(1);
   
           /* With a length string, omit the last child. */
   
           for (nn = n->child; nn->next; nn = nn->next)
                   print_man_node(m, nn, h);
   
           return(0);
   }
   
   
   /* ARGSUSED */
   static int
   man_HP_pre(MAN_ARGS)
   {
           int                      ival, len;
           const struct man_node   *nn;
           struct htmlpair          tag;
   
           if (MAN_HEAD == n->type)
                   return(0);
   
           nn = MAN_BLOCK == n->type ?
                   n->head->child : n->parent->head->child;
   
           len = INDENT;
   
           if (NULL != nn)
                   if ((ival = a2width(nn)) >= 0)
                           len = ival;
   
           if (MAN_BLOCK == n->type) {
                   buffmt(h, "clear: both; margin-left: %dem;", len);
                 tag.key = ATTR_STYLE;                  tag.key = ATTR_STYLE;
                 tag.val = h->buf;                  tag.val = h->buf;
                 print_otag(h, TAG_DIV, 1, &tag);                  print_otag(h, TAG_DIV, 1, &tag);
                   return(1);
           }
   
                 /* Don't print the length value. */          buffmt(h, "text-indent: -%dem;", len);
   
                 for (nn = n->child; nn->next; nn = nn->next)          tag.key = ATTR_STYLE;
                         print_man_node(m, nn, h);          tag.val = h->buf;
                 return(0);          print_otag(h, TAG_DIV, 1, &tag);
         }  
   
         print_otag(h, TAG_DIV, 0, &tag);  
         return(1);          return(1);
 }  }
   

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

CVSweb