=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.191 retrieving revision 1.197 diff -u -p -r1.191 -r1.197 --- mandoc/mdoc_html.c 2014/07/02 03:48:07 1.191 +++ mandoc/mdoc_html.c 2014/08/13 15:25:22 1.197 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.191 2014/07/02 03:48:07 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.197 2014/08/13 15:25:22 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -15,9 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include @@ -380,8 +378,9 @@ print_mdoc_head(MDOC_ARGS) print_gen_head(h); bufinit(h); - bufcat_fmt(h, "%s(%s)", meta->title, meta->msec); - + bufcat(h, meta->title); + if (meta->msec) + bufcat_fmt(h, "(%s)", meta->msec); if (meta->arch) bufcat_fmt(h, " (%s)", meta->arch); @@ -525,7 +524,11 @@ mdoc_root_pre(MDOC_ARGS) mandoc_asprintf(&volume, "%s (%s)", meta->vol, meta->arch); - mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec); + if (NULL == meta->msec) + title = mandoc_strdup(meta->title); + else + mandoc_asprintf(&title, "%s(%s)", + meta->title, meta->msec); PAIR_SUMMARY_INIT(&tag[0], "Document Header"); PAIR_CLASS_INIT(&tag[1], "head"); @@ -699,7 +702,7 @@ mdoc_nm_pre(MDOC_ARGS) if (0 == len && meta->name) len = html_strlen(meta->name); - SCALE_HS_INIT(&su, (double)len); + SCALE_HS_INIT(&su, len); bufinit(h); bufcat_su(h, "width", &su); PAIR_STYLE_INIT(&tag, h); @@ -1069,21 +1072,19 @@ mdoc_ex_pre(MDOC_ARGS) } if (nchild > 1) - print_text(h, "utilities exit"); + print_text(h, "utilities exit\\~0"); else - print_text(h, "utility exits"); + print_text(h, "utility exits\\~0"); - print_text(h, "0 on success, and >0 if an error occurs."); + print_text(h, "on success, and\\~>0 if an error occurs."); return(0); } static int mdoc_em_pre(MDOC_ARGS) { - struct htmlpair tag; - PAIR_CLASS_INIT(&tag, "emph"); - print_otag(h, TAG_SPAN, 1, &tag); + print_otag(h, TAG_EM, 0, NULL); return(1); } @@ -1524,23 +1525,16 @@ static int mdoc_sm_pre(MDOC_ARGS) { - assert(n->child && MDOC_TEXT == n->child->type); - if (0 == strcmp("on", n->child->string)) { - /* - * FIXME: no p->col to check. Thus, if we have - * .Bd -literal - * .Sm off - * 1 2 - * .Sm on - * 3 - * .Ed - * the "3" is preceded by a space. - */ - h->flags &= ~HTML_NOSPACE; + if (NULL == n->child) + h->flags ^= HTML_NONOSPACE; + else if (0 == strcmp("on", n->child->string)) h->flags &= ~HTML_NONOSPACE; - } else + else h->flags |= HTML_NONOSPACE; + if ( ! (HTML_NONOSPACE & h->flags)) + h->flags &= ~HTML_NOSPACE; + return(0); } @@ -1572,7 +1566,7 @@ mdoc_sp_pre(MDOC_ARGS) if ( ! a2roffsu(n->string, &su, SCALE_VS)) SCALE_VS_INIT(&su, atoi(n->string)); } else - su.scale = 0; + su.scale = 0.0; bufinit(h); bufcat_su(h, "height", &su); @@ -1751,35 +1745,41 @@ mdoc_rv_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag, "fname"); - print_text(h, "The"); - nchild = n->nchild; - for (n = n->child; n; n = n->next) { - assert(MDOC_TEXT == n->type); + if (nchild > 0) { + print_text(h, "The"); - t = print_otag(h, TAG_B, 1, &tag); - print_text(h, n->string); - print_tagq(h, t); + for (n = n->child; n; n = n->next) { + t = print_otag(h, TAG_B, 1, &tag); + print_text(h, n->string); + print_tagq(h, t); - h->flags |= HTML_NOSPACE; - print_text(h, "()"); - - if (nchild > 2 && n->next) { h->flags |= HTML_NOSPACE; - print_text(h, ","); + print_text(h, "()"); + + if (n->next == NULL) + continue; + + if (nchild > 2) { + h->flags |= HTML_NOSPACE; + print_text(h, ","); + } + if (n->next->next == NULL) + print_text(h, "and"); } - if (n->next && NULL == n->next->next) - print_text(h, "and"); - } + if (nchild > 1) + print_text(h, "functions return"); + else + print_text(h, "function returns"); - if (nchild > 1) - print_text(h, "functions return"); - else - print_text(h, "function returns"); + print_text(h, "the value\\~0 if successful;"); + } else + print_text(h, "Upon successful completion," + " the value\\~0 is returned;"); - print_text(h, "the value 0 if successful; otherwise the " - "value -1 is returned and the global variable"); + print_text(h, "otherwise the value\\~\\-1 is returned" + " and the global variable"); PAIR_CLASS_INIT(&tag, "var"); t = print_otag(h, TAG_B, 1, &tag); @@ -1820,9 +1820,7 @@ mdoc_bf_pre(MDOC_ARGS) else if (MDOC_BODY != n->type) return(1); - if (FONT_Em == n->norm->Bf.font) - PAIR_CLASS_INIT(&tag[0], "emph"); - else if (FONT_Sy == n->norm->Bf.font) + if (FONT_Sy == n->norm->Bf.font) PAIR_CLASS_INIT(&tag[0], "symb"); else if (FONT_Li == n->norm->Bf.font) PAIR_CLASS_INIT(&tag[0], "lit"); @@ -1840,6 +1838,8 @@ mdoc_bf_pre(MDOC_ARGS) bufcat_su(h, "margin-left", &su); PAIR_STYLE_INIT(&tag[1], h); print_otag(h, TAG_DIV, 2, tag); + if (FONT_Em == n->norm->Bf.font) + print_otag(h, TAG_EM, 0, NULL); return(1); }