[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.133 and 1.146

version 1.133, 2017/02/05 18:15:39 version 1.146, 2018/04/11 17:11:13
Line 26 
Line 26 
 #include <string.h>  #include <string.h>
   
 #include "mandoc_aux.h"  #include "mandoc_aux.h"
   #include "mandoc.h"
 #include "roff.h"  #include "roff.h"
 #include "man.h"  #include "man.h"
 #include "out.h"  #include "out.h"
Line 65  static int    man_SM_pre(MAN_ARGS);
Line 66  static int    man_SM_pre(MAN_ARGS);
 static  int               man_SS_pre(MAN_ARGS);  static  int               man_SS_pre(MAN_ARGS);
 static  int               man_UR_pre(MAN_ARGS);  static  int               man_UR_pre(MAN_ARGS);
 static  int               man_alt_pre(MAN_ARGS);  static  int               man_alt_pre(MAN_ARGS);
 static  int               man_br_pre(MAN_ARGS);  
 static  int               man_ign_pre(MAN_ARGS);  static  int               man_ign_pre(MAN_ARGS);
 static  int               man_in_pre(MAN_ARGS);  static  int               man_in_pre(MAN_ARGS);
 static  void              man_root_post(MAN_ARGS);  static  void              man_root_post(MAN_ARGS);
 static  void              man_root_pre(MAN_ARGS);  static  void              man_root_pre(MAN_ARGS);
   
 static  const struct htmlman mans[MAN_MAX] = {  static  const struct htmlman __mans[MAN_MAX - MAN_TH] = {
         { man_br_pre, NULL }, /* br */  
         { 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 */
Line 93  static const struct htmlman mans[MAN_MAX] = {
Line 92  static const struct htmlman mans[MAN_MAX] = {
         { man_I_pre, NULL }, /* I */          { man_I_pre, NULL }, /* I */
         { man_alt_pre, NULL }, /* IR */          { man_alt_pre, NULL }, /* IR */
         { man_alt_pre, NULL }, /* RI */          { man_alt_pre, NULL }, /* RI */
         { man_br_pre, NULL }, /* sp */  
         { NULL, NULL }, /* nf */          { NULL, NULL }, /* nf */
         { NULL, NULL }, /* fi */          { NULL, NULL }, /* fi */
         { NULL, NULL }, /* RE */          { NULL, NULL }, /* RE */
Line 103  static const struct htmlman mans[MAN_MAX] = {
Line 101  static const struct htmlman mans[MAN_MAX] = {
         { man_ign_pre, NULL }, /* PD */          { man_ign_pre, NULL }, /* PD */
         { man_ign_pre, NULL }, /* AT */          { man_ign_pre, NULL }, /* AT */
         { man_in_pre, NULL }, /* in */          { man_in_pre, NULL }, /* in */
         { man_ign_pre, NULL }, /* ft */  
         { man_OP_pre, NULL }, /* OP */          { man_OP_pre, NULL }, /* OP */
         { NULL, NULL }, /* EX */          { NULL, NULL }, /* EX */
         { NULL, NULL }, /* EE */          { NULL, NULL }, /* EE */
         { man_UR_pre, NULL }, /* UR */          { man_UR_pre, NULL }, /* UR */
         { NULL, NULL }, /* UE */          { NULL, NULL }, /* UE */
         { man_ign_pre, NULL }, /* ll */          { man_UR_pre, NULL }, /* MT */
           { NULL, NULL }, /* ME */
 };  };
   static  const struct htmlman *const mans = __mans - MAN_TH;
   
   
 /*  /*
Line 233  print_man_node(MAN_ARGS)
Line 232  print_man_node(MAN_ARGS)
                 case MAN_P:   /* reopen .nf in the body.        */                  case MAN_P:   /* reopen .nf in the body.        */
                 case MAN_RS:                  case MAN_RS:
                 case MAN_UR:                  case MAN_UR:
                   case MAN_MT:
                         fillmode(h, MAN_fi);                          fillmode(h, MAN_fi);
                         break;                          break;
                 default:                  default:
Line 255  print_man_node(MAN_ARGS)
Line 255  print_man_node(MAN_ARGS)
         case ROFFT_TEXT:          case ROFFT_TEXT:
                 if (fillmode(h, want_fillmode) == MAN_fi &&                  if (fillmode(h, want_fillmode) == MAN_fi &&
                     want_fillmode == MAN_fi &&                      want_fillmode == MAN_fi &&
                     n->flags & NODE_LINE && *n->string == ' ')                      n->flags & NODE_LINE && *n->string == ' ' &&
                       (h->flags & HTML_NONEWLINE) == 0)
                         print_otag(h, TAG_BR, "");                          print_otag(h, TAG_BR, "");
                 if (*n->string != '\0')                  if (*n->string != '\0')
                         break;                          break;
                 print_paragraph(h);                  print_paragraph(h);
                 return;                  return;
           case ROFFT_COMMENT:
                   return;
         default:          default:
                 break;                  break;
         }          }
Line 304  print_man_node(MAN_ARGS)
Line 307  print_man_node(MAN_ARGS)
                         print_tblclose(h);                          print_tblclose(h);
   
                 t = h->tag;                  t = h->tag;
                   if (n->tok < ROFF_MAX) {
                           roff_html_pre(h, n);
                           child = 0;
                           break;
                   }
   
                   assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
                 if (mans[n->tok].pre)                  if (mans[n->tok].pre)
                         child = (*mans[n->tok].pre)(man, n, h);                          child = (*mans[n->tok].pre)(man, n, h);
   
Line 354  fillmode(struct html *h, int want)
Line 364  fillmode(struct html *h, int want)
 static int  static int
 a2width(const struct roff_node *n, struct roffsu *su)  a2width(const struct roff_node *n, struct roffsu *su)
 {  {
   
         if (n->type != ROFFT_TEXT)          if (n->type != ROFFT_TEXT)
                 return 0;                  return 0;
         if (a2roffsu(n->string, su, SCALE_EN))          return a2roffsu(n->string, su, SCALE_EN) != NULL;
                 return 1;  
   
         return 0;  
 }  }
   
 static void  static void
Line 409  man_root_post(MAN_ARGS)
Line 415  man_root_post(MAN_ARGS)
         print_tagq(h, t);          print_tagq(h, t);
 }  }
   
   
 static int  static int
 man_br_pre(MAN_ARGS)  
 {  
         struct roffsu    su;  
   
         SCALE_VS_INIT(&su, 1);  
   
         if (MAN_sp == n->tok) {  
                 if (NULL != (n = n->child))  
                         if ( ! a2roffsu(n->string, &su, SCALE_VS))  
                                 su.scale = 1.0;  
         } else  
                 su.scale = 0.0;  
   
         print_otag(h, TAG_DIV, "suh", &su);  
   
         /* So the div isn't empty: */  
         print_text(h, "\\~");  
   
         return 0;  
 }  
   
 static int  
 man_SH_pre(MAN_ARGS)  man_SH_pre(MAN_ARGS)
 {  {
         if (n->type == ROFFT_HEAD)          char    *id;
                 print_otag(h, TAG_H1, "c", "Sh");  
           if (n->type == ROFFT_HEAD) {
                   id = html_make_id(n);
                   print_otag(h, TAG_H1, "cTi", "Sh", id);
                   if (id != NULL)
                           print_otag(h, TAG_A, "chR", "selflink", id);
                   free(id);
           }
         return 1;          return 1;
 }  }
   
Line 498  man_SM_pre(MAN_ARGS)
Line 488  man_SM_pre(MAN_ARGS)
 static int  static int
 man_SS_pre(MAN_ARGS)  man_SS_pre(MAN_ARGS)
 {  {
         if (n->type == ROFFT_HEAD)          char    *id;
                 print_otag(h, TAG_H2, "c", "Ss");  
           if (n->type == ROFFT_HEAD) {
                   id = html_make_id(n);
                   print_otag(h, TAG_H2, "cTi", "Ss", id);
                   if (id != NULL)
                           print_otag(h, TAG_A, "chR", "selflink", id);
                   free(id);
           }
         return 1;          return 1;
 }  }
   
Line 652  man_RS_pre(MAN_ARGS)
Line 649  man_RS_pre(MAN_ARGS)
 static int  static int
 man_UR_pre(MAN_ARGS)  man_UR_pre(MAN_ARGS)
 {  {
           char *cp;
         n = n->child;          n = n->child;
         assert(n->type == ROFFT_HEAD);          assert(n->type == ROFFT_HEAD);
         if (n->child != NULL) {          if (n->child != NULL) {
                 assert(n->child->type == ROFFT_TEXT);                  assert(n->child->type == ROFFT_TEXT);
                 print_otag(h, TAG_A, "ch", "Lk", n->child->string);                  if (n->tok == MAN_MT) {
                           mandoc_asprintf(&cp, "mailto:%s", n->child->string);
                           print_otag(h, TAG_A, "cTh", "Mt", cp);
                           free(cp);
                   } else
                           print_otag(h, TAG_A, "cTh", "Lk", n->child->string);
         }          }
   
         assert(n->next->type == ROFFT_BODY);          assert(n->next->type == ROFFT_BODY);

Legend:
Removed from v.1.133  
changed lines
  Added in v.1.146

CVSweb