=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.73 retrieving revision 1.77 diff -u -p -r1.73 -r1.77 --- mandoc/mdoc_html.c 2010/06/04 21:05:39 1.73 +++ mandoc/mdoc_html.c 2010/06/06 10:50:56 1.77 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.73 2010/06/04 21:05:39 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.77 2010/06/06 10:50:56 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -1247,7 +1247,7 @@ mdoc_d1_pre(MDOC_ARGS) /* FIXME: D1 shouldn't be literal. */ - SCALE_VS_INIT(&su, INDENT - 1); + SCALE_VS_INIT(&su, INDENT - 2); bufcat_su(h, "margin-left", &su); PAIR_CLASS_INIT(&tag[0], "lit"); PAIR_STYLE_INIT(&tag[1], h); @@ -1563,8 +1563,8 @@ mdoc_ft_pre(MDOC_ARGS) { struct htmlpair tag; - if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) - print_otag(h, TAG_DIV, 0, NULL); + if (SEC_SYNOPSIS == n->sec && n->prev) + print_otag(h, TAG_BR, 0, NULL); PAIR_CLASS_INIT(&tag, "ftype"); print_otag(h, TAG_SPAN, 1, &tag); @@ -1584,15 +1584,16 @@ mdoc_fn_pre(MDOC_ARGS) int sz, i; struct roffsu su; - if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) { + /* NB: MDOC_LINE has no effect on this macro! */ + if (SEC_SYNOPSIS == n->sec) { SCALE_HS_INIT(&su, INDENT); bufcat_su(h, "margin-left", &su); su.scale = -su.scale; bufcat_su(h, "text-indent", &su); - if (n->next) { + if (n->prev && MDOC_Ft != n->prev->tok) { SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-bottom", &su); - } + bufcat_su(h, "margin-top", &su); + } PAIR_STYLE_INIT(&tag[0], h); print_otag(h, TAG_DIV, 1, tag); } @@ -1780,25 +1781,39 @@ mdoc_mt_pre(MDOC_ARGS) static int mdoc_fo_pre(MDOC_ARGS) { - struct htmlpair tag; - struct roffsu su; + struct htmlpair tag; + struct roffsu su; + struct tag *t; if (MDOC_BODY == n->type) { h->flags |= HTML_NOSPACE; print_text(h, "("); h->flags |= HTML_NOSPACE; return(1); - } else if (MDOC_BLOCK == n->type && n->next) { + } else if (MDOC_BLOCK == n->type) { + if (SEC_SYNOPSIS != n->sec) + return(1); + if (NULL == n->prev || MDOC_Ft == n->prev->tok) { + print_otag(h, TAG_DIV, 0, NULL); + return(1); + } SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-bottom", &su); + bufcat_su(h, "margin-top", &su); PAIR_STYLE_INIT(&tag, h); print_otag(h, TAG_DIV, 1, &tag); return(1); } + /* XXX: we drop non-initial arguments as per groff. */ + + assert(n->child); + assert(n->child->string); + PAIR_CLASS_INIT(&tag, "fname"); - print_otag(h, TAG_SPAN, 1, &tag); - return(1); + t = print_otag(h, TAG_SPAN, 1, &tag); + print_text(h, n->child->string); + print_tagq(h, t); + return(0); } @@ -1823,31 +1838,16 @@ mdoc_in_pre(MDOC_ARGS) struct tag *t; struct htmlpair tag[2]; int i; - struct roffsu su; - if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) { - if (n->next && MDOC_In != n->next->tok) { - SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-bottom", &su); - PAIR_STYLE_INIT(&tag[0], h); - print_otag(h, TAG_DIV, 1, tag); - } else - print_otag(h, TAG_DIV, 0, NULL); - } - - /* FIXME: there's a buffer bug in here somewhere. */ - PAIR_CLASS_INIT(&tag[0], "includes"); print_otag(h, TAG_SPAN, 1, tag); - if (SEC_SYNOPSIS == n->sec) + if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) print_text(h, "#include"); print_text(h, "<"); h->flags |= HTML_NOSPACE; - /* XXX -- see warning in termp_in_post(). */ - for (nn = n->child; nn; nn = nn->next) { PAIR_CLASS_INIT(&tag[0], "link-includes"); i = 1; @@ -1864,6 +1864,9 @@ mdoc_in_pre(MDOC_ARGS) h->flags |= HTML_NOSPACE; print_text(h, ">"); + + if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) + print_otag(h, TAG_BR, 0, NULL); return(0); }