=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.125 retrieving revision 1.131 diff -u -p -r1.125 -r1.131 --- mandoc/mdoc_html.c 2010/12/17 08:17:40 1.125 +++ mandoc/mdoc_html.c 2010/12/19 12:14:36 1.131 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.125 2010/12/17 08:17:40 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.131 2010/12/19 12:14:36 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -287,7 +287,7 @@ a2width(const char *p, struct roffsu *su) { if ( ! a2roffsu(p, su, SCALE_MAX)) { - su->unit = SCALE_EM; + su->unit = SCALE_BU; su->scale = (int)strlen(p); } } @@ -354,7 +354,7 @@ a2offs(const char *p, struct roffsu *su) else if (0 == strcmp(p, "indent-two")) SCALE_HS_INIT(su, INDENT * 2); else if ( ! a2roffsu(p, su, SCALE_MAX)) { - su->unit = SCALE_EM; + su->unit = SCALE_BU; su->scale = (int)strlen(p); } } @@ -945,7 +945,10 @@ mdoc_bl_pre(MDOC_ARGS) PAIR_STYLE_INIT(&tag[0], h); assert(lists[n->data.Bl->type]); - PAIR_CLASS_INIT(&tag[1], lists[n->data.Bl->type]); + bufinit(h); + bufcat(h, "list "); + bufcat(h, lists[n->data.Bl->type]); + PAIR_INIT(&tag[1], ATTR_CLASS, h->buf); i = 2; /* Set the block's left-hand margin. */ @@ -1000,6 +1003,9 @@ mdoc_ex_pre(MDOC_ARGS) struct tag *t; struct htmlpair tag; + if (n->prev) + print_otag(h, TAG_BR, 0, NULL); + PAIR_CLASS_INIT(&tag, "utility"); print_text(h, "The"); @@ -1058,12 +1064,12 @@ mdoc_d1_pre(MDOC_ARGS) /* BLOCKQUOTE needs a block body. */ - if (MDOC_Dl == n->tok) { - PAIR_CLASS_INIT(&tag[1], "lit"); - print_otag(h, TAG_DIV, 1, tag); - } else - print_otag(h, TAG_DIV, 0, tag); + if (MDOC_Dl == n->tok) + PAIR_CLASS_INIT(&tag[0], "lit display"); + else + PAIR_CLASS_INIT(&tag[0], "display"); + print_otag(h, TAG_DIV, 1, tag); return(1); } @@ -1103,19 +1109,8 @@ mdoc_bd_pre(MDOC_ARGS) if (MDOC_HEAD == n->type) return(0); - SCALE_VS_INIT(&su, 0); - - assert(n->data.Bd); - if (n->data.Bd->offs) - a2offs(n->data.Bd->offs, &su); - - comp = n->data.Bd->comp; - - /* FIXME: -centered, etc. formatting. */ - /* FIXME: does not respect -offset ??? */ - if (MDOC_BLOCK == n->type) { - bufcat_su(h, "margin-left", &su); + comp = n->data.Bd->comp; for (nn = n; nn && ! comp; nn = nn->parent) { if (MDOC_BLOCK != nn->type) continue; @@ -1124,26 +1119,27 @@ mdoc_bd_pre(MDOC_ARGS) if (nn->prev) break; } - if (comp) { - PAIR_STYLE_INIT(&tag[0], h); - print_otag(h, TAG_DIV, 1, tag); - return(1); - } - SCALE_VS_INIT(&su, 1); - bufcat_su(h, "margin-top", &su); - PAIR_STYLE_INIT(&tag[0], h); - print_otag(h, TAG_DIV, 1, tag); + if ( ! comp) + print_otag(h, TAG_P, 0, NULL); return(1); } + SCALE_HS_INIT(&su, 0); + if (n->data.Bd->offs) + a2offs(n->data.Bd->offs, &su); + + bufcat_su(h, "margin-left", &su); + PAIR_STYLE_INIT(&tag[0], h); + if (DISP_unfilled != n->data.Bd->type && - DISP_literal != n->data.Bd->type) + DISP_literal != n->data.Bd->type) { + PAIR_CLASS_INIT(&tag[1], "display"); + print_otag(h, TAG_DIV, 2, tag); return(1); + } - PAIR_CLASS_INIT(&tag[0], "lit"); - bufcat_style(h, "white-space", "pre"); - PAIR_STYLE_INIT(&tag[1], h); - print_otag(h, TAG_DIV, 2, tag); + PAIR_CLASS_INIT(&tag[1], "lit display"); + print_otag(h, TAG_PRE, 2, tag); for (nn = n->child; nn; nn = nn->next) { print_mdoc_node(m, nn, h); @@ -1175,8 +1171,9 @@ mdoc_bd_pre(MDOC_ARGS) } if (nn->next && nn->next->line == nn->line) continue; + else if (nn->next) + print_text(h, "\n"); - print_text(h, "\n"); h->flags |= HTML_NOSPACE; } @@ -1645,7 +1642,9 @@ mdoc_rv_pre(MDOC_ARGS) struct htmlpair tag; struct tag *t; - print_otag(h, TAG_DIV, 0, NULL); + if (n->prev) + print_otag(h, TAG_BR, 0, NULL); + print_text(h, "The"); for (nn = n->child; nn; nn = nn->next) { @@ -1841,8 +1840,9 @@ mdoc_lb_pre(MDOC_ARGS) { struct htmlpair tag; - if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags) - print_otag(h, TAG_DIV, 0, NULL); + if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags && n->prev) + print_otag(h, TAG_BR, 0, NULL); + PAIR_CLASS_INIT(&tag, "lib"); print_otag(h, TAG_SPAN, 1, &tag); return(1); @@ -1948,7 +1948,8 @@ mdoc_bk_pre(MDOC_ARGS) case (MDOC_HEAD): return(0); case (MDOC_BODY): - h->flags |= HTML_PREKEEP; + if (n->parent->args || 0 == n->prev->nchild) + h->flags |= HTML_PREKEEP; break; default: abort();