diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2019-09-03 12:31:05 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2019-09-03 12:31:05 +0000 |
commit | 1554c3f90875f1f80fbb816938aa0e3b93421e43 (patch) | |
tree | 9dc4561131fdd8b707415f58a4c6fe3f97f61aab /html.c | |
parent | c306146247f4b042c4cd1219c55d103cfbf26f20 (diff) | |
download | mandoc-1554c3f90875f1f80fbb816938aa0e3b93421e43.tar.gz |
Make html_close_paragraph() more versatile, more robust, less
dependent on individual HTML elements, and simpler: don't just close
<p>, <pre>, and <a>, but any element that establishes phrasing
context. This doesn't change output for any OpenBSD manual page,
but it will allow using this function more safely and at more places
in the future.
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -271,21 +271,18 @@ print_metaf(struct html *h) void html_close_paragraph(struct html *h) { - struct tag *t; + struct tag *this, *next; + int flags; - for (t = h->tag; t != NULL && t->closed == 0; t = t->next) { - switch(t->tag) { - case TAG_P: - case TAG_PRE: - print_tagq(h, t); + this = h->tag; + for (;;) { + next = this->next; + flags = htmltags[this->tag].flags; + if (flags & (HTML_INPHRASE | HTML_TOPHRASE)) + print_ctag(h, this); + if ((flags & HTML_INPHRASE) == 0) break; - case TAG_A: - print_tagq(h, t); - continue; - default: - continue; - } - break; + this = next; } } |