aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-05-09 00:46:10 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-05-09 00:46:10 +0000
commit8146f18c9d4d17026c0a4ae5ed85ea5907bf38fc (patch)
tree5b53a53e71f76bae69a7632586ac545c8d80b651
parent35d4aaed89e7337b61f0213b253b9bee370ad2c3 (diff)
downloadmandoc-8146f18c9d4d17026c0a4ae5ed85ea5907bf38fc.tar.gz
mandoc-8146f18c9d4d17026c0a4ae5ed85ea5907bf38fc.tar.zst
mandoc-8146f18c9d4d17026c0a4ae5ed85ea5907bf38fc.zip
Fix a long-standing issue:
Some macros (Nd, Oo) can contain blocks but rendered as elements that can only contain phrasing content, resulting in invalid HTML nesting. Switch them to <div>. Also move the related "display: inline" style from the HTML to the CSS. Reminded during a conversation with John Gardner.
-rw-r--r--html.c5
-rw-r--r--html.h3
-rw-r--r--mandoc.css7
-rw-r--r--mdoc_html.c26
4 files changed, 21 insertions, 20 deletions
diff --git a/html.c b/html.c
index e57322b4..33cb67c4 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.224 2018/05/08 21:42:34 schwarze Exp $ */
+/* $Id: html.c,v 1.225 2018/05/09 00:46:10 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -59,6 +59,7 @@ static const struct htmldata htmltags[TAG_MAX] = {
{"meta", HTML_NOSTACK | HTML_AUTOCLOSE | HTML_NLALL},
{"title", HTML_NLAROUND},
{"div", HTML_NLAROUND},
+ {"div", 0},
{"h1", HTML_NLAROUND},
{"h2", HTML_NLAROUND},
{"span", 0},
@@ -187,6 +188,8 @@ print_gen_head(struct html *h)
print_endline(h);
print_text(h, "div.Pp { margin: 1ex 0ex; }");
print_endline(h);
+ print_text(h, "div.Nd, div.Bf, div.Op { display: inline; }");
+ print_endline(h);
print_text(h, "dl.Bl-diag ");
print_byte(h, '>');
print_text(h, " dt { font-weight: bold; }");
diff --git a/html.h b/html.h
index d128a76c..fc722694 100644
--- a/html.h
+++ b/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.88 2018/04/13 16:28:07 schwarze Exp $ */
+/* $Id: html.h,v 1.89 2018/05/09 00:46:10 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -23,6 +23,7 @@ enum htmltag {
TAG_META,
TAG_TITLE,
TAG_DIV,
+ TAG_IDIV,
TAG_H1,
TAG_H2,
TAG_SPAN,
diff --git a/mandoc.css b/mandoc.css
index 57278ca3..dbedcb75 100644
--- a/mandoc.css
+++ b/mandoc.css
@@ -1,4 +1,4 @@
-/* $Id: mandoc.css,v 1.25 2018/05/08 21:42:34 schwarze Exp $ */
+/* $Id: mandoc.css,v 1.26 2018/05/09 00:46:10 schwarze Exp $ */
/*
* Standard style sheet for mandoc(1) -Thtml and man.cgi(8).
*/
@@ -41,7 +41,7 @@ table.head { width: 100%;
td.head-vol { text-align: center; }
td.head-rtitle {
text-align: right; }
-span.Nd { }
+div.Nd { display: inline; }
table.foot { width: 100%;
border-top: 1px dotted #808080;
@@ -164,7 +164,7 @@ code.Cm { font-style: normal;
font-family: inherit; }
var.Ar { font-style: italic;
font-weight: normal; }
-span.Op { }
+div.Op { display: inline; }
code.Ic { font-style: normal;
font-weight: bold;
font-family: inherit; }
@@ -216,6 +216,7 @@ a.Ux { }
/* Physical markup. */
+.Bf { display: inline; }
.No { font-style: normal;
font-weight: normal; }
.Em { font-style: italic;
diff --git a/mdoc_html.c b/mdoc_html.c
index 9930cb55..c871181d 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.299 2018/05/08 21:42:34 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.300 2018/05/09 00:46:10 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -583,10 +583,9 @@ mdoc_nd_pre(MDOC_ARGS)
if (n->type != ROFFT_BODY)
return 1;
- /* XXX: this tag in theory can contain block elements. */
-
print_text(h, "\\(em");
- print_otag(h, TAG_SPAN, "cT", "Nd");
+ /* Cannot use TAG_SPAN because it may contain blocks. */
+ print_otag(h, TAG_DIV, "cT", "Nd");
return 1;
}
@@ -1444,20 +1443,16 @@ mdoc_bf_pre(MDOC_ARGS)
return 1;
if (FONT_Em == n->norm->Bf.font)
- cattr = "Em";
+ cattr = "Bf Em";
else if (FONT_Sy == n->norm->Bf.font)
- cattr = "Sy";
+ cattr = "Bf Sy";
else if (FONT_Li == n->norm->Bf.font)
- cattr = "Li";
+ cattr = "Bf Li";
else
- cattr = "No";
-
- /*
- * We want this to be inline-formatted, but needs to be div to
- * accept block children.
- */
+ cattr = "Bf No";
- print_otag(h, TAG_DIV, "css?hl", cattr, "display", "inline", 1);
+ /* Cannot use TAG_SPAN because it may contain blocks. */
+ print_otag(h, TAG_DIV, "cshl", cattr, 1);
return 1;
}
@@ -1678,7 +1673,8 @@ mdoc_quote_pre(MDOC_ARGS)
case MDOC_Op:
print_text(h, "\\(lB");
h->flags |= HTML_NOSPACE;
- print_otag(h, TAG_SPAN, "c", "Op");
+ /* Cannot use TAG_SPAN because it may contain blocks. */
+ print_otag(h, TAG_IDIV, "c", "Op");
break;
case MDOC_En:
if (NULL == n->norm->Es ||