From 7f36e58ef077e2bf3ff4592144b6be7ccc0db8de Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 16 Oct 2020 17:22:43 +0000 Subject: In HTML output, avoid printing a newline right after
 and right
 before 
because that resulted in vertical whitespace not requested by the manual page author. Formatting bug reported by Aman Verma on discuss@. --- html.c | 4 ++-- man_html.c | 16 +++++++-------- mdoc_html.c | 11 +++++----- regress/man/HP/literal.out_html | 18 ++++++---------- regress/man/IP/literal.out_html | 42 +++++++++++++------------------------- regress/man/RS/literal.out_html | 18 ++++++---------- regress/man/SY/literal.out_html | 16 +++++---------- regress/man/TP/literal.out_html | 18 ++++++---------- regress/mdoc/Bd/nf.out_html | 18 ++++++---------- regress/mdoc/Bd/paragraph.out_html | 6 ++---- regress/mdoc/Rs/paragraph.out_html | 1 - regress/roff/sp/fill-man.out_html | 6 ++---- regress/roff/string/dotT.out_html | 1 - 13 files changed, 61 insertions(+), 114 deletions(-) diff --git a/html.c b/html.c index 8b7937a5..0096c2db 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.270 2020/04/20 13:07:24 schwarze Exp $ */ +/* $Id: html.c,v 1.271 2020/10/16 17:22:43 schwarze Exp $ */ /* * Copyright (c) 2011-2015, 2017-2020 Ingo Schwarze * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons @@ -81,7 +81,7 @@ static const struct htmldata htmltags[TAG_MAX] = { {"h1", HTML_TOPHRASE | HTML_NLAROUND}, {"h2", HTML_TOPHRASE | HTML_NLAROUND}, {"p", HTML_TOPHRASE | HTML_NLAROUND | HTML_INDENT}, - {"pre", HTML_TOPHRASE | HTML_NLALL | HTML_NOINDENT}, + {"pre", HTML_TOPHRASE | HTML_NLAROUND | HTML_NOINDENT}, {"a", HTML_INPHRASE | HTML_TOPHRASE}, {"b", HTML_INPHRASE | HTML_TOPHRASE}, {"cite", HTML_INPHRASE | HTML_TOPHRASE}, diff --git a/man_html.c b/man_html.c index 80f69e1a..147c20e4 100644 --- a/man_html.c +++ b/man_html.c @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.178 2020/04/04 20:33:33 schwarze Exp $ */ +/* $Id: man_html.c,v 1.179 2020/10/16 17:22:43 schwarze Exp $ */ /* * Copyright (c) 2013-2015, 2017-2020 Ingo Schwarze * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons @@ -169,7 +169,12 @@ print_man_node(MAN_ARGS) if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT) return; - html_fillmode(h, n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi); + if ((n->flags & NODE_NOFILL) == 0) + html_fillmode(h, ROFF_fi); + else if (html_fillmode(h, ROFF_nf) == ROFF_nf && + n->tok != ROFF_fi && n->flags & NODE_LINE && + (n->prev == NULL || n->prev->tok != MAN_YS)) + print_endline(h); child = 1; switch (n->type) { @@ -253,13 +258,6 @@ print_man_node(MAN_ARGS) } if (t != NULL) print_stagq(h, t); - - if (n->flags & NODE_NOFILL && n->tok != MAN_YS && - (n->next != NULL && n->next->flags & NODE_LINE)) { - /* In .nf =
, print even empty lines. */
-		h->col++;
-		print_endline(h);
-	}
 }
 
 static void
