[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.65 and 1.66

version 1.65, 2010/05/17 22:11:42 version 1.66, 2010/05/17 23:57:06
Line 57  static void    print_mdoc_nodelist(MDOC_ARGS);
Line 57  static void    print_mdoc_nodelist(MDOC_ARGS);
 static  void              a2width(const char *, struct roffsu *);  static  void              a2width(const char *, struct roffsu *);
 static  void              a2offs(const char *, struct roffsu *);  static  void              a2offs(const char *, struct roffsu *);
   
 static  int               a2list(const struct mdoc_node *);  
   
 static  void              mdoc_root_post(MDOC_ARGS);  static  void              mdoc_root_post(MDOC_ARGS);
 static  int               mdoc_root_pre(MDOC_ARGS);  static  int               mdoc_root_pre(MDOC_ARGS);
   
Line 98  static void    mdoc_fo_post(MDOC_ARGS);
Line 96  static void    mdoc_fo_post(MDOC_ARGS);
 static  int               mdoc_fo_pre(MDOC_ARGS);  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_block_pre(MDOC_ARGS, int, int,  static  int               mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list,
                                 struct roffsu *, struct roffsu *);                                  int, struct roffsu *, struct roffsu *);
 static  int               mdoc_it_head_pre(MDOC_ARGS, int,  static  int               mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list,
                                 struct roffsu *);                                  struct roffsu *);
 static  int               mdoc_it_body_pre(MDOC_ARGS, int);  static  int               mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list);
 static  int               mdoc_it_pre(MDOC_ARGS);  static  int               mdoc_it_pre(MDOC_ARGS);
 static  int               mdoc_lb_pre(MDOC_ARGS);  static  int               mdoc_lb_pre(MDOC_ARGS);
 static  int               mdoc_li_pre(MDOC_ARGS);  static  int               mdoc_li_pre(MDOC_ARGS);
Line 277  html_mdoc(void *arg, const struct mdoc *m)
Line 275  html_mdoc(void *arg, const struct mdoc *m)
   
   
 /*  /*
  * Return the list type for `Bl', e.g., `Bl -column' returns  
  * MDOC_Column.  This can ONLY be run for lists; it will abort() if no  
  * list type is found.  
  */  
 static int  
 a2list(const struct mdoc_node *n)  
 {  
         int              i;  
   
         assert(n->args);  
         for (i = 0; i < (int)n->args->argc; i++)  
                 switch (n->args->argv[i].arg) {  
                 case (MDOC_Enum):  
                         /* FALLTHROUGH */  
                 case (MDOC_Dash):  
                         /* FALLTHROUGH */  
                 case (MDOC_Hyphen):  
                         /* FALLTHROUGH */  
                 case (MDOC_Bullet):  
                         /* FALLTHROUGH */  
                 case (MDOC_Tag):  
                         /* FALLTHROUGH */  
                 case (MDOC_Hang):  
                         /* FALLTHROUGH */  
                 case (MDOC_Inset):  
                         /* FALLTHROUGH */  
                 case (MDOC_Diag):  
                         /* FALLTHROUGH */  
                 case (MDOC_Item):  
                         /* FALLTHROUGH */  
                 case (MDOC_Column):  
                         /* FALLTHROUGH */  
                 case (MDOC_Ohang):  
                         return(n->args->argv[i].arg);  
                 default:  
                         break;  
                 }  
   
         abort();  
         /* NOTREACHED */  
 }  
   
   
 /*  
  * Calculate the scaling unit passed in a `-width' argument.  This uses   * Calculate the scaling unit passed in a `-width' argument.  This uses
  * either a native scaling unit (e.g., 1i, 2m) or the string length of   * either a native scaling unit (e.g., 1i, 2m) or the string length of
  * the value.   * the value.
Line 868  mdoc_bx_pre(MDOC_ARGS)
Line 822  mdoc_bx_pre(MDOC_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 mdoc_it_block_pre(MDOC_ARGS, int type, int comp,  mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list type, int comp,
                 struct roffsu *offs, struct roffsu *width)                  struct roffsu *offs, struct roffsu *width)
 {  {
         struct htmlpair          tag;          struct htmlpair          tag;
Line 880  mdoc_it_block_pre(MDOC_ARGS, int type, int comp,
Line 834  mdoc_it_block_pre(MDOC_ARGS, int type, int comp,
   
         /* XXX: see notes in mdoc_it_pre(). */          /* XXX: see notes in mdoc_it_pre(). */
   
         if (MDOC_Column == type) {          if (LIST_column == type) {
                 /* Don't width-pad on the left. */                  /* Don't width-pad on the left. */
                 SCALE_HS_INIT(width, 0);                  SCALE_HS_INIT(width, 0);
                 /* Also disallow non-compact. */                  /* Also disallow non-compact. */
                 comp = 1;                  comp = 1;
         }          }
         if (MDOC_Diag == type)          if (LIST_diag == type)
                 /* Mandate non-compact with empty prior. */                  /* Mandate non-compact with empty prior. */
                 if (n->prev && NULL == n->prev->body->child)                  if (n->prev && NULL == n->prev->body->child)
                         comp = 1;                          comp = 1;
