=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.11 retrieving revision 1.15 diff -u -p -r1.11 -r1.15 --- mandoc/mdoc_html.c 2009/09/25 12:43:05 1.11 +++ mandoc/mdoc_html.c 2009/09/26 18:31:36 1.15 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.11 2009/09/25 12:43:05 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.15 2009/09/26 18:31:36 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -873,7 +873,8 @@ mdoc_bx_pre(MDOC_ARGS) static int mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int c) { - struct htmlpair tag; + struct htmlpair tag; + const struct mdoc_node *nn; switch (t) { case (MDOC_Column): @@ -889,10 +890,26 @@ mdoc_tbl_block_pre(MDOC_ARGS, int t, int w, int o, int } if ( ! c && MDOC_Column != t) { - if (n->prev && n->prev->body->child) - bufcat("padding-top: 1em;"); - else if (NULL == n->prev) - bufcat("padding-top: 1em;"); + for (nn = n; nn; nn = nn->parent) { + if (MDOC_BLOCK != nn->type) + continue; + switch (nn->tok) { + case (MDOC_Ss): + /* FALLTHROUGH */ + case (MDOC_Sh): + c = 1; + break; + default: + break; + } + if (nn->prev) + break; + } + if (MDOC_Diag == t && n->prev) + if (NULL == n->prev->body->child) + c = 1; + if ( ! c) + bufcat("padding-top: 1em;"); } tag.key = ATTR_STYLE; @@ -988,8 +1005,6 @@ mdoc_tbl_pre(MDOC_ARGS, int type) if (MDOC_BLOCK != n->type) bl = bl->parent; - /* FIXME: fmt_vspace() equivalent. */ - assert(bl->args); w = o = c = 0; @@ -1065,6 +1080,8 @@ mdoc_bl_pre(MDOC_ARGS) if (MDOC_Enum != a2list(n)) return(1); + /* Allocate an -enum on the stack of indices. */ + ord = malloc(sizeof(struct ord)); if (NULL == ord) err(EXIT_FAILURE, "malloc"); @@ -1310,10 +1327,8 @@ mdoc_bd_pre(MDOC_ARGS) { struct htmlpair tag[2]; int t, c, o, i; - const struct mdoc_node *bl; + const struct mdoc_node *bl, *nn; - /* FIXME: fmt_vspace() shit. */ - if (MDOC_BLOCK == n->type) bl = n; else if (MDOC_HEAD == n->type) @@ -1327,7 +1342,7 @@ mdoc_bd_pre(MDOC_ARGS) switch (bl->args->argv[i].arg) { case (MDOC_Offset): assert(bl->args->argv[i].sz); - o = a2offs (bl->args->argv[i].value[0]); + o = a2offs(bl->args->argv[i].value[0]); break; case (MDOC_Compact): c = 1; @@ -1346,20 +1361,33 @@ mdoc_bd_pre(MDOC_ARGS) if (MDOC_BLOCK == n->type) { if (o) buffmt("margin-left: %dem;", o); - bufcat("margin-top: 1em;"); + if ( ! c) { + for (nn = n; nn; nn = nn->parent) { + if (MDOC_BLOCK != nn->type) + continue; + switch (nn->tok) { + case (MDOC_Ss): + /* FALLTHROUGH */ + case (MDOC_Sh): + c = 1; + break; + default: + break; + } + if (nn->prev) + break; + } + if ( ! c) + bufcat("margin-top: 1em;"); + } tag[0].key = ATTR_STYLE; tag[0].val = buf; print_otag(h, TAG_DIV, 1, tag); return(1); } - switch (t) { - case (MDOC_Unfilled): - case (MDOC_Literal): - break; - default: + if (MDOC_Unfilled != t && MDOC_Literal != t) return(1); - } bufcat("white-space: pre;"); tag[0].key = ATTR_STYLE; @@ -1369,10 +1397,11 @@ mdoc_bd_pre(MDOC_ARGS) print_otag(h, TAG_DIV, 2, tag); - for (n = n->child; n; n = n->next) { - h->flags |= HTML_NOSPACE; - print_mdoc_node(m, n, h); - if (n->next) + for (nn = n->child; nn; nn = nn->next) { + print_mdoc_node(m, nn, h); + if (NULL == nn->next) + continue; + if (nn->prev && nn->prev->line < nn->line) print_text(h, "\n"); } @@ -1574,30 +1603,31 @@ static int mdoc_fn_pre(MDOC_ARGS) { struct tag *t; - struct htmlpair tag; + struct htmlpair tag[2]; const struct mdoc_node *nn; char nbuf[BUFSIZ]; const char *sp, *ep; - int sz; + int sz, i; if (SEC_SYNOPSIS == n->sec) { - if (n->next) { - tag.key = ATTR_STYLE; - tag.val = "margin-bottom: 1em"; - print_otag(h, TAG_DIV, 1, &tag); - } else - print_otag(h, TAG_DIV, 0, NULL); + bufcat("margin-left: 6em;"); + bufcat("text-indent: -6em;"); + if (n->next) + bufcat("margin-bottom: 1em;"); + tag[0].key = ATTR_STYLE; + tag[0].val = buf; + print_otag(h, TAG_DIV, 1, tag); } /* Split apart into type and name. */ - tag.key = ATTR_CLASS; - tag.val = "ftype"; - t = print_otag(h, TAG_SPAN, 1, &tag); + tag[0].key = ATTR_CLASS; + tag[0].val = "ftype"; + t = print_otag(h, TAG_SPAN, 1, tag); assert(n->child->string); sp = n->child->string; - while ((ep = strchr(sp, ' '))) { + while (NULL != (ep = strchr(sp, ' '))) { sz = MIN((int)(ep - sp), BUFSIZ - 1); (void)memcpy(nbuf, sp, (size_t)sz); nbuf[sz] = '\0'; @@ -1607,9 +1637,9 @@ mdoc_fn_pre(MDOC_ARGS) print_tagq(h, t); - tag.key = ATTR_CLASS; - tag.val = "fname"; - t = print_otag(h, TAG_SPAN, 1, &tag); + tag[0].key = ATTR_CLASS; + tag[0].val = "fname"; + t = print_otag(h, TAG_SPAN, 1, tag); if (sp) { (void)strlcpy(nbuf, sp, BUFSIZ); @@ -1622,9 +1652,15 @@ mdoc_fn_pre(MDOC_ARGS) print_text(h, "("); for (nn = n->child->next; nn; nn = nn->next) { - tag.key = ATTR_CLASS; - tag.val = "farg"; - t = print_otag(h, TAG_SPAN, 1, &tag); + i = 0; + tag[i].key = ATTR_CLASS; + tag[i++].val = "farg"; + if (SEC_SYNOPSIS == n->sec) { + tag[i].key = ATTR_STYLE; + tag[i++].val = "white-space: nowrap;"; + } + + t = print_otag(h, TAG_SPAN, i, tag); print_text(h, nn->string); print_tagq(h, t); if (nn->next)