=================================================================== RCS file: /cvs/mandoc/html.c,v retrieving revision 1.109 retrieving revision 1.120 diff -u -p -r1.109 -r1.120 --- mandoc/html.c 2010/07/23 00:08:57 1.109 +++ mandoc/html.c 2010/12/20 13:07:55 1.120 @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.109 2010/07/23 00:08:57 kristaps Exp $ */ +/* $Id: html.c,v 1.120 2010/12/20 13:07:55 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -57,12 +57,22 @@ static const struct htmldata htmltags[TAG_MAX] = { {"br", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_BR */ {"a", 0}, /* TAG_A */ {"table", HTML_CLRLINE}, /* TAG_TABLE */ + {"tbody", HTML_CLRLINE}, /* TAG_TBODY */ {"col", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_COL */ {"tr", HTML_CLRLINE}, /* TAG_TR */ {"td", HTML_CLRLINE}, /* TAG_TD */ {"li", HTML_CLRLINE}, /* TAG_LI */ {"ul", HTML_CLRLINE}, /* TAG_UL */ {"ol", HTML_CLRLINE}, /* TAG_OL */ + {"dl", HTML_CLRLINE}, /* TAG_DL */ + {"dt", HTML_CLRLINE}, /* TAG_DT */ + {"dd", HTML_CLRLINE}, /* TAG_DD */ + {"blockquote", HTML_CLRLINE}, /* TAG_BLOCKQUOTE */ + {"p", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_P */ + {"pre", HTML_CLRLINE }, /* TAG_PRE */ + {"b", 0 }, /* TAG_B */ + {"i", 0 }, /* TAG_I */ + {"u", 0 }, /* TAG_U */ }; static const char *const htmlfonts[HTMLFONT_MAX] = { @@ -72,20 +82,19 @@ static const char *const htmlfonts[HTMLFONT_MAX] = { }; static const char *const htmlattrs[ATTR_MAX] = { - "http-equiv", - "content", - "name", - "rel", - "href", - "type", - "media", - "class", - "style", - "width", - "valign", - "target", - "id", - "summary", + "http-equiv", /* ATTR_HTTPEQUIV */ + "content", /* ATTR_CONTENT */ + "name", /* ATTR_NAME */ + "rel", /* ATTR_REL */ + "href", /* ATTR_HREF */ + "type", /* ATTR_TYPE */ + "media", /* ATTR_MEDIA */ + "class", /* ATTR_CLASS */ + "style", /* ATTR_STYLE */ + "width", /* ATTR_WIDTH */ + "id", /* ATTR_ID */ + "summary", /* ATTR_SUMMARY */ + "align", /* ATTR_ALIGN */ }; static void print_spec(struct html *, enum roffdeco, @@ -116,12 +125,11 @@ ml_alloc(char *outopts, enum htmltype type) h = calloc(1, sizeof(struct html)); if (NULL == h) { perror(NULL); - exit(EXIT_FAILURE); + exit((int)MANDOCLEVEL_SYSERR); } h->type = type; h->tags.head = NULL; - h->ords.head = NULL; h->symtab = chars_init(CHARS_HTML); while (outopts && *outopts) @@ -162,16 +170,10 @@ void html_free(void *p) { struct tag *tag; - struct ord *ord; struct html *h; h = (struct html *)p; - while ((ord = h->ords.head) != NULL) { - h->ords.head = ord->next; - free(ord); - } - while ((tag = h->tags.head) != NULL) { h->tags.head = tag->next; free(tag); @@ -398,7 +400,7 @@ print_otag(struct html *h, enum htmltag tag, t = malloc(sizeof(struct tag)); if (NULL == t) { perror(NULL); - exit(EXIT_FAILURE); + exit((int)MANDOCLEVEL_SYSERR); } t->tag = tag; t->next = h->tags.head; @@ -419,6 +421,8 @@ print_otag(struct html *h, enum htmltag tag, if ( ! (h->flags & HTML_NONOSPACE)) h->flags &= ~HTML_NOSPACE; + else + h->flags |= HTML_NOSPACE; /* Print out the tag name and attributes. */ @@ -448,6 +452,10 @@ print_otag(struct html *h, enum htmltag tag, putchar('>'); h->flags |= HTML_NOSPACE; + + if ((HTML_AUTOCLOSE | HTML_CLRLINE) & htmltags[tag].flags) + putchar('\n'); + return(t); } @@ -549,6 +557,8 @@ print_text(struct html *h, const char *word) if ( ! print_encode(h, word, 0)) if ( ! (h->flags & HTML_NONOSPACE)) h->flags &= ~HTML_NOSPACE; + + h->flags &= ~HTML_IGNDELIM; /* * Note that we don't process the pipe: the parser sees it as