=================================================================== RCS file: /cvs/mandoc/html.c,v retrieving revision 1.119 retrieving revision 1.123 diff -u -p -r1.119 -r1.123 --- mandoc/html.c 2010/12/20 10:40:11 1.119 +++ mandoc/html.c 2010/12/24 14:14:00 1.123 @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.119 2010/12/20 10:40:11 kristaps Exp $ */ +/* $Id: html.c,v 1.123 2010/12/24 14:14:00 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -71,14 +71,11 @@ static const struct htmldata htmltags[TAG_MAX] = { {"p", HTML_CLRLINE | HTML_NOSTACK | HTML_AUTOCLOSE}, /* TAG_P */ {"pre", HTML_CLRLINE }, /* TAG_PRE */ {"b", 0 }, /* TAG_B */ + {"i", 0 }, /* TAG_I */ + {"code", 0 }, /* TAG_CODE */ + {"small", 0 }, /* TAG_SMALL */ }; -static const char *const htmlfonts[HTMLFONT_MAX] = { - "roman", - "bold", - "italic" -}; - static const char *const htmlattrs[ATTR_MAX] = { "http-equiv", /* ATTR_HTTPEQUIV */ "content", /* ATTR_CONTENT */ @@ -254,25 +251,6 @@ print_res(struct html *h, const char *p, size_t len) } -struct tag * -print_ofont(struct html *h, enum htmlfont font) -{ - struct htmlpair tag; - - h->metal = h->metac; - h->metac = font; - - /* FIXME: DECO_ROMAN should just close out preexisting. */ - - if (h->metaf && h->tags.head == h->metaf) - print_tagq(h, h->metaf); - - PAIR_CLASS_INIT(&tag, htmlfonts[font]); - h->metaf = print_otag(h, TAG_SPAN, 1, &tag); - return(h->metaf); -} - - static void print_metaf(struct html *h, enum roffdeco deco) { @@ -296,7 +274,18 @@ print_metaf(struct html *h, enum roffdeco deco) /* NOTREACHED */ } - (void)print_ofont(h, font); + if (h->metaf) { + print_tagq(h, h->metaf); + h->metaf = NULL; + } + + h->metal = h->metac; + h->metac = font; + + if (HTMLFONT_NONE != font) + h->metaf = HTMLFONT_BOLD == font ? + print_otag(h, TAG_B, 0, NULL) : + print_otag(h, TAG_I, 0, NULL); } @@ -484,7 +473,7 @@ print_xmltype(struct html *h) { if (HTML_XHTML_1_0_STRICT == h->type) - printf(""); + puts(""); } @@ -551,10 +540,21 @@ print_text(struct html *h, const char *word) printf(" "); } + assert(NULL == h->metaf); + if (HTMLFONT_NONE != h->metac) + h->metaf = HTMLFONT_BOLD == h->metac ? + print_otag(h, TAG_B, 0, NULL) : + print_otag(h, TAG_I, 0, NULL); + assert(word); if ( ! print_encode(h, word, 0)) if ( ! (h->flags & HTML_NONOSPACE)) h->flags &= ~HTML_NOSPACE; + + if (h->metaf) { + print_tagq(h, h->metaf); + h->metaf = NULL; + } h->flags &= ~HTML_IGNDELIM;