summaryrefslogtreecommitdiffstats
path: root/html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-09-03 12:31:05 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-09-03 12:31:05 +0000
commit1554c3f90875f1f80fbb816938aa0e3b93421e43 (patch)
tree9dc4561131fdd8b707415f58a4c6fe3f97f61aab /html.c
parentc306146247f4b042c4cd1219c55d103cfbf26f20 (diff)
downloadmandoc-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.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/html.c b/html.c
index d7204e82..2a5f80d6 100644
--- a/html.c
+++ b/html.c
@@ -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;
}
}