[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.274 and 1.279

version 1.274, 2017/03/13 19:01:38 version 1.279, 2017/04/17 12:53:29
Line 48  struct htmlmdoc {
Line 48  struct htmlmdoc {
         void            (*post)(MDOC_ARGS);          void            (*post)(MDOC_ARGS);
 };  };
   
 static  char             *make_id(const struct roff_node *);  static  char             *cond_id(const struct roff_node *);
 static  void              print_mdoc_head(MDOC_ARGS);  static  void              print_mdoc_head(MDOC_ARGS);
 static  void              print_mdoc_node(MDOC_ARGS);  static  void              print_mdoc_node(MDOC_ARGS);
 static  void              print_mdoc_nodelist(MDOC_ARGS);  static  void              print_mdoc_nodelist(MDOC_ARGS);
Line 477  mdoc_root_pre(MDOC_ARGS)
Line 477  mdoc_root_pre(MDOC_ARGS)
 }  }
   
 static char *  static char *
 make_id(const struct roff_node *n)  cond_id(const struct roff_node *n)
 {  {
         const struct roff_node  *nch;          if (n->child != NULL &&
         char                    *buf, *cp;              n->child->type == ROFFT_TEXT &&
               (n->prev == NULL ||
         for (nch = n->child; nch != NULL; nch = nch->next)               (n->prev->type == ROFFT_TEXT &&
                 if (nch->type != ROFFT_TEXT)                strcmp(n->prev->string, "|") == 0)) &&
                         return NULL;              (n->parent->tok == MDOC_It ||
                (n->parent->tok == MDOC_Xo &&
         buf = NULL;                n->parent->parent->prev == NULL &&
         deroff(&buf, n);                n->parent->parent->parent->tok == MDOC_It)))
                   return html_make_id(n);
         /* http://www.w3.org/TR/html5/dom.html#the-id-attribute */          return NULL;
   
         for (cp = buf; *cp != '\0'; cp++)  
                 if (*cp == ' ')  
                         *cp = '_';  
   
         return buf;  
 }  }
   
 static int  static int
Line 505  mdoc_sh_pre(MDOC_ARGS)
Line 499  mdoc_sh_pre(MDOC_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case ROFFT_HEAD:          case ROFFT_HEAD:
                 id = make_id(n);                  id = html_make_id(n);
                 print_otag(h, TAG_H1, "cTi", "Sh", id);                  print_otag(h, TAG_H1, "cTi", "Sh", id);
                   if (id != NULL)
                           print_otag(h, TAG_A, "chR", "selflink", id);
                 free(id);                  free(id);
                 break;                  break;
         case ROFFT_BODY:          case ROFFT_BODY:
Line 527  mdoc_ss_pre(MDOC_ARGS)
Line 523  mdoc_ss_pre(MDOC_ARGS)
         if (n->type != ROFFT_HEAD)          if (n->type != ROFFT_HEAD)
                 return 1;                  return 1;
   
         id = make_id(n);          id = html_make_id(n);
         print_otag(h, TAG_H2, "cTi", "Ss", id);          print_otag(h, TAG_H2, "cTi", "Ss", id);
           if (id != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
         free(id);          free(id);
         return 1;          return 1;
 }  }
