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

Diff for /mandoc/html.c between version 1.5 and 1.54

version 1.5, 2008/12/04 16:19:52 version 1.54, 2009/10/03 15:26:26
Line 1 
Line 1 
 /* $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>   * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the   * purpose with or without fee is hereby granted, provided that the above
  * above copyright notice and this permission notice appear in all   * copyright notice and this permission notice appear in all copies.
  * copies.  
  *   *
  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED   * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE   * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL   * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  * PERFORMANCE OF THIS SOFTWARE.  
  */   */
 #include <sys/param.h>  #include <sys/types.h>
 #include <sys/stat.h>  #include <sys/queue.h>
   
 #include <assert.h>  #include <assert.h>
 #include <err.h>  #include <err.h>
 #include <fcntl.h>  
 #include <stdlib.h>  
 #include <stdio.h>  #include <stdio.h>
   #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
 #include "libmdocml.h"  #include "chars.h"
 #include "private.h"  #include "html.h"
 #include "ml.h"  
   
   #define DOCTYPE         "-//W3C//DTD HTML 4.01//EN"
   #define DTD             "http://www.w3.org/TR/html4/strict.dtd"
   
 static  int             html_loadcss(struct md_mbuf *, const char *);  struct  htmldata {
           char             *name;
           int               flags;
   #define HTML_CLRLINE     (1 << 0)
   #define HTML_NOSTACK     (1 << 1)
   };
   
 static  ssize_t         html_endtag(struct md_mbuf *,  static  const struct htmldata htmltags[TAG_MAX] = {
                                 const struct md_args *,          {"html",        HTML_CLRLINE}, /* TAG_HTML */
                                 enum md_ns, int);          {"head",        HTML_CLRLINE}, /* TAG_HEAD */
 static  ssize_t         html_begintag(struct md_mbuf *,          {"body",        HTML_CLRLINE}, /* TAG_BODY */
                                 const struct md_args *,          {"meta",        HTML_CLRLINE | HTML_NOSTACK}, /* TAG_META */
                                 enum md_ns, int,          {"title",       HTML_CLRLINE}, /* TAG_TITLE */
                                 const int *, const char **);          {"div",         HTML_CLRLINE}, /* TAG_DIV */
 static  int             html_begin(struct md_mbuf *,          {"h1",          0}, /* TAG_H1 */
                                 const struct md_args *,          {"h2",          0}, /* TAG_H2 */
                                 const struct tm *,          {"p",           HTML_CLRLINE}, /* TAG_P */
                                 const char *, const char *,          {"span",        0}, /* TAG_SPAN */
                                 const char *, const char *);          {"link",        HTML_CLRLINE | HTML_NOSTACK}, /* TAG_LINK */
 static  int             html_end(struct md_mbuf *,          {"br",          HTML_CLRLINE | HTML_NOSTACK}, /* TAG_LINK */
                                 const struct md_args *);          {"a",           0}, /* TAG_A */
 static  ssize_t         html_blocktagname(struct md_mbuf *,          {"table",       HTML_CLRLINE}, /* TAG_TABLE */
                                 const struct md_args *, int);          {"col",         HTML_CLRLINE | HTML_NOSTACK}, /* TAG_COL */
 static  ssize_t         html_blocktagargs(struct md_mbuf *,          {"tr",          HTML_CLRLINE}, /* TAG_TR */
                                 const struct md_args *, int,          {"td",          HTML_CLRLINE}, /* TAG_TD */
                                 const int *, const char **);          {"li",          HTML_CLRLINE}, /* TAG_LI */
 static  ssize_t         html_blockheadtagname(struct md_mbuf *,          {"ul",          HTML_CLRLINE}, /* TAG_UL */
                                 const struct md_args *, int);          {"ol",          HTML_CLRLINE}, /* TAG_OL */
 static  ssize_t         html_blockheadtagargs(struct md_mbuf *,          {"base",        HTML_CLRLINE | HTML_NOSTACK}, /* TAG_BASE */
                                 const struct md_args *, int,  };
                                 const int *, const char **);  
 static  ssize_t         html_blockbodytagname(struct md_mbuf *,  
                                 const struct md_args *, int);  
 static  ssize_t         html_blockbodytagargs(struct md_mbuf *,  
                                 const struct md_args *, int,  
                                 const int *, const char **);  
 static  ssize_t         html_inlinetagname(struct md_mbuf *,  
                                 const struct md_args *, int);  
 static  ssize_t         html_inlinetagargs(struct md_mbuf *,  
                                 const struct md_args *, int,  
                                 const int *, const char **);  
   
   static  const char       *const htmlattrs[ATTR_MAX] = {
           "http-equiv",
           "content",
           "name",
           "rel",
           "href",
           "type",
           "media",
           "class",
           "style",
           "width",
           "valign",
           "target",
   };
   
 static int  #ifdef __linux__
 html_loadcss(struct md_mbuf *mbuf, const char *css)  extern  int               getsubopt(char **, char * const *, char **);
   #endif
   
   void *
   html_alloc(char *outopts)
 {  {
         size_t           res, bufsz;          struct html     *h;
         char            *buf;          char            *toks[4], *v;
         struct stat      st;  
         int              fd, c;  
         ssize_t          ssz;  
   
         c = 0;          toks[0] = "style";
         res = 0;          toks[1] = "man";
         buf = NULL;          toks[2] = "includes";
           toks[3] = NULL;
   
         if (-1 == (fd = open(css, O_RDONLY, 0))) {          if (NULL == (h = calloc(1, sizeof(struct html))))
                 warn("%s", css);                  return(NULL);
                 return(0);  
         }  
   
         if (-1 == fstat(fd, &st)) {  
                 warn("%s", css);  
                 goto out;  
         }  
   
         bufsz = MAX(st.st_blksize, BUFSIZ);          SLIST_INIT(&h->tags);
         if (NULL == (buf = malloc(bufsz))) {          SLIST_INIT(&h->ords);
                 warn("malloc");  
                 goto out;          if (NULL == (h->symtab = chars_init(CHARS_HTML))) {
                   free(h);
                   return(NULL);
         }          }
   
         for (;;) {          while (outopts && *outopts)
                 if (-1 == (ssz = read(fd, buf, bufsz))) {                  switch (getsubopt(&outopts, toks, &v)) {
                         warn("%s", css);                  case (0):
                         goto out;                          h->style = v;
                 } else if (0 == ssz)  
                         break;                          break;
                 if ( ! ml_nputs(mbuf, buf, (size_t)ssz, &res))                  case (1):
                         goto out;                          h->base_man = v;
         }                          break;
                   case (2):
                           h->base_includes = v;
                           break;
                   default:
                           break;
                   }
   
         c = 1;          return(h);
   
 out:  
         if (-1 == close(fd)) {  
                 warn("%s", css);  
                 c = 0;  
         }  
   
         if (buf)  
                 free(buf);  
   
         return(c);  
 }  }
   
   
 /* ARGSUSED */  void
 static int  html_free(void *p)
 html_begin(struct md_mbuf *mbuf, const struct md_args *args,  
                 const struct tm *tm, const char *os,  
                 const char *title, const char *section,  
                 const char *vol)  
 {  {
         const char      *preamble, *css, *trail;          struct tag      *tag;
         char             buf[512];          struct ord      *ord;
         size_t           res;          struct html     *h;
   
         preamble =          h = (struct html *)p;
         "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n"  
         "    \"http://www.w3.org/TR/html4/strict.dtd\">\n"  
         "<html>\n"  
         "<head>\n"  
         "    <meta http-equiv=\"Content-Type\"\n"  
         "         content=\"text/html;charset=utf-8\">\n"  
         "    <meta name=\"resource-type\" content=\"document\">\n"  
         "    <title>Manual Page for %s(%s)</title>\n";  
   
         css =          while ( ! SLIST_EMPTY(&h->ords)) {
         "    <link rel=\"stylesheet\" type=\"text/css\"\n"                  ord = SLIST_FIRST(&h->ords);
         "         href=\"%s\">\n";                  SLIST_REMOVE_HEAD(&h->ords, entry);
         trail =                  free(ord);
         "</head>\n"          }
         "<body>\n"  
         "<div class=\"mdoc\">\n";  
   
         res = 0;          while ( ! SLIST_EMPTY(&h->tags)) {
                   tag = SLIST_FIRST(&h->tags);
         (void)snprintf(buf, sizeof(buf) - 1,                  SLIST_REMOVE_HEAD(&h->tags, entry);
                         preamble, title, section);                  free(tag);
   
         if ( ! ml_puts(mbuf, buf, &res))  
                 return(0);  
   
         assert(args->params.html.css);  
         if (HTML_CSS_EMBED & args->params.html.flags) {  
                 if ( ! ml_puts(mbuf, "    <style type=\"text/css\"><!--\n", &res))  
                         return(0);  
                 if ( ! html_loadcss(mbuf, args->params.html.css))  
                         return(0);  
                 if ( ! ml_puts(mbuf, "    --!></style>\n", &res))  
                         return(0);  
         } else {  
                 (void)snprintf(buf, sizeof(buf) - 1, css,  
                                 args->params.html.css);  
                 if ( ! ml_puts(mbuf, buf, &res))  
                         return(0);  
         }          }
   
           if (h->buf)
                   free(h->buf);
           if (h->symtab)
                   chars_free(h->symtab);
   
         if ( ! ml_puts(mbuf, trail, &res))          free(h);
                 return(0);  
   
         return(1);  
 }  }
   
   
 /* ARGSUSED */  void
 static int  print_gen_head(struct html *h)
 html_end(struct md_mbuf *mbuf, const struct md_args *args)  
 {  {
         size_t           res;          struct htmlpair  tag[4];
   
         res = 0;          tag[0].key = ATTR_HTTPEQUIV;
         if ( ! ml_puts(mbuf, "</div></body>\n</html>", &res))          tag[0].val = "Content-Type";
                 return(0);          tag[1].key = ATTR_CONTENT;
           tag[1].val = "text/html; charset=utf-8";
           print_otag(h, TAG_META, 2, tag);
   
         return(1);          tag[0].key = ATTR_NAME;
           tag[0].val = "resource-type";
           tag[1].key = ATTR_CONTENT;
           tag[1].val = "document";
           print_otag(h, TAG_META, 2, tag);
   
           if (h->style) {
                   tag[0].key = ATTR_REL;
                   tag[0].val = "stylesheet";
                   tag[1].key = ATTR_HREF;
                   tag[1].val = h->style;
                   tag[2].key = ATTR_TYPE;
                   tag[2].val = "text/css";
                   tag[3].key = ATTR_MEDIA;
                   tag[3].val = "all";
                   print_otag(h, TAG_LINK, 4, tag);
           }
 }  }
   
   
 /* ARGSUSED */  static void
 static ssize_t  print_spec(struct html *h, const char *p, int len)
 html_blockbodytagname(struct md_mbuf *mbuf,  
                 const struct md_args *args, int tok)  
 {  {
         size_t           res;          const char      *rhs;
           int              i;
           size_t           sz;
   
         res = 0;          rhs = chars_a2ascii(h->symtab, p, (size_t)len, &sz);
         if ( ! ml_puts(mbuf, "div", &res))  
                 return(-1);  
   
         return((ssize_t)res);          if (NULL == rhs)
                   return;
           for (i = 0; i < (int)sz; i++)
                   putchar(rhs[i]);
 }  }
   
   
   static void
   print_res(struct html *h, const char *p, int len)
 /* ARGSUSED */  
 static ssize_t  
 html_blockheadtagname(struct md_mbuf *mbuf,  
                 const struct md_args *args, int tok)  
 {  {
         size_t           res;          const char      *rhs;
           int              i;
           size_t           sz;
   
         res = 0;          rhs = chars_a2res(h->symtab, p, (size_t)len, &sz);
         if ( ! ml_puts(mbuf, "div", &res))  
                 return(-1);  
   
         return((ssize_t)res);          if (NULL == rhs)
                   return;
           for (i = 0; i < (int)sz; i++)
                   putchar(rhs[i]);
 }  }
   
   
 /* ARGSUSED */  static void
 static ssize_t  print_escape(struct html *h, const char **p)
 html_blocktagname(struct md_mbuf *mbuf,  
                 const struct md_args *args, int tok)  
 {  {
         size_t           res;          int              j, type;
           const char      *wp;
   
         res = 0;          wp = *p;
         if ( ! ml_puts(mbuf, "div", &res))          type = 1;
                 return(-1);  
   
         return((ssize_t)res);          if (0 == *(++wp)) {
 }                  *p = wp;
                   return;
           }
   
           if ('(' == *wp) {
                   wp++;
                   if (0 == *wp || 0 == *(wp + 1)) {
                           *p = 0 == *wp ? wp : wp + 1;
                           return;
                   }
   
 /* ARGSUSED */                  print_spec(h, wp, 2);
 static ssize_t                  *p = ++wp;
 html_blockheadtagargs(struct md_mbuf *mbuf, const struct md_args *args,                  return;
                 int tok, const int *argc, const char **argv)  
 {  
         size_t           res;  
   
         res = 0;          } else if ('*' == *wp) {
                   if (0 == *(++wp)) {
                           *p = wp;
                           return;
                   }
   
         if ( ! ml_puts(mbuf, " class=\"head-", &res))                  switch (*wp) {
                 return(0);                  case ('('):
         if ( ! ml_puts(mbuf, toknames[tok], &res))                          wp++;
                 return(0);                          if (0 == *wp || 0 == *(wp + 1)) {
         if ( ! ml_puts(mbuf, "\"", &res))                                  *p = 0 == *wp ? wp : wp + 1;
                 return(0);                                  return;
                           }
   
         switch (tok) {                          print_res(h, wp, 2);
         default:                          *p = ++wp;
                 break;                          return;
         }                  case ('['):
                           type = 0;
                           break;
                   default:
                           print_res(h, wp, 1);
                           *p = wp;
                           return;
                   }
   
           } else if ('f' == *wp) {
                   if (0 == *(++wp)) {
                           *p = wp;
                           return;
                   }
   
         return(0);                  switch (*wp) {
 }                  case ('B'):
                           /* TODO */
                           break;
                   case ('I'):
                           /* TODO */
                           break;
                   case ('P'):
                           /* FALLTHROUGH */
                   case ('R'):
                           /* TODO */
                           break;
                   default:
                           break;
                   }
   
                   *p = wp;
                   return;
   
 /* ARGSUSED */          } else if ('[' != *wp) {
 static ssize_t                  print_spec(h, wp, 1);
 html_blockbodytagargs(struct md_mbuf *mbuf, const struct md_args *args,                  *p = wp;
                 int tok, const int *argc, const char **argv)                  return;
 {          }
         size_t           res;  
   
         res = 0;          wp++;
           for (j = 0; *wp && ']' != *wp; wp++, j++)
                   /* Loop... */ ;
   
         if ( ! ml_puts(mbuf, " class=\"body-", &res))          if (0 == *wp) {
                 return(0);                  *p = wp;
         if ( ! ml_puts(mbuf, toknames[tok], &res))                  return;
                 return(0);  
         if ( ! ml_puts(mbuf, "\"", &res))  
                 return(0);  
   
         switch (tok) {  
         default:  
                 break;  
         }          }
   
         return(res);          if (type)
                   print_spec(h, wp - j, j);
           else
                   print_res(h, wp - j, j);
   
           *p = wp;
 }  }
   
   
 /* ARGSUSED */  static void
 static ssize_t  print_encode(struct html *h, const char *p)
 html_blocktagargs(struct md_mbuf *mbuf, const struct md_args *args,  
                 int tok, const int *argc, const char **argv)  
 {  {
         size_t           res;  
   
         res = 0;          for (; *p; p++) {
                   if ('\\' == *p) {
         if ( ! ml_puts(mbuf, " class=\"block-", &res))                          print_escape(h, &p);
                 return(0);                          continue;
         if ( ! ml_puts(mbuf, toknames[tok], &res))                  }
                 return(0);                  switch (*p) {
         if ( ! ml_puts(mbuf, "\"", &res))                  case ('<'):
                 return(0);                          printf("&lt;");
                           break;
         switch (tok) {                  case ('>'):
         default:                          printf("&gt;");
                 break;                          break;
                   case ('&'):
                           printf("&amp;");
                           break;
                   default:
                           putchar(*p);
                           break;
                   }
         }          }
   
         return(0);  
 }  }
   
   
 /* ARGSUSED */  struct tag *
 static ssize_t  print_otag(struct html *h, enum htmltag tag,
 html_inlinetagargs(struct md_mbuf *mbuf, const struct md_args *args,                  int sz, const struct htmlpair *p)
                 int tok, const int *argc, const char **argv)  
 {  {
         size_t           res;          int              i;
           struct tag      *t;
   
         res = 0;          if ( ! (HTML_NOSTACK & htmltags[tag].flags)) {
                   if (NULL == (t = malloc(sizeof(struct tag))))
                           err(EXIT_FAILURE, "malloc");
                   t->tag = tag;
                   SLIST_INSERT_HEAD(&h->tags, t, entry);
           } else
                   t = NULL;
   
         if ( ! ml_puts(mbuf, " class=\"inline-", &res))          if ( ! (HTML_NOSPACE & h->flags))
                 return(0);                  if ( ! (HTML_CLRLINE & htmltags[tag].flags))
         if ( ! ml_puts(mbuf, toknames[tok], &res))                          printf(" ");
                 return(0);  
         if ( ! ml_puts(mbuf, "\"", &res))  
                 return(0);  
   
           printf("<%s", htmltags[tag].name);
         switch (tok) {          for (i = 0; i < sz; i++) {
         default:                  printf(" %s=\"", htmlattrs[p[i].key]);
                 break;                  assert(p->val);
                   print_encode(h, p[i].val);
                   printf("\"");
         }          }
           printf(">");
   
         return(0);          h->flags |= HTML_NOSPACE;
           if (HTML_CLRLINE & htmltags[tag].flags)
                   h->flags |= HTML_NEWLINE;
           else
                   h->flags &= ~HTML_NEWLINE;
   
           return(t);
 }  }
   
   
 /* ARGSUSED */  /* ARGSUSED */
 static ssize_t  static void
 html_inlinetagname(struct md_mbuf *mbuf,  print_ctag(struct html *h, enum htmltag tag)
                 const struct md_args *args, int tok)  
 {  {
         size_t           res;  
           printf("</%s>", htmltags[tag].name);
         res = 0;          if (HTML_CLRLINE & htmltags[tag].flags)
                   h->flags |= HTML_NOSPACE;
         switch (tok) {          if (HTML_CLRLINE & htmltags[tag].flags)
         case (ROFF_Pp):                  h->flags |= HTML_NEWLINE;
                 if ( ! ml_puts(mbuf, "div", &res))          else
                         return(-1);                  h->flags &= ~HTML_NEWLINE;
                 break;  
         default:  
                 if ( ! ml_puts(mbuf, "span", &res))  
                         return(-1);  
                 break;  
         }  
   
         return((ssize_t)res);  
 }  }
   
   
 static ssize_t  /* ARGSUSED */
 html_begintag(struct md_mbuf *mbuf, const struct md_args *args,  void
                 enum md_ns ns, int tok,  print_gen_doctype(struct html *h)
                 const int *argc, const char **argv)  
 {  {
   
         assert(ns != MD_NS_DEFAULT);          printf("<!DOCTYPE HTML PUBLIC \"%s\" \"%s\">", DOCTYPE, DTD);
         switch (ns) {  
         case (MD_NS_BLOCK):  
                 if ( ! html_blocktagname(mbuf, args, tok))  
                         return(0);  
                 return(html_blocktagargs(mbuf, args,  
                                         tok, argc, argv));  
         case (MD_NS_BODY):  
                 if ( ! html_blockbodytagname(mbuf, args, tok))  
                         return(0);  
                 return(html_blockbodytagargs(mbuf, args,  
                                         tok, argc, argv));  
         case (MD_NS_HEAD):  
                 if ( ! html_blockheadtagname(mbuf, args, tok))  
                         return(0);  
                 return(html_blockheadtagargs(mbuf, args,  
                                         tok, argc, argv));  
         default:  
                 break;  
         }  
   
         if ( ! html_inlinetagname(mbuf, args, tok))  
                 return(0);  
         return(html_inlinetagargs(mbuf, args, tok, argc, argv));  
 }  }
   
   
 static ssize_t  void
 html_endtag(struct md_mbuf *mbuf, const struct md_args *args,  print_text(struct html *h, const char *p)
                 enum md_ns ns, int tok)  
 {  {
   
         assert(ns != MD_NS_DEFAULT);          if (*p && 0 == *(p + 1))
         switch (ns) {                  switch (*p) {
         case (MD_NS_BLOCK):                  case('.'):
                 return(html_blocktagname(mbuf, args, tok));                          /* FALLTHROUGH */
         case (MD_NS_BODY):                  case(','):
                 return(html_blockbodytagname(mbuf, args, tok));                          /* FALLTHROUGH */
         case (MD_NS_HEAD):                  case(';'):
                 return(html_blockheadtagname(mbuf, args, tok));                          /* FALLTHROUGH */
         default:                  case(':'):
                 break;                          /* FALLTHROUGH */
         }                  case('?'):
                           /* FALLTHROUGH */
                   case('!'):
                           /* FALLTHROUGH */
                   case(')'):
                           /* FALLTHROUGH */
                   case(']'):
                           /* FALLTHROUGH */
                   case('}'):
                           if ( ! (HTML_IGNDELIM & h->flags))
                                   h->flags |= HTML_NOSPACE;
                           break;
                   default:
                           break;
                   }
   
         return(html_inlinetagname(mbuf, args, tok));          if ( ! (h->flags & HTML_NOSPACE))
 }                  printf(" ");
   
           h->flags &= ~HTML_NOSPACE;
           h->flags &= ~HTML_NEWLINE;
   
 int          if (p)
 md_line_html(void *data, char *buf)                  print_encode(h, p);
 {  
   
         return(mlg_line((struct md_mlg *)data, buf));          if (*p && 0 == *(p + 1))
                   switch (*p) {
                   case('('):
                           /* FALLTHROUGH */
                   case('['):
                           /* FALLTHROUGH */
                   case('{'):
                           h->flags |= HTML_NOSPACE;
                           break;
                   default:
                           break;
                   }
 }  }
   
   
 int  void
 md_exit_html(void *data, int flush)  print_tagq(struct html *h, const struct tag *until)
 {  {
           struct tag      *tag;
   
         return(mlg_exit((struct md_mlg *)data, flush));          while ( ! SLIST_EMPTY(&h->tags)) {
                   tag = SLIST_FIRST(&h->tags);
                   print_ctag(h, tag->tag);
                   SLIST_REMOVE_HEAD(&h->tags, entry);
                   free(tag);
                   if (until && tag == until)
                           return;
           }
 }  }
   
   
 void *  void
 md_init_html(const struct md_args *args,  print_stagq(struct html *h, const struct tag *suntil)
                 struct md_mbuf *mbuf, const struct md_rbuf *rbuf)  
 {  {
           struct tag      *tag;
   
         return(mlg_alloc(args, rbuf, mbuf, html_begintag,          while ( ! SLIST_EMPTY(&h->tags)) {
                                 html_endtag, html_begin, html_end));                  tag = SLIST_FIRST(&h->tags);
                   if (suntil && tag == suntil)
                           return;
                   print_ctag(h, tag->tag);
                   SLIST_REMOVE_HEAD(&h->tags, entry);
                   free(tag);
           }
 }  }
   

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

CVSweb