=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.115 retrieving revision 1.119 diff -u -p -r1.115 -r1.119 --- mandoc/mdoc_html.c 2010/12/15 14:52:16 1.115 +++ mandoc/mdoc_html.c 2010/12/15 16:35:21 1.119 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.115 2010/12/15 14:52:16 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.119 2010/12/15 16:35:21 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -246,13 +246,13 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { static const char * const lists[LIST_MAX] = { NULL, - "list-bullet", - "list-column", + "list-bul", + "list-col", "list-dash", "list-diag", "list-enum", "list-hang", - "list-hyphen", + "list-hyph", "list-inset", "list-item", "list-ohang", @@ -369,18 +369,12 @@ static void print_mdoc(MDOC_ARGS) { struct tag *t; - struct htmlpair tag; t = print_otag(h, TAG_HEAD, 0, NULL); print_mdoc_head(m, n, h); print_tagq(h, t); t = print_otag(h, TAG_BODY, 0, NULL); - - tag.key = ATTR_CLASS; - tag.val = "body"; - print_otag(h, TAG_DIV, 1, &tag); - print_mdoc_nodelist(m, n, h); print_tagq(h, t); } @@ -479,12 +473,6 @@ mdoc_root_post(MDOC_ARGS) time2a(m->date, b, DATESIZ); - /* - * XXX: this should use divs, but in Firefox, divs with nested - * divs for some reason puke when trying to put a border line - * below. So I use tables, instead. - */ - PAIR_CLASS_INIT(&tag[0], "footer"); bufcat_style(h, "width", "100%"); PAIR_STYLE_INIT(&tag[1], h); @@ -518,19 +506,16 @@ mdoc_root_pre(MDOC_ARGS) struct tag *t, *tt; char b[BUFSIZ], title[BUFSIZ]; - (void)strlcpy(b, m->vol, BUFSIZ); + strlcpy(b, m->vol, BUFSIZ); if (m->arch) { - (void)strlcat(b, " (", BUFSIZ); - (void)strlcat(b, m->arch, BUFSIZ); - (void)strlcat(b, ")", BUFSIZ); + strlcat(b, " (", BUFSIZ); + strlcat(b, m->arch, BUFSIZ); + strlcat(b, ")", BUFSIZ); } - (void)snprintf(title, BUFSIZ - 1, - "%s(%s)", m->title, m->msec); + snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec); - /* XXX: see note in mdoc_root_post() about divs. */ - PAIR_CLASS_INIT(&tag[0], "header"); bufcat_style(h, "width", "100%"); PAIR_STYLE_INIT(&tag[1], h); @@ -903,7 +888,7 @@ mdoc_it_pre(MDOC_ARGS) { struct roffsu su; enum mdoc_list type; - struct htmlpair tag; + struct htmlpair tag[2]; const struct mdoc_node *bl; bl = n->parent; @@ -914,11 +899,12 @@ mdoc_it_pre(MDOC_ARGS) type = bl->data.Bl->type; - /* Whether we're top-padded (not "compact"). */ + assert(lists[type]); + PAIR_CLASS_INIT(&tag[0], lists[type]); SCALE_VS_INIT(&su, ! bl->data.Bl->comp); bufcat_su(h, "margin-top", &su); - PAIR_STYLE_INIT(&tag, h); + PAIR_STYLE_INIT(&tag[1], h); if (MDOC_HEAD == n->type) { switch (type) { @@ -941,7 +927,7 @@ mdoc_it_pre(MDOC_ARGS) case(LIST_ohang): /* FALLTHROUGH */ case(LIST_tag): - print_otag(h, TAG_DT, 1, &tag); + print_otag(h, TAG_DT, 2, tag); break; case(LIST_column): break; @@ -960,7 +946,7 @@ mdoc_it_pre(MDOC_ARGS) /* FALLTHROUGH */ case(LIST_item): /* FALLTHROUGH */ - print_otag(h, TAG_LI, 1, &tag); + print_otag(h, TAG_LI, 2, tag); break; case(LIST_diag): /* FALLTHROUGH */ @@ -971,10 +957,10 @@ mdoc_it_pre(MDOC_ARGS) case(LIST_ohang): /* FALLTHROUGH */ case(LIST_tag): - print_otag(h, TAG_DD, 0, NULL); + print_otag(h, TAG_DD, 1, tag); break; case(LIST_column): - print_otag(h, TAG_TD, 1, &tag); + print_otag(h, TAG_TD, 2, tag); break; default: break; @@ -982,7 +968,7 @@ mdoc_it_pre(MDOC_ARGS) } else { switch (type) { case (LIST_column): - print_otag(h, TAG_TR, 0, NULL); + print_otag(h, TAG_TR, 1, tag); break; default: break; @@ -997,7 +983,7 @@ static int mdoc_bl_pre(MDOC_ARGS) { size_t i; - struct htmlpair tag[2]; + struct htmlpair tag[3]; struct roffsu su; if (MDOC_BODY == n->type) { @@ -1031,18 +1017,22 @@ mdoc_bl_pre(MDOC_ARGS) return(0); } + SCALE_VS_INIT(&su, 0); + bufcat_su(h, "margin-top", &su); + bufcat_su(h, "margin-bottom", &su); + PAIR_STYLE_INIT(&tag[0], h); + assert(lists[n->data.Bl->type]); - PAIR_CLASS_INIT(&tag[0], lists[n->data.Bl->type]); - i = 1; + PAIR_CLASS_INIT(&tag[1], lists[n->data.Bl->type]); + i = 2; /* Set the block's left-hand margin. */ if (n->data.Bl->offs) { a2offs(n->data.Bl->offs, &su); bufcat_su(h, "margin-left", &su); - PAIR_STYLE_INIT(&tag[1], h); - i = 2; - + PAIR_STYLE_INIT(&tag[2], h); + i = 3; } switch (n->data.Bl->type) { @@ -1138,13 +1128,17 @@ mdoc_d1_pre(MDOC_ARGS) if (MDOC_BLOCK != n->type) return(1); - /* FIXME: D1 shouldn't be literal. */ + SCALE_VS_INIT(&su, 0); + bufcat_su(h, "margin-top", &su); + bufcat_su(h, "margin-bottom", &su); + PAIR_STYLE_INIT(&tag[0], h); - SCALE_VS_INIT(&su, INDENT - 2); - bufcat_su(h, "margin-left", &su); - PAIR_CLASS_INIT(&tag[0], "lit"); - PAIR_STYLE_INIT(&tag[1], h); - print_otag(h, TAG_DIV, 2, tag); + if (MDOC_Dl == n->tok) { + PAIR_CLASS_INIT(&tag[1], "lit"); + print_otag(h, TAG_BLOCKQUOTE, 2, tag); + } else + print_otag(h, TAG_BLOCKQUOTE, 1, tag); + return(1); }