From 81110a42d3e8acf54bd059afb29098770437d398 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 7 Jan 2019 07:26:29 +0000 Subject: Represent mdoc(7) .Pp (and .sp, and some SYNOPSIS and .Rs features) by the

HTML element and use the html_fillmode() mechanism for .Bd -unfilled, just like it was done for man(7) earlier, finally getting rid both of the horrible

hack and of the worst HTML syntax violations caused by nested displays. Care is needed because in some situations, paragraphs have to remain open across several subsequent macros, whereas in other situations, they must get closed together with a block containing them. Some implementation details include: * Always close paragraphs before emitting HTML flow content. * Let html_close_paragraph() also close
 for extra safety.
* Drop the old, now unused function print_paragraph().
* Minor adjustments in the top-level man(7) node formatter for symmetry.
* Bugfix: .Ss heads suspend no-fill mode, even though .Ss doesn't end it.
* Bugfix: give up on .Op semantic markup for now, see the comment.
---
 man_html.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

(limited to 'man_html.c')

diff --git a/man_html.c b/man_html.c
index 98ab2aae..8b4dd945 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/*	$Id: man_html.c,v 1.166 2019/01/06 04:55:09 schwarze Exp $ */
+/*	$Id: man_html.c,v 1.167 2019/01/07 07:26:29 schwarze Exp $ */
 /*
  * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons 
  * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze 
@@ -162,16 +162,22 @@ print_man_node(MAN_ARGS)
 	struct tag	*t;
 	int		 child;
 
+	if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
+		return;
+
 	html_fillmode(h, n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi);
 
 	child = 1;
+	t = h->tag;
+	if (t->tag == TAG_P || t->tag == TAG_PRE)
+		t = t->next;
+
 	switch (n->type) {
 	case ROFFT_TEXT:
 		if (*n->string == '\0') {
 			print_endline(h);
 			return;
 		}
-		t = h->tag;
 		if (*n->string == ' ' && n->flags & NODE_LINE &&
 		    (h->flags & HTML_NONEWLINE) == 0)
 			print_endline(h);
@@ -179,10 +185,7 @@ print_man_node(MAN_ARGS)
 			h->flags |= HTML_NOSPACE;
 		print_text(h, n->string);
 		break;
-	case ROFFT_COMMENT:
-		return;
 	case ROFFT_EQN:
-		t = h->tag;
 		print_eqn(h, n->eqn);
 		break;
 	case ROFFT_TBL:
@@ -208,17 +211,15 @@ print_man_node(MAN_ARGS)
 		 * the "meta" table state.  This will be reopened on the
 		 * next table element.
 		 */
-		if (h->tblt != NULL)
+		if (h->tblt != NULL) {
 			print_tblclose(h);
-
-		t = h->tag;
+			t = h->tag;
+		}
 		if (n->tok < ROFF_MAX) {
 			roff_html_pre(h, n);
-			if (n->tok != ROFF_sp)
-				print_stagq(h, t);
+			print_stagq(h, t);
 			return;
 		}
-
 		assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
 		if (man_html_acts[n->tok - MAN_TH].pre != NULL)
 			child = (*man_html_acts[n->tok - MAN_TH].pre)(man,
-- 
cgit v1.2.3-56-ge451