diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-09-03 12:03:06 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-09-03 12:03:06 +0000 |
commit | 4649f2bfb93371840f045064e3d09c0bfd419eb3 (patch) | |
tree | ca307451e6c6c9ddf476a6702f5a9d7351f697de /usr.bin/mandoc/html.c | |
parent | 57abe288969510702f216bf08cd205070a8ba17f (diff) |
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 'usr.bin/mandoc/html.c')
-rw-r--r-- | usr.bin/mandoc/html.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c index 88e0a3e4338..b8f39a459d6 100644 --- a/usr.bin/mandoc/html.c +++ b/usr.bin/mandoc/html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: html.c,v 1.128 2019/09/01 15:12:03 schwarze Exp $ */ +/* $OpenBSD: html.c,v 1.129 2019/09/03 12:03:05 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -269,21 +269,17 @@ print_metaf(struct html *h) void html_close_paragraph(struct html *h) { - struct tag *t; + struct tag *this, *next; - 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; + if (htmltags[this->tag].flags & + (HTML_INPHRASE | HTML_TOPHRASE)) + print_ctag(h, this); + if ((htmltags[this->tag].flags & HTML_INPHRASE) == 0) break; - case TAG_A: - print_tagq(h, t); - continue; - default: - continue; - } - break; + this = next; } } |