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

Diff for /mandoc/html.c between version 1.11 and 1.16

version 1.11, 2008/12/05 22:54:44 version 1.16, 2008/12/08 16:29:57
Line 55  static void  html_free(void *);
Line 55  static void  html_free(void *);
 static  ssize_t         html_endtag(struct md_mbuf *, void *,  static  ssize_t         html_endtag(struct md_mbuf *, void *,
                                 const struct md_args *,                                  const struct md_args *,
                                 enum md_ns, int);                                  enum md_ns, int);
   static  ssize_t         html_beginstring(struct md_mbuf *,
                                   const struct md_args *,
                                   const char *, size_t);
   static  ssize_t         html_beginhttp(struct md_mbuf *,
                                   const struct md_args *,
                                   const char *, size_t);
   static  ssize_t         html_endstring(struct md_mbuf *,
                                   const struct md_args *,
                                   const char *, size_t);
   static  ssize_t         html_endhttp(struct md_mbuf *,
                                   const struct md_args *,
                                   const char *, size_t);
 static  ssize_t         html_begintag(struct md_mbuf *, void *,  static  ssize_t         html_begintag(struct md_mbuf *, void *,
                                 const struct md_args *,                                  const struct md_args *,
                                 enum md_ns, int,                                  enum md_ns, int,
Line 63  static int  html_begin(struct md_mbuf *,
Line 75  static int  html_begin(struct md_mbuf *,
                                 const struct md_args *,                                  const struct md_args *,
                                 const struct tm *,                                  const struct tm *,
                                 const char *, const char *,                                  const char *, const char *,
                                 const char *, const char *);                                  enum roffmsec, const char *);
 static  int             html_printargs(struct md_mbuf *, int,  static  int             html_printargs(struct md_mbuf *, int,
                                 const char *, const int *,                                  const char *, const int *,
                                 const char **, size_t *);                                  const char **, size_t *);
Line 83  static int  html_headtagname(struct md_mbuf *,
Line 95  static int  html_headtagname(struct md_mbuf *,
 static  int             html_headtagargs(struct md_mbuf *,  static  int             html_headtagargs(struct md_mbuf *,
                                 const struct md_args *, int,                                  const struct md_args *, int,
                                 const int *, const char **, size_t *);                                  const int *, const char **, size_t *);
 static  int             html_blockbodytagname(struct md_mbuf *,  static  int             html_bodytagname(struct md_mbuf *,
                                 const struct md_args *,                                  const struct md_args *,
                                 int, struct htmlq *, const int *,                                  int, struct htmlq *, const int *,
                                 const char **, size_t *);                                  const char **, size_t *);
 static  int             html_blockbodytagargs(struct md_mbuf *,  static  int             html_bodytagargs(struct md_mbuf *,
                                 const struct md_args *, int,                                  const struct md_args *, int,
                                 const int *, const char **, size_t *);                                  const int *, const char **, size_t *);
 static  int             html_inlinetagname(struct md_mbuf *,  static  int             html_inlinetagname(struct md_mbuf *,
Line 122  html_It_headtagname(struct md_mbuf *mbuf, struct htmlq
Line 134  html_It_headtagname(struct md_mbuf *mbuf, struct htmlq
                         break;                          break;
   
         assert(n);          assert(n);
   
           /* LINTED */
         for (i = 0; ROFF_ARGMAX != n->argc[i] &&          for (i = 0; ROFF_ARGMAX != n->argc[i] &&
                         i < ROFF_MAXLINEARG; i++) {                          i < ROFF_MAXLINEARG; i++) {
                 switch (n->argc[i]) {                  switch (n->argc[i]) {
                   case (ROFF_Ohang):
                           return(ml_nputs(mbuf, "div", 3, res));
                 case (ROFF_Tag):                  case (ROFF_Tag):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (ROFF_Column):                  case (ROFF_Column):
Line 134  html_It_headtagname(struct md_mbuf *mbuf, struct htmlq
Line 150  html_It_headtagname(struct md_mbuf *mbuf, struct htmlq
                 }                  }
         }          }
   
         assert(i != ROFF_MAXLINEARG);          return(0);
         abort();  
         /* NOTREACHED */  
   
         return(1);  
 }  }
   
   
Line 155  html_It_bodytagname(struct md_mbuf *mbuf, struct htmlq
Line 167  html_It_bodytagname(struct md_mbuf *mbuf, struct htmlq
                         break;                          break;
   
         assert(n);          assert(n);
   
           /* LINTED */
         for (i = 0; ROFF_ARGMAX != n->argc[i] &&          for (i = 0; ROFF_ARGMAX != n->argc[i] &&
                         i < ROFF_MAXLINEARG; i++) {                          i < ROFF_MAXLINEARG; i++) {
                 switch (n->argc[i]) {                  switch (n->argc[i]) {
Line 186  html_It_bodytagname(struct md_mbuf *mbuf, struct htmlq
Line 200  html_It_bodytagname(struct md_mbuf *mbuf, struct htmlq
         }          }
   
         assert(i != ROFF_MAXLINEARG);          assert(i != ROFF_MAXLINEARG);
         abort();          return(0);
         /* NOTREACHED */  
   
         return(1);  
 }  }
   
   
Line 231  html_Bl_bodytagname(struct md_mbuf *mbuf, struct htmlq
Line 242  html_Bl_bodytagname(struct md_mbuf *mbuf, struct htmlq
         }          }
   
         assert(i != ROFF_MAXLINEARG);          assert(i != ROFF_MAXLINEARG);
         abort();          return(0);
         /* NOTREACHED */  
 }  }
   
   
Line 249  html_It_blocktagname(struct md_mbuf *mbuf, struct html
Line 259  html_It_blocktagname(struct md_mbuf *mbuf, struct html
                         break;                          break;
   
         assert(n);          assert(n);
   
           /* LINTED */
         for (i = 0; ROFF_ARGMAX != n->argc[i] &&          for (i = 0; ROFF_ARGMAX != n->argc[i] &&
                         i < ROFF_MAXLINEARG; i++) {                          i < ROFF_MAXLINEARG; i++) {
                 switch (n->argc[i]) {                  switch (n->argc[i]) {
Line 280  html_It_blocktagname(struct md_mbuf *mbuf, struct html
Line 292  html_It_blocktagname(struct md_mbuf *mbuf, struct html
         }          }
   
         assert(i != ROFF_MAXLINEARG);          assert(i != ROFF_MAXLINEARG);
         abort();          return(0);
         /* NOTREACHED */  
 }  }
   
   
Line 343  out:
Line 354  out:
 static int  static int
 html_begin(struct md_mbuf *mbuf, const struct md_args *args,  html_begin(struct md_mbuf *mbuf, const struct md_args *args,
                 const struct tm *tm, const char *os,                  const struct tm *tm, const char *os,
                 const char *title, const char *section,                  const char *title, enum roffmsec section,
                 const char *vol)                  const char *vol)
 {  {
         const char      *preamble, *css, *trail;          const char      *preamble, *css, *trail;
Line 371  html_begin(struct md_mbuf *mbuf, const struct md_args 
Line 382  html_begin(struct md_mbuf *mbuf, const struct md_args 
         res = 0;          res = 0;
   
         (void)snprintf(buf, sizeof(buf) - 1,          (void)snprintf(buf, sizeof(buf) - 1,
                         preamble, title, section);                          preamble, title, ml_section(section));
   
         if ( ! ml_puts(mbuf, buf, &res))          if ( ! ml_puts(mbuf, buf, &res))
                 return(0);                  return(0);
Line 409  html_end(struct md_mbuf *mbuf, const struct md_args *a
Line 420  html_end(struct md_mbuf *mbuf, const struct md_args *a
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 html_blockbodytagname(struct md_mbuf *mbuf,  html_bodytagname(struct md_mbuf *mbuf,
                 const struct md_args *args, int tok, struct htmlq *q,                  const struct md_args *args, int tok, struct htmlq *q,
                 const int *argc, const char **argv, size_t *res)                  const int *argc, const char **argv, size_t *res)
 {  {
Line 417  html_blockbodytagname(struct md_mbuf *mbuf, 
Line 428  html_blockbodytagname(struct md_mbuf *mbuf, 
         switch (tok) {          switch (tok) {
         case (ROFF_Bl):          case (ROFF_Bl):
                 return(html_Bl_bodytagname(mbuf, q, argc, argv, res));                  return(html_Bl_bodytagname(mbuf, q, argc, argv, res));
           case (ROFF_Fo):
                   return(ml_nputs(mbuf, "span", 4, res));
         case (ROFF_It):          case (ROFF_It):
                 return(html_It_bodytagname(mbuf, q, argc, argv, res));                  return(html_It_bodytagname(mbuf, q, argc, argv, res));
           case (ROFF_Oo):
                   return(ml_nputs(mbuf, "span", 4, res));
         default:          default:
                 break;                  break;
         }          }
Line 437  html_headtagname(struct md_mbuf *mbuf, 
Line 452  html_headtagname(struct md_mbuf *mbuf, 
         switch (tok) {          switch (tok) {
         case (ROFF_It):          case (ROFF_It):
                 return(html_It_headtagname(mbuf, q, argc, argv, res));                  return(html_It_headtagname(mbuf, q, argc, argv, res));
           case (ROFF_Fo):
                   return(ml_nputs(mbuf, "span", 4, res));
           case (ROFF_Oo):
                   return(ml_nputs(mbuf, "span", 4, res));
         case (ROFF_Sh):          case (ROFF_Sh):
                 return(ml_puts(mbuf, "h1", res));                  return(ml_nputs(mbuf, "h1", 2, res));
         case (ROFF_Ss):          case (ROFF_Ss):
                 return(ml_puts(mbuf, "h2", res));                  return(ml_nputs(mbuf, "h2", 2, res));
         default:          default:
                 break;                  break;
         }          }
   
         return(ml_puts(mbuf, "div", res));          return(ml_nputs(mbuf, "div", 3, res));
 }  }
   
   
Line 457  html_blocktagname(struct md_mbuf *mbuf, const struct m
Line 476  html_blocktagname(struct md_mbuf *mbuf, const struct m
 {  {
   
         switch (tok) {          switch (tok) {
           case (ROFF_Fo):
                   return(ml_nputs(mbuf, "span", 4, res));
           case (ROFF_Oo):
                   return(ml_nputs(mbuf, "span", 4, res));
         case (ROFF_It):          case (ROFF_It):
                 return(html_It_blocktagname(mbuf, q, argc, argv, res));                  return(html_It_blocktagname(mbuf, q, argc, argv, res));
         default:          default:
Line 498  html_headtagargs(struct md_mbuf *mbuf, 
Line 521  html_headtagargs(struct md_mbuf *mbuf, 
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
 html_blockbodytagargs(struct md_mbuf *mbuf,  html_bodytagargs(struct md_mbuf *mbuf,
                 const struct md_args *args, int tok,                  const struct md_args *args, int tok,
                 const int *argc, const char **argv, size_t *res)                  const int *argc, const char **argv, size_t *res)
 {  {
Line 525  html_inlinetagargs(struct md_mbuf *mbuf, 
Line 548  html_inlinetagargs(struct md_mbuf *mbuf, 
                 const int *argc, const char **argv, size_t *res)                  const int *argc, const char **argv, size_t *res)
 {  {
   
         return(html_printargs(mbuf, tok, "inline", argc, argv, res));          if ( ! html_printargs(mbuf, tok, "inline", argc, argv, res))
                   return(0);
   
           switch (tok) {
           case (ROFF_Sx):
                   assert(*argv);
                   if ( ! ml_nputs(mbuf, " href=\"#", 8, res))
                           return(0);
                   if ( ! ml_putstring(mbuf, *argv, res))
                           return(0);
                   if ( ! ml_nputs(mbuf, "\"", 1, res))
                           return(0);
                   break;
           default:
                   break;
           }
   
           return(1);
 }  }
   
   
Line 537  html_inlinetagname(struct md_mbuf *mbuf, 
Line 577  html_inlinetagname(struct md_mbuf *mbuf, 
   
         switch (tok) {          switch (tok) {
         case (ROFF_Pp):          case (ROFF_Pp):
                 return(ml_puts(mbuf, "div", res));                  return(ml_nputs(mbuf, "div", 3, res));
           case (ROFF_Sx):
                   return(ml_nputs(mbuf, "a", 1, res));
         default:          default:
                 break;                  break;
         }          }
Line 575  html_begintag(struct md_mbuf *mbuf, void *data,
Line 617  html_begintag(struct md_mbuf *mbuf, void *data,
                 /* TODO: argv. */                  /* TODO: argv. */
   
                 assert(argv);                  assert(argv);
                   /* LINTED */
                 for (i = 0; ROFF_ARGMAX != argc[i]                  for (i = 0; ROFF_ARGMAX != argc[i]
                                 && i < ROFF_MAXLINEARG; i++)                                  && i < ROFF_MAXLINEARG; i++)
                         node->argc[i] = argc[i];                          node->argc[i] = argc[i];
                 assert(i != ROFF_MAXLINEARG);                  assert(i != ROFF_MAXLINEARG);
         } else          }
                 assert(NULL == argv);  
   
   
         q->last = node;          q->last = node;
Line 595  html_begintag(struct md_mbuf *mbuf, void *data,
Line 637  html_begintag(struct md_mbuf *mbuf, void *data,
                         return(-1);                          return(-1);
                 break;                  break;
         case (MD_NS_BODY):          case (MD_NS_BODY):
                 if ( ! html_blockbodytagname(mbuf, args, tok,                  if ( ! html_bodytagname(mbuf, args, tok,
                                         q, argc, argv, &res))                                          q, argc, argv, &res))
                         return(-1);                          return(-1);
                 if ( ! html_blockbodytagargs(mbuf, args, tok,                  if ( ! html_bodytagargs(mbuf, args, tok,
                                         argc, argv, &res))                                          argc, argv, &res))
                         return(-1);                          return(-1);
                 break;                  break;
Line 646  html_endtag(struct md_mbuf *mbuf, void *data,
Line 688  html_endtag(struct md_mbuf *mbuf, void *data,
                         return(-1);                          return(-1);
                 break;                  break;
         case (MD_NS_BODY):          case (MD_NS_BODY):
                 if ( ! html_blockbodytagname(mbuf, args, tok,                  if ( ! html_bodytagname(mbuf, args, tok,
                                         q, node->argc,                                          q, node->argc,
                                         (const char **)node->argv, &res))                                          (const char **)node->argv, &res))
                         return(-1);                          return(-1);
Line 692  html_free(void *p)
Line 734  html_free(void *p)
         assert(p);          assert(p);
         q = (struct htmlq *)p;          q = (struct htmlq *)p;
   
           /* LINTED */
         while ((n = q->last)) {          while ((n = q->last)) {
                 q->last = n->parent;                  q->last = n->parent;
                 free(n);                  free(n);
Line 701  html_free(void *p)
Line 744  html_free(void *p)
 }  }
   
   
   static ssize_t
   html_beginhttp(struct md_mbuf *mbuf,
                   const struct md_args *args,
                   const char *buf, size_t sz)
   {
           size_t           res;
   
           res = 0;
   
           if ( ! ml_puts(mbuf, "<a href=\"", &res))
                   return(-1);
           if (1 != ml_nputstring(mbuf, buf, sz, &res))
                   return(-1);
           if ( ! ml_puts(mbuf, "\">", &res))
                   return(-1);
   
           return((ssize_t)res);
   }
   
   
   static ssize_t
   html_endhttp(struct md_mbuf *mbuf,
                   const struct md_args *args,
                   const char *buf, size_t sz)
   {
           size_t           res;
   
           res = 0;
   
           if ( ! ml_puts(mbuf, "</a>", &res))
                   return(-1);
   
           return((ssize_t)res);
   }
   
   
   /* ARGSUSED */
   static ssize_t
   html_beginstring(struct md_mbuf *mbuf,
                   const struct md_args *args,
                   const char *buf, size_t sz)
   {
   
           if (0 == strncmp(buf, "http://", 7))
                   return(html_beginhttp(mbuf, args, buf, sz));
   
           return(0);
   }
   
   
   /* ARGSUSED */
   static ssize_t
   html_endstring(struct md_mbuf *mbuf,
                   const struct md_args *args,
                   const char *buf, size_t sz)
   {
   
           if (0 == strncmp(buf, "http://", 7))
                   return(html_endhttp(mbuf, args, buf, sz));
   
           return(0);
   }
   
   
 int  int
 md_line_html(void *data, char *buf)  md_line_html(void *data, char *buf)
 {  {
Line 729  md_init_html(const struct md_args *args,
Line 836  md_init_html(const struct md_args *args,
         cbs.ml_endtag = html_endtag;          cbs.ml_endtag = html_endtag;
         cbs.ml_begin = html_begin;          cbs.ml_begin = html_begin;
         cbs.ml_end = html_end;          cbs.ml_end = html_end;
           cbs.ml_beginstring = html_beginstring;
           cbs.ml_endstring = html_endstring;
   
         return(mlg_alloc(args, rbuf, mbuf, &cbs));          return(mlg_alloc(args, rbuf, mbuf, &cbs));
 }  }
   

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.16

CVSweb