From 4529325a8a141549d437f69180f87d8e684a0235 Mon Sep 17 00:00:00 2001 From: schwarze Date: Tue, 30 Mar 2021 19:23:50 +0000 Subject: [PATCH] In HTML output, correctly render .Bd -unfilled in proportionally-spaced font, rather than with the monospace font appropriate for .Bd -literal. This fixes a minibug reported by anton@. Implemented by no longer relying on the typical browser default of "pre { font-family: monospace }" but instead letting
 elements
inherit the font family from their parent, then adding an explicit CSS .Li
class only for those displays where the manual page author requested it
by using the -literal option on the .Bd macro.
---
 regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html | 2 +-
 usr.bin/mandoc/mandoc.css                         | 3 ++-
 usr.bin/mandoc/mdoc_html.c                        | 9 ++++++---
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html b/regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html
index 22355ed1e2b..df5fc6d6062 100644
--- a/regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html
+++ b/regress/usr.bin/mandoc/mdoc/Bd/paragraph.out_html
@@ -7,7 +7,7 @@
 
 back to normal
 

another paragraph

-
+
 literal
 display
 
diff --git a/usr.bin/mandoc/mandoc.css b/usr.bin/mandoc/mandoc.css
index ca7f2602e58..2b19ba68596 100644
--- a/usr.bin/mandoc/mandoc.css
+++ b/usr.bin/mandoc/mandoc.css
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.css,v 1.34 2020/10/30 21:31:19 schwarze Exp $ */
+/* $OpenBSD: mandoc.css,v 1.35 2021/03/30 19:23:50 schwarze Exp $ */
 /*
  * Standard style sheet for mandoc(1) -Thtml and man.cgi(8).
  *
@@ -31,6 +31,7 @@ td {		vertical-align: top;
 ul, ol, dl {	margin-top: 0em;
 		margin-bottom: 0em; }
 li, dt {	margin-top: 1em; }
+pre {		font-family: inherit; }
 
 .permalink {	border-bottom: thin dotted;
 		color: inherit;
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index b5442dfd9b4..e6dbfbe4a83 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,6 +1,6 @@
-/* $OpenBSD: mdoc_html.c,v 1.216 2020/10/16 17:22:39 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.217 2021/03/30 19:23:50 schwarze Exp $ */
 /*
- * Copyright (c) 2014-2020 Ingo Schwarze 
+ * Copyright (c) 2014-2021 Ingo Schwarze 
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons 
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -928,7 +928,7 @@ mdoc_sx_pre(MDOC_ARGS)
 static int
 mdoc_bd_pre(MDOC_ARGS)
 {
-	char			 buf[16];
+	char			 buf[20];
 	struct roff_node	*nn;
 	int			 comp;
 
@@ -965,6 +965,9 @@ mdoc_bd_pre(MDOC_ARGS)
 	    strcmp(n->norm->Bd.offs, "left") != 0)
 		(void)strlcat(buf, " Bd-indent", sizeof(buf));
 
+	if (n->norm->Bd.type == DISP_literal)
+		(void)strlcat(buf, " Li", sizeof(buf));
+
 	print_otag_id(h, TAG_DIV, buf, n);
 	return 1;
 }
-- 
2.20.1