From 86b0169f43d17f57d4eaad30937f9c1948200884 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 3 Sep 2019 12:31:05 +0000 Subject: Make html_close_paragraph() more versatile, more robust, less dependent on individual HTML elements, and simpler: don't just close

,

, and , 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.

---
 html.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

(limited to 'html.c')

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 
  * Copyright (c) 2011-2015, 2017-2019 Ingo Schwarze 
@@ -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;
 	}
 }
 
-- 
cgit v1.2.3