diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2019-01-07 07:26:29 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2019-01-07 07:26:29 +0000 |
commit | 81110a42d3e8acf54bd059afb29098770437d398 (patch) | |
tree | 80d9ed9a7d5b4f7cf2ef77c2240111757459966e /man_html.c | |
parent | 9b3bcfda2071ff49dd238b2315b1cc49c09a1552 (diff) | |
download | mandoc-81110a42d3e8acf54bd059afb29098770437d398.tar.gz mandoc-81110a42d3e8acf54bd059afb29098770437d398.tar.zst mandoc-81110a42d3e8acf54bd059afb29098770437d398.zip |
Represent mdoc(7) .Pp (and .sp, and some SYNOPSIS and .Rs features)
by the <p> HTML element and use the html_fillmode() mechanism
for .Bd -unfilled, just like it was done for man(7) earlier, finally
getting rid both of the horrible <div class="Pp"></div> hack and
of the worst HTML syntax violations caused by nested displays.
Care is needed because in some situations, paragraphs have to remain
open across several subsequent macros, whereas in other situations,
they must get closed together with a block containing them.
Some implementation details include:
* Always close paragraphs before emitting HTML flow content.
* Let html_close_paragraph() also close <pre> for extra safety.
* Drop the old, now unused function print_paragraph().
* Minor adjustments in the top-level man(7) node formatter for symmetry.
* Bugfix: .Ss heads suspend no-fill mode, even though .Ss doesn't end it.
* Bugfix: give up on .Op semantic markup for now, see the comment.
Diffstat (limited to 'man_html.c')
-rw-r--r-- | man_html.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.166 2019/01/06 04:55:09 schwarze Exp $ */ +/* $Id: man_html.c,v 1.167 2019/01/07 07:26:29 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -162,16 +162,22 @@ print_man_node(MAN_ARGS) struct tag *t; int child; + if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT) + return; + html_fillmode(h, n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi); child = 1; + t = h->tag; + if (t->tag == TAG_P || t->tag == TAG_PRE) + t = t->next; + switch (n->type) { case ROFFT_TEXT: if (*n->string == '\0') { print_endline(h); return; } - t = h->tag; if (*n->string == ' ' && n->flags & NODE_LINE && (h->flags & HTML_NONEWLINE) == 0) print_endline(h); @@ -179,10 +185,7 @@ print_man_node(MAN_ARGS) h->flags |= HTML_NOSPACE; print_text(h, n->string); break; - case ROFFT_COMMENT: - return; case ROFFT_EQN: - t = h->tag; print_eqn(h, n->eqn); break; case ROFFT_TBL: @@ -208,17 +211,15 @@ print_man_node(MAN_ARGS) * the "meta" table state. This will be reopened on the * next table element. */ - if (h->tblt != NULL) + if (h->tblt != NULL) { print_tblclose(h); - - t = h->tag; + t = h->tag; + } if (n->tok < ROFF_MAX) { roff_html_pre(h, n); - if (n->tok != ROFF_sp) - print_stagq(h, t); + print_stagq(h, t); return; } - assert(n->tok >= MAN_TH && n->tok < MAN_MAX); if (man_html_acts[n->tok - MAN_TH].pre != NULL) child = (*man_html_acts[n->tok - MAN_TH].pre)(man, |