diff --git a/mdoc_html.c b/mdoc_html.c
index d96df6df..0569255b 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.340 2020/04/19 15:16:56 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.341 2020/10/16 17:22:43 schwarze Exp $ */
 /*
  * Copyright (c) 2014-2020 Ingo Schwarze 
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons 
@@ -349,12 +349,11 @@ print_mdoc_node(MDOC_ARGS)
 	if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
 		return;
 
-	if (n->flags & NODE_NOFILL) {
-		html_fillmode(h, ROFF_nf);
-		if (n->flags & NODE_LINE)
-			print_endline(h);
-	} else
+	if ((n->flags & NODE_NOFILL) == 0)
 		html_fillmode(h, ROFF_fi);
+	else if (html_fillmode(h, ROFF_nf) == ROFF_nf &&
+	    n->tok != ROFF_fi && n->flags & NODE_LINE)
+		print_endline(h);
 
 	child = 1;
 	n->flags &= ~NODE_ENDED;
diff --git a/regress/man/HP/literal.out_html b/regress/man/HP/literal.out_html
index 08fb26b9..48089e36 100644
--- a/regress/man/HP/literal.out_html
+++ b/regress/man/HP/literal.out_html
@@ -1,18 +1,12 @@
 

tag indented text

regular paragraph

-
-literal
-text
-
-
-tag
+
literal
+text
+
tag
 literal
 hanged
-paragraph
-
-
-literal
-paragraph
-
+paragraph
+
literal
+paragraph
regular text
diff --git a/regress/man/IP/literal.out_html b/regress/man/IP/literal.out_html index aa0536e7..ceb26a56 100644 --- a/regress/man/IP/literal.out_html +++ b/regress/man/IP/literal.out_html @@ -3,42 +3,32 @@
indented regular text

new regular paragraph

-
-literal
-text
-
+
literal
+text
-
-indented
+    
indented
 literal
-text
-    
+text
-
-new
+
new
 literal
-paragraph
-
+paragraph
regular text

regular text

-
-literal
-text
-
+
literal
+text
-
-indented
+    
indented
 literal
-text
-    
+text
indented regular text

new regular paragraph

@@ -50,17 +40,13 @@ text
indented regular text -
-indented
+    
indented
 literal
-text
-    
+text
-
-new
+
new
 literal
-paragraph
-
+paragraph
regular text
diff --git a/regress/man/RS/literal.out_html b/regress/man/RS/literal.out_html index 7bd5431b..3429d849 100644 --- a/regress/man/RS/literal.out_html +++ b/regress/man/RS/literal.out_html @@ -1,18 +1,12 @@
initial regular text

-
-literal text
-before display
-
+
literal text
+before display
-
-This is a short line.
-This is a very long line that would wrap if it weren't in literal context.
-
+
This is a short line.
+This is a very long line that would wrap if it weren't in literal context.
-
-literal text
-after display
-
+
literal text
+after display

final regular text
diff --git a/regress/man/SY/literal.out_html b/regress/man/SY/literal.out_html index 9b3e8486..3d63b516 100644 --- a/regress/man/SY/literal.out_html +++ b/regress/man/SY/literal.out_html @@ -7,23 +7,17 @@ middle regular text -

-literal text
-before display
-
+
literal text
+before display
command -
-arguments
-    
+
arguments
-
-literal text
-after display
-
+
literal text
+after display

final regular text
diff --git a/regress/man/TP/literal.out_html b/regress/man/TP/literal.out_html index 914c7b5c..71194770 100644 --- a/regress/man/TP/literal.out_html +++ b/regress/man/TP/literal.out_html @@ -3,23 +3,17 @@

regular indented text

regular paragraph

-
-literal
-text
-
+
literal
+text
-
-indented
+    
indented
 literal
-text
-    
+text
-
-literal
-paragraph
-
+
literal
+paragraph
regular text
diff --git a/regress/mdoc/Bd/nf.out_html b/regress/mdoc/Bd/nf.out_html index 394eb7ed..83083353 100644 --- a/regress/mdoc/Bd/nf.out_html +++ b/regress/mdoc/Bd/nf.out_html @@ -1,20 +1,14 @@ -
-after .nf
-request
-
+
after .nf
+request

after .fi request

-
-in unfilled
-block
-
+
in unfilled
+block
after .fi request in unfilled block
after end of unfilled block
in filled block -
-after .nf request
-in filled block
-
+
after .nf request
+in filled block
after end of filled block
diff --git a/regress/mdoc/Bd/paragraph.out_html b/regress/mdoc/Bd/paragraph.out_html index cc3491c9..22355ed1 100644 --- a/regress/mdoc/Bd/paragraph.out_html +++ b/regress/mdoc/Bd/paragraph.out_html @@ -8,13 +8,11 @@ back to normal

another paragraph

-
- literal
+
 literal
 display
 
  literal
-paragraph
-
+paragraph
again back to normal
diff --git a/regress/mdoc/Rs/paragraph.out_html b/regress/mdoc/Rs/paragraph.out_html index ba5fb63a..bfb0a724 100644 --- a/regress/mdoc/Rs/paragraph.out_html +++ b/regress/mdoc/Rs/paragraph.out_html @@ -13,4 +13,3 @@

in a paragraph:

another author, another book.

-
diff --git a/regress/roff/sp/fill-man.out_html b/regress/roff/sp/fill-man.out_html
index 054b6359..213d4601 100644
--- a/regress/roff/sp/fill-man.out_html
+++ b/regress/roff/sp/fill-man.out_html
@@ -1,7 +1,5 @@
 

switch to no-fill mode:

-
-in no-fill mode:
+
in no-fill mode:
 
 back to
-fill mode:
-
+fill mode:
diff --git a/regress/roff/string/dotT.out_html b/regress/roff/string/dotT.out_html index 0a019b20..51ab1411 100644 --- a/regress/roff/string/dotT.out_html +++ b/regress/roff/string/dotT.out_html @@ -1,3 +1,2 @@

We are using the html device.

The device name can be overridden.

-
-- 
cgit v1.2.3-56-ge451