diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-25 02:14:43 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-25 02:14:43 +0000 |
commit | 75f0aa87c57b152c84c7f856cb1ab705769c6478 (patch) | |
tree | bdc6aeee5b3f0315cb57f4964f4d43ac809aafb9 /mdoc_html.c | |
parent | 2678c5ab0377c06b6806c2fafd2df37e3c7d23c7 (diff) | |
download | mandoc-75f0aa87c57b152c84c7f856cb1ab705769c6478.tar.gz |
Improve HTML formatting of .Bl -tag.
In particular, when using the style sheet, put the body on the same
line as the head for short heads, or on the next line for long
heads, in a way that preserves both correct indentation and correct
vertical spacing with and without -compact, and with one or more
heads per body (hi, Zaphod) - eight use cases so far - and with and
without -tag, and with and without -offset, 32 use cases grand total.
Using many ideas from zhuk@, from <David dot Dahlberg at fkie dot
fraunhofer dot de>, and from Benny Lofgren <bl dash lists at lofgren
dot biz>, and a few of my own.
This is an excellent demonstration that CSS is an extremely hostile
language, much more trapful and much harder to use than, say, C.
When matthew@ reported this in July 2014 (!), it was already a known
issue, and i no longer remember for how long. My first serious
attempt at fixing it (in November 2015) failed miserably. I'd love
to see simplifications of both the generated HTML code and of the
style sheet, but without breaking any of the 32 use cases, please.
Diffstat (limited to 'mdoc_html.c')
-rw-r--r-- | mdoc_html.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/mdoc_html.c b/mdoc_html.c index a09f2f42..e5ac0a2c 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -671,6 +671,7 @@ static int mdoc_it_pre(MDOC_ARGS) { const struct roff_node *bl; + struct tag *t; const char *cattr; enum mdoc_list type; @@ -738,7 +739,6 @@ mdoc_it_pre(MDOC_ARGS) case LIST_hang: case LIST_inset: case LIST_ohang: - case LIST_tag: switch (n->type) { case ROFFT_HEAD: if (bl->norm->Bl.comp) @@ -759,6 +759,41 @@ mdoc_it_pre(MDOC_ARGS) break; } break; + case LIST_tag: + switch (n->type) { + case ROFFT_HEAD: + if (h->style != NULL && !bl->norm->Bl.comp && + (n->parent->prev == NULL || + n->parent->prev->body->child != NULL)) { + if (bl->norm->Bl.width == NULL) + t = print_otag(h, TAG_DT, "c", cattr); + else + t = print_otag(h, TAG_DT, "csWl", + cattr, bl->norm->Bl.width); + print_text(h, "\\ "); + print_tagq(h, t); + t = print_otag(h, TAG_DD, "c", cattr); + print_text(h, "\\ "); + print_tagq(h, t); + } + if (bl->norm->Bl.width == NULL) + print_otag(h, TAG_DT, "c", cattr); + else + print_otag(h, TAG_DT, "csWl", cattr, + bl->norm->Bl.width); + break; + case ROFFT_BODY: + if (n->child == NULL) { + print_otag(h, TAG_DD, "css?", cattr, + "width", "auto"); + print_text(h, "\\ "); + } else + print_otag(h, TAG_DD, "c", cattr); + break; + default: + break; + } + break; case LIST_column: switch (n->type) { case ROFFT_HEAD: @@ -845,9 +880,16 @@ mdoc_bl_pre(MDOC_ARGS) cattr = "Bl-ohang"; break; case LIST_tag: - elemtype = TAG_DL; cattr = "Bl-tag"; - break; + if (n->norm->Bl.offs) + print_otag(h, TAG_DIV, "cswl", cattr, + n->norm->Bl.offs); + if (n->norm->Bl.width == NULL) + print_otag(h, TAG_DL, "c", cattr); + else + print_otag(h, TAG_DL, "cswl", cattr, + n->norm->Bl.width); + return 1; case LIST_column: elemtype = TAG_TABLE; cattr = "Bl-column"; |