Line 536  mdoc_ss_pre(MDOC_ARGS)
Line 534  mdoc_ss_pre(MDOC_ARGS)
 static int  static int
 mdoc_fl_pre(MDOC_ARGS)  mdoc_fl_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_B, "cT", "Fl");          char    *id;
         print_text(h, "\\-");  
   
           if ((id = cond_id(n)) != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_B, "cTi", "Fl", id);
           free(id);
   
           print_text(h, "\\-");
         if (!(n->child == NULL &&          if (!(n->child == NULL &&
             (n->next == NULL ||              (n->next == NULL ||
              n->next->type == ROFFT_TEXT ||               n->next->type == ROFFT_TEXT ||
Line 551  mdoc_fl_pre(MDOC_ARGS)
Line 554  mdoc_fl_pre(MDOC_ARGS)
 static int  static int
 mdoc_cm_pre(MDOC_ARGS)  mdoc_cm_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_B, "cT", "Cm");          char    *id;
   
           if ((id = cond_id(n)) != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_B, "cTi", "Cm", id);
           free(id);
         return 1;          return 1;
 }  }
   
Line 599  mdoc_nm_pre(MDOC_ARGS)
Line 607  mdoc_nm_pre(MDOC_ARGS)
                 len = html_strlen(meta->name);                  len = html_strlen(meta->name);
   
         t = print_otag(h, TAG_COLGROUP, "");          t = print_otag(h, TAG_COLGROUP, "");
         print_otag(h, TAG_COL, "shw", len);          /* Increase width to make even bold text fit. */
           print_otag(h, TAG_COL, "shw", len + 2);
         print_otag(h, TAG_COL, "");          print_otag(h, TAG_COL, "");
         print_tagq(h, t);          print_tagq(h, t);
         print_otag(h, TAG_TR, "");          print_otag(h, TAG_TR, "");
Line 925  mdoc_sx_pre(MDOC_ARGS)
Line 934  mdoc_sx_pre(MDOC_ARGS)
 {  {
         char    *id;          char    *id;
   
         id = make_id(n);          id = html_make_id(n);
         print_otag(h, TAG_A, "cThR", "Sx", id);          print_otag(h, TAG_A, "cThR", "Sx", id);
         free(id);          free(id);
         return 1;          return 1;
Line 1068  mdoc_cd_pre(MDOC_ARGS)
Line 1077  mdoc_cd_pre(MDOC_ARGS)
 static int  static int
 mdoc_dv_pre(MDOC_ARGS)  mdoc_dv_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_CODE, "cT", "Dv");          char    *id;
   
           if ((id = cond_id(n)) != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_CODE, "cTi", "Dv", id);
           free(id);
         return 1;          return 1;
 }  }
   
 static int  static int
 mdoc_ev_pre(MDOC_ARGS)  mdoc_ev_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_CODE, "cT", "Ev");          char    *id;
   
           if ((id = cond_id(n)) != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_CODE, "cTi", "Ev", id);
           free(id);
         return 1;          return 1;
 }  }
   
 static int  static int
 mdoc_er_pre(MDOC_ARGS)  mdoc_er_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_CODE, "cT", "Er");          char    *id;
   
           id = n->sec == SEC_ERRORS &&
               (n->parent->tok == MDOC_It ||
                (n->parent->tok == MDOC_Bq &&
                 n->parent->parent->parent->tok == MDOC_It)) ?
               html_make_id(n) : NULL;
   
           if (id != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_CODE, "cTi", "Er", id);
           free(id);
         return 1;          return 1;
 }  }
   
Line 1316  mdoc_sp_pre(MDOC_ARGS)
Line 1346  mdoc_sp_pre(MDOC_ARGS)
 static int  static int
 mdoc_lk_pre(MDOC_ARGS)  mdoc_lk_pre(MDOC_ARGS)
 {  {
         if (NULL == (n = n->child))          struct tag      *t;
   
           if ((n = n->child) == NULL)
                 return 0;                  return 0;
   
         assert(n->type == ROFFT_TEXT);          /* Link target and link text. */
           t = print_otag(h, TAG_A, "cTh", "Lk", n->string);
         print_otag(h, TAG_A, "cTh", "Lk", n->string);          if (n->next == NULL || n->next->flags & NODE_DELIMC)
   
         if (NULL == n->next)  
                 print_text(h, n->string);                  print_text(h, n->string);
           for (n = n->next; n != NULL && !(n->flags & NODE_DELIMC); n = n->next)
         for (n = n->next; n; n = n->next)  
                 print_text(h, n->string);                  print_text(h, n->string);
           print_tagq(h, t);
   
           /* Trailing punctuation. */
           while (n != NULL) {
                   h->flags |= HTML_NOSPACE;
                   print_text(h, n->string);
                   n = n->next;
           }
         return 0;          return 0;
 }  }
   
Line 1436  mdoc_in_pre(MDOC_ARGS)
Line 1472  mdoc_in_pre(MDOC_ARGS)
 static int  static int
 mdoc_ic_pre(MDOC_ARGS)  mdoc_ic_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_B, "cT", "Ic");          char    *id;
   
           if ((id = cond_id(n)) != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_B, "cTi", "Ic", id);
           free(id);
         return 1;          return 1;
 }  }
   
Line 1488  mdoc_bf_pre(MDOC_ARGS)
Line 1529  mdoc_bf_pre(MDOC_ARGS)
 static int  static int
 mdoc_ms_pre(MDOC_ARGS)  mdoc_ms_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_B, "cT", "Ms");          char *id;
   
           if ((id = cond_id(n)) != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_B, "cTi", "Ms", id);
           free(id);
         return 1;          return 1;
 }  }
   
Line 1524  mdoc_rs_pre(MDOC_ARGS)
Line 1570  mdoc_rs_pre(MDOC_ARGS)
 static int  static int
 mdoc_no_pre(MDOC_ARGS)  mdoc_no_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_SPAN, "c", "No");          char *id;
   
           if ((id = cond_id(n)) != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_SPAN, "ci", "No", id);
           free(id);
         return 1;          return 1;
 }  }
   
 static int  static int
 mdoc_li_pre(MDOC_ARGS)  mdoc_li_pre(MDOC_ARGS)
 {  {
         print_otag(h, TAG_CODE, "c", "Li");          char    *id;
   
           if ((id = cond_id(n)) != NULL)
                   print_otag(h, TAG_A, "chR", "selflink", id);
           print_otag(h, TAG_CODE, "ci", "Li", id);
           free(id);
         return 1;          return 1;
 }  }
   

Legend:
Removed from v.1.274  
changed lines
  Added in v.1.279

CVSweb