Line 923  mdoc_it_block_pre(MDOC_ARGS, int type, int comp,
Line 877  mdoc_it_block_pre(MDOC_ARGS, int type, int comp,
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 mdoc_it_body_pre(MDOC_ARGS, int type)  mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list type)
 {  {
         struct htmlpair  tag;          struct htmlpair  tag;
         struct roffsu    su;          struct roffsu    su;
   
         switch (type) {          switch (type) {
         case (MDOC_Item):          case (LIST_item):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Ohang):          case (LIST_ohang):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Column):          case (LIST_column):
                 break;                  break;
         default:          default:
                 /*                  /*
Line 953  mdoc_it_body_pre(MDOC_ARGS, int type)
Line 907  mdoc_it_body_pre(MDOC_ARGS, int type)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *width)  mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width)
 {  {
         struct htmlpair  tag;          struct htmlpair  tag;
         struct ord      *ord;          struct ord      *ord;
         char             nbuf[BUFSIZ];          char             nbuf[BUFSIZ];
   
         switch (type) {          switch (type) {
         case (MDOC_Item):          case (LIST_item):
                 return(0);                  return(0);
         case (MDOC_Ohang):          case (LIST_ohang):
                 print_otag(h, TAG_DIV, 0, &tag);                  print_otag(h, TAG_DIV, 0, &tag);
                 return(1);                  return(1);
         case (MDOC_Column):          case (LIST_column):
                 bufcat_su(h, "min-width", width);                  bufcat_su(h, "min-width", width);
                 bufcat_style(h, "clear", "none");                  bufcat_style(h, "clear", "none");
                 if (n->next && MDOC_HEAD == n->next->type)                  if (n->next && MDOC_HEAD == n->next->type)
Line 989  mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w
Line 943  mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w
         }          }
   
         switch (type) {          switch (type) {
         case (MDOC_Diag):          case (LIST_diag):
                 PAIR_CLASS_INIT(&tag, "diag");                  PAIR_CLASS_INIT(&tag, "diag");
                 print_otag(h, TAG_SPAN, 1, &tag);                  print_otag(h, TAG_SPAN, 1, &tag);
                 break;                  break;
         case (MDOC_Enum):          case (LIST_enum):
                 ord = h->ords.head;                  ord = h->ords.head;
                 assert(ord);                  assert(ord);
                 nbuf[BUFSIZ - 1] = 0;                  nbuf[BUFSIZ - 1] = 0;
                 (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);                  (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);
                 print_text(h, nbuf);                  print_text(h, nbuf);
                 return(0);                  return(0);
         case (MDOC_Dash):          case (LIST_dash):
                 print_text(h, "\\(en");                  print_text(h, "\\(en");
                 return(0);                  return(0);
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 print_text(h, "\\(hy");                  print_text(h, "\\(hy");
                 return(0);                  return(0);
         case (MDOC_Bullet):          case (LIST_bullet):
                 print_text(h, "\\(bu");                  print_text(h, "\\(bu");
                 return(0);                  return(0);
         default:          default:
Line 1020  mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w
Line 974  mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *w
 static int  static int
 mdoc_it_pre(MDOC_ARGS)  mdoc_it_pre(MDOC_ARGS)
 {  {
         int                      i, type, wp, comp;          int                      i, wp, comp;
         const struct mdoc_node  *bl, *nn;          const struct mdoc_node  *bl, *nn;
         struct roffsu            width, offs;          struct roffsu            width, offs;
           enum mdoc_list           type;
   
         /*          /*
          * XXX: be very careful in changing anything, here.  Lists in           * XXX: be very careful in changing anything, here.  Lists in
Line 1034  mdoc_it_pre(MDOC_ARGS)
Line 989  mdoc_it_pre(MDOC_ARGS)
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 bl = bl->parent;                  bl = bl->parent;
   
         type = a2list(bl);          type = bl->data.list;
   
         /* Set default width and offset. */          /* Set default width and offset. */
   
         SCALE_HS_INIT(&offs, 0);          SCALE_HS_INIT(&offs, 0);
   
         switch (type) {          switch (type) {
         case (MDOC_Enum):          case (LIST_enum):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Dash):          case (LIST_dash):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Hyphen):          case (LIST_hyphen):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Bullet):          case (LIST_bullet):
                 SCALE_HS_INIT(&width, 2);                  SCALE_HS_INIT(&width, 2);
                 break;                  break;
         default:          default:
Line 1078  mdoc_it_pre(MDOC_ARGS)
Line 1033  mdoc_it_pre(MDOC_ARGS)
         /* Override width in some cases. */          /* Override width in some cases. */
   
         switch (type) {          switch (type) {
         case (MDOC_Ohang):          case (LIST_ohang):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Item):          case (LIST_item):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Inset):          case (LIST_inset):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Diag):          case (LIST_diag):
                 SCALE_HS_INIT(&width, 0);                  SCALE_HS_INIT(&width, 0);
                 break;                  break;
         default:          default:
Line 1103  mdoc_it_pre(MDOC_ARGS)
Line 1058  mdoc_it_pre(MDOC_ARGS)
   
         /* Override column widths. */          /* Override column widths. */
   
         if (MDOC_Column == type) {          if (LIST_column == type) {
                 nn = n->parent->child;                  nn = n->parent->child;
                 for (i = 0; nn && nn != n; nn = nn->next, i++)                  for (i = 0; nn && nn != n; nn = nn->next, i++)
                         /* Counter... */ ;                          /* Counter... */ ;
Line 1125  mdoc_bl_pre(MDOC_ARGS)
Line 1080  mdoc_bl_pre(MDOC_ARGS)
                 return(0);                  return(0);
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return(1);                  return(1);
         if (MDOC_Enum != a2list(n))          if (MDOC_Enum != n->data.list)
                 return(1);                  return(1);
   
         ord = malloc(sizeof(struct ord));          ord = malloc(sizeof(struct ord));
Line 1149  mdoc_bl_post(MDOC_ARGS)
Line 1104  mdoc_bl_post(MDOC_ARGS)
   
         if (MDOC_BLOCK != n->type)          if (MDOC_BLOCK != n->type)
                 return;                  return;
         if (MDOC_Enum != a2list(n))          if (MDOC_Enum != n->data.list)
                 return;                  return;
   
         ord = h->ords.head;          ord = h->ords.head;

Legend:
Removed from v.1.65  
changed lines
  Added in v.1.66

CVSweb