aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit86b0169f43d17f57d4eaad30937f9c1948200884 (patch)
tree1a6d527d4a842d4dbae33a919e61d4067324fd63
parentcbdb02c169520201c5b9e366dd5e61cc778b9ad7 (diff)
downloadmandoc-86b0169f43d17f57d4eaad30937f9c1948200884.tar.gz
mandoc-86b0169f43d17f57d4eaad30937f9c1948200884.tar.zst
mandoc-86b0169f43d17f57d4eaad30937f9c1948200884.zip
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.
-rw-r--r--html.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/html.c b/html.c
index 7f8ca02d..b7db8fdd 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.258 2019/09/01 15:12:19 schwarze Exp $ */
+/* $Id: html.c,v 1.259 2019/09/03 12:31:05 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;
}
}