diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2020-10-16 17:22:41 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2020-10-16 17:22:41 +0000 |
commit | de41bd77987c4f878a7d4e7cbcab00dcf7de095c (patch) | |
tree | 45bcbb84c0d4e672eeb63b43ca8d7b8c2700639e | |
parent | 3a705fad114fbe296980921ecf319911949c685b (diff) |
In HTML output, avoid printing a newline right after <pre>
and right before </pre> because that resulted in vertical
whitespace not requested by the manual page author.
Formatting bug reported by
Aman Verma <amanraoverma plus vim at gmail dot com> on discuss@.
-rw-r--r-- | regress/usr.bin/mandoc/man/HP/literal.out_html | 18 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/IP/literal.out_html | 42 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/RS/literal.out_html | 18 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/SY/literal.out_html | 16 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/TP/literal.out_html | 18 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bd/nf.out_html | 18 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html | 6 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html | 1 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/roff/sp/fill-man.out_html | 6 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/roff/string/dotT.out_html | 1 | ||||
-rw-r--r-- | usr.bin/mandoc/html.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/man_html.c | 16 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 11 |
13 files changed, 61 insertions, 114 deletions
diff --git a/regress/usr.bin/mandoc/man/HP/literal.out_html b/regress/usr.bin/mandoc/man/HP/literal.out_html index 08fb26b96f9..48089e36ba7 100644 --- a/regress/usr.bin/mandoc/man/HP/literal.out_html +++ b/regress/usr.bin/mandoc/man/HP/literal.out_html @@ -1,18 +1,12 @@ <p class="Pp HP">tag indented text</p> <p class="Pp">regular paragraph</p> -<pre> -literal -text -</pre> -<pre> -tag +<pre>literal +text</pre> +<pre>tag literal hanged -paragraph -</pre> -<pre> -literal -paragraph -</pre> +paragraph</pre> +<pre>literal +paragraph</pre> regular text <br/> diff --git a/regress/usr.bin/mandoc/man/IP/literal.out_html b/regress/usr.bin/mandoc/man/IP/literal.out_html index aa0536e795c..ceb26a561ec 100644 --- a/regress/usr.bin/mandoc/man/IP/literal.out_html +++ b/regress/usr.bin/mandoc/man/IP/literal.out_html @@ -3,42 +3,32 @@ <dd>indented regular text</dd> </dl> <p class="Pp">new regular paragraph</p> -<pre> -literal -text -</pre> +<pre>literal +text</pre> <dl class="Bl-tag"> <dt id="tag~2"><a class="permalink" href="#tag~2">tag</a></dt> <dd> - <pre> -indented + <pre>indented literal -text - </pre> +text</pre> </dd> </dl> -<pre> -new +<pre>new literal -paragraph -</pre> +paragraph</pre> regular text <section class="Ss"> <h2 class="Ss" id="literal_into_indented_paragraph"><a class="permalink" href="#literal_into_indented_paragraph">literal into indented paragraph</a></h2> <p class="Pp">regular text</p> -<pre> -literal -text -</pre> +<pre>literal +text</pre> <dl class="Bl-tag"> <dt id="tag~3"><a class="permalink" href="#tag~3">tag</a></dt> <dd> - <pre> -indented + <pre>indented literal -text - </pre> +text</pre> indented regular text</dd> </dl> <p class="Pp">new regular paragraph</p> @@ -50,17 +40,13 @@ text <dl class="Bl-tag"> <dt id="tag~4"><a class="permalink" href="#tag~4">tag</a></dt> <dd>indented regular text - <pre> -indented + <pre>indented literal -text - </pre> +text</pre> </dd> </dl> -<pre> -new +<pre>new literal -paragraph -</pre> +paragraph</pre> regular text <br/> diff --git a/regress/usr.bin/mandoc/man/RS/literal.out_html b/regress/usr.bin/mandoc/man/RS/literal.out_html index 7bd5431bf31..3429d849092 100644 --- a/regress/usr.bin/mandoc/man/RS/literal.out_html +++ b/regress/usr.bin/mandoc/man/RS/literal.out_html @@ -1,18 +1,12 @@ <br/> initial regular text</p> -<pre> -literal text -before display -</pre> +<pre>literal text +before display</pre> <div class="Bd-indent"> -<pre> -This is a short line. -This is a very long line that would wrap if it weren't in literal context. -</pre> +<pre>This is a short line. +This is a very long line that would wrap if it weren't in literal context.</pre> </div> -<pre> -literal text -after display -</pre> +<pre>literal text +after display</pre> <p class="Pp">final regular text <br/> diff --git a/regress/usr.bin/mandoc/man/SY/literal.out_html b/regress/usr.bin/mandoc/man/SY/literal.out_html index 9b3e84866b2..3d63b516d15 100644 --- a/regress/usr.bin/mandoc/man/SY/literal.out_html +++ b/regress/usr.bin/mandoc/man/SY/literal.out_html @@ -7,23 +7,17 @@ </tr> </table> middle regular text -<pre> -literal text -before display -</pre> +<pre>literal text +before display</pre> <table class="Nm"> <tr> <td><code class="Nm">command</code></td> <td> - <pre> -<i>arguments</i> - </pre> + <pre><i>arguments</i></pre> </td> </tr> </table> -<pre> -literal text -after display -</pre> +<pre>literal text +after display</pre> <p class="Pp">final regular text <br/> diff --git a/regress/usr.bin/mandoc/man/TP/literal.out_html b/regress/usr.bin/mandoc/man/TP/literal.out_html index 914c7b5c6ef..711947702e4 100644 --- a/regress/usr.bin/mandoc/man/TP/literal.out_html +++ b/regress/usr.bin/mandoc/man/TP/literal.out_html @@ -3,23 +3,17 @@ <dd>regular indented text</dd> </dl> <p class="Pp">regular paragraph</p> -<pre> -literal -text -</pre> +<pre>literal +text</pre> <dl class="Bl-tag"> <dt id="tag~2"><a class="permalink" href="#tag~2">tag</a></dt> <dd> - <pre> -indented + <pre>indented literal -text - </pre> +text</pre> </dd> </dl> -<pre> -literal -paragraph -</pre> +<pre>literal +paragraph</pre> regular text <br/> diff --git a/regress/usr.bin/mandoc/mdoc/Bd/nf.out_html b/regress/usr.bin/mandoc/mdoc/Bd/nf.out_html index 394eb7edefa..83083353b9d 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/nf.out_html +++ b/regress/usr.bin/mandoc/mdoc/Bd/nf.out_html @@ -1,20 +1,14 @@ -<pre> -after .nf -request -</pre> +<pre>after .nf +request</pre> <p class="Pp">after .fi request</p> <div class="Bd Pp"> -<pre> -in unfilled -block -</pre> +<pre>in unfilled +block</pre> after .fi request in unfilled block</div> after end of unfilled block <div class="Bd Pp">in filled block -<pre> -after .nf request -in filled block -</pre> +<pre>after .nf request +in filled block</pre> </div> after end of filled block <br/> diff --git a/regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html b/regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html index cc3491c9f86..22355ed1e2b 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html +++ b/regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html @@ -8,13 +8,11 @@ back to normal <p class="Pp">another paragraph</p> <div class="Bd Pp" id="unfilled"> -<pre> -<a class="permalink" href="#unfilled">unfilled</a> literal +<pre><a class="permalink" href="#unfilled">unfilled</a> literal display <mark id="upara"></mark> <a class="permalink" href="#upara">unfilled</a> literal -paragraph -</pre> +paragraph</pre> </div> again back to normal <br/> diff --git a/regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html b/regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html index ba5fb63a8de..bfb0a7240c2 100644 --- a/regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html +++ b/regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html @@ -13,4 +13,3 @@ <p class="Pp">in a paragraph:</p> <p class="Pp"><cite class="Rs"><span class="RsA">another author</span>, <i class="RsB">another book</i>.</cite></p> -<pre> diff --git a/regress/usr.bin/mandoc/roff/sp/fill-man.out_html b/regress/usr.bin/mandoc/roff/sp/fill-man.out_html index 054b63596dd..213d46012e8 100644 --- a/regress/usr.bin/mandoc/roff/sp/fill-man.out_html +++ b/regress/usr.bin/mandoc/roff/sp/fill-man.out_html @@ -1,7 +1,5 @@ <p class="Pp">switch to no-fill mode:</p> -<pre> -in no-fill mode: +<pre>in no-fill mode: back to -fill mode: -</pre> +fill mode:</pre> diff --git a/regress/usr.bin/mandoc/roff/string/dotT.out_html b/regress/usr.bin/mandoc/roff/string/dotT.out_html index 0a019b20d59..51ab1411619 100644 --- a/regress/usr.bin/mandoc/roff/string/dotT.out_html +++ b/regress/usr.bin/mandoc/roff/string/dotT.out_html @@ -1,3 +1,2 @@ <p class="Pp">We are using the html device.</p> <p class="Pp">The device name can be overridden.</p> -<pre> diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c index 8892009d9f6..cadd57daec7 100644 --- a/usr.bin/mandoc/html.c +++ b/usr.bin/mandoc/html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: html.c,v 1.141 2020/04/20 12:59:24 schwarze Exp $ */ +/* $OpenBSD: html.c,v 1.142 2020/10/16 17:22:38 schwarze Exp $ */ /* * Copyright (c) 2011-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> @@ -79,7 +79,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/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index a2a1b4d959c..3d57bad66c0 100644 --- a/usr.bin/mandoc/man_html.c +++ b/usr.bin/mandoc/man_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_html.c,v 1.131 2020/04/04 20:23:06 schwarze Exp $ */ +/* $OpenBSD: man_html.c,v 1.132 2020/10/16 17:22:39 schwarze Exp $ */ /* * Copyright (c) 2013-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> @@ -167,7 +167,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) { @@ -251,13 +256,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 = <pre>, print even empty lines. */ - h->col++; - print_endline(h); - } } static void diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index fcff005883b..b5442dfd9b4 100644 --- a/usr.bin/mandoc/mdoc_html.c +++ b/usr.bin/mandoc/mdoc_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_html.c,v 1.215 2020/04/19 15:15:54 schwarze Exp $ */ +/* $OpenBSD: mdoc_html.c,v 1.216 2020/10/16 17:22:39 schwarze Exp $ */ /* * Copyright (c) 2014-2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> @@ -347,12 +347,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; |