summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2019-03-01 10:49:00 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2019-03-01 10:49:00 +0000
commitfcf50d2d6b1d25933557b0bddd82d0aa2315add8 (patch)
tree7c10d95824d1862207e81544f896bde74be1fe90
parent52fdb68cdf8373bbdc96a78e26be74766ba34cc4 (diff)
Wrap .Sh/.SH sections and .Ss/.SS subsections in HTML <section> elements
as recommended for accessibility by the HTML 5 standard. Triggered by a similar, but slightly different suggestion from Laura Morales <lauretas at mail dot com>.
-rw-r--r--regress/usr.bin/mandoc/man/IP/literal.out_html3
-rw-r--r--regress/usr.bin/mandoc/man/SH/paragraph.out_html4
-rw-r--r--regress/usr.bin/mandoc/man/SS/paragraph.out_html3
-rw-r--r--regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html2
-rw-r--r--regress/usr.bin/mandoc/mdoc/Sh/paragraph.out_html4
-rw-r--r--regress/usr.bin/mandoc/roff/ft/badargs.out_html2
-rw-r--r--usr.bin/mandoc/html.c3
-rw-r--r--usr.bin/mandoc/html.h3
-rw-r--r--usr.bin/mandoc/man_html.c21
-rw-r--r--usr.bin/mandoc/mandoc.css20
-rw-r--r--usr.bin/mandoc/mdoc_html.c8
11 files changed, 52 insertions, 21 deletions
diff --git a/regress/usr.bin/mandoc/man/IP/literal.out_html b/regress/usr.bin/mandoc/man/IP/literal.out_html
index 844eb1dd477..dce47df1e77 100644
--- a/regress/usr.bin/mandoc/man/IP/literal.out_html
+++ b/regress/usr.bin/mandoc/man/IP/literal.out_html
@@ -24,6 +24,7 @@ literal
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>
regular text
@@ -42,6 +43,8 @@ text
indented regular text</dd>
</dl>
<p class="Pp">new regular paragraph</p>
+</section>
+<section class="Ss">
<h2 class="Ss" id="literal_out_of_indented_paragraph"><a class="permalink" href="#literal_out_of_indented_paragraph">literal
out of indented paragraph</a></h2>
regular text
diff --git a/regress/usr.bin/mandoc/man/SH/paragraph.out_html b/regress/usr.bin/mandoc/man/SH/paragraph.out_html
index 49627f19f50..6423855ade4 100644
--- a/regress/usr.bin/mandoc/man/SH/paragraph.out_html
+++ b/regress/usr.bin/mandoc/man/SH/paragraph.out_html
@@ -1,6 +1,10 @@
BEGINTEST
+</section>
+<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
This text immediately follows a section header.
<p class="Pp">This is a paragraph.</p>
+</section>
+<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
ENDTEST
diff --git a/regress/usr.bin/mandoc/man/SS/paragraph.out_html b/regress/usr.bin/mandoc/man/SS/paragraph.out_html
index bc803f86a97..fa385635e2f 100644
--- a/regress/usr.bin/mandoc/man/SS/paragraph.out_html
+++ b/regress/usr.bin/mandoc/man/SS/paragraph.out_html
@@ -1,8 +1,11 @@
BEGINTEST
+<section class="Ss">
<h2 class="Ss" id="First_subsection"><a class="permalink" href="#First_subsection">First
subsection</a></h2>
This text immediately follows a subsection header.
<p class="Pp">This is a paragraph.</p>
+</section>
+<section class="Ss">
<h2 class="Ss" id="Second_subsection"><a class="permalink" href="#Second_subsection">Second
subsection</a></h2>
ENDTEST
diff --git a/regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html b/regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html
index ab2575e52a5..251d0d0c87d 100644
--- a/regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html
+++ b/regress/usr.bin/mandoc/mdoc/Rs/paragraph.out_html
@@ -4,6 +4,8 @@ initial reference: <cite class="Rs"><span class="RsA">author name</span>,
<i class="RsB">book title</i>.</cite>
<p class="Pp">in a paragraph: <cite class="Rs"><span class="RsA">another
author</span>, <i class="RsB">another book</i>.</cite></p>
+</section>
+<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
initial reference:
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/paragraph.out_html b/regress/usr.bin/mandoc/mdoc/Sh/paragraph.out_html
index 7d4f0d40498..3b5154deb34 100644
--- a/regress/usr.bin/mandoc/mdoc/Sh/paragraph.out_html
+++ b/regress/usr.bin/mandoc/mdoc/Sh/paragraph.out_html
@@ -1,7 +1,11 @@
BEGINTEST
<p class="Pp">descriptive text</p>
+<section class="Ss">
<h2 class="Ss" id="Subsection"><a class="permalink" href="#Subsection">Subsection</a></h2>
initial subsection text
<p class="Pp">subsection paragraph</p>
+</section>
+</section>
+<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
ENDTEST
diff --git a/regress/usr.bin/mandoc/roff/ft/badargs.out_html b/regress/usr.bin/mandoc/roff/ft/badargs.out_html
index 8b30ab05d23..5d98e9883a6 100644
--- a/regress/usr.bin/mandoc/roff/ft/badargs.out_html
+++ b/regress/usr.bin/mandoc/roff/ft/badargs.out_html
@@ -6,4 +6,4 @@ default font <i></i><i>italic</i> <b><i></i></b><b><i>bold italic</i></b>
<i></i> <i>italic</i> <b></b><b>bold</b> <b>still bold</b>
<i></i><i>italic</i> <i></i><i>back to bold</i> <i></i><i>back to italic</i>
<br/>
-ENDTEST</div>
+ENDTEST
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index 23f52e10cb0..87aee9c66fe 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.122 2019/01/18 14:36:16 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.123 2019/03/01 10:48:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -61,6 +61,7 @@ static const struct htmldata htmltags[TAG_MAX] = {
{"title", HTML_NLAROUND},
{"div", HTML_NLAROUND},
{"div", 0},
+ {"section", HTML_NLALL},
{"h1", HTML_NLAROUND},
{"h2", HTML_NLAROUND},
{"span", 0},
diff --git a/usr.bin/mandoc/html.h b/usr.bin/mandoc/html.h
index 7f23401ad97..253a2423523 100644
--- a/usr.bin/mandoc/html.h
+++ b/usr.bin/mandoc/html.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.h,v 1.63 2019/01/18 14:36:16 schwarze Exp $ */
+/* $OpenBSD: html.h,v 1.64 2019/03/01 10:48:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2017, 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -24,6 +24,7 @@ enum htmltag {
TAG_TITLE,
TAG_DIV,
TAG_IDIV,
+ TAG_SECTION,
TAG_H1,
TAG_H2,
TAG_SPAN,
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index cfdb29175c6..2780072a794 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.124 2019/02/28 16:36:10 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.125 2019/03/01 10:48:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -308,18 +308,25 @@ man_root_post(const struct roff_meta *man, struct html *h)
static int
man_SH_pre(MAN_ARGS)
{
- char *id;
-
+ const char *class;
+ char *id;
+ enum htmltag tag;
+
+ if (n->tok == MAN_SH) {
+ tag = TAG_H1;
+ class = "Sh";
+ } else {
+ tag = TAG_H2;
+ class = "Ss";
+ }
switch (n->type) {
case ROFFT_BLOCK:
html_close_paragraph(h);
+ print_otag(h, TAG_SECTION, "c", class);
break;
case ROFFT_HEAD:
id = html_make_id(n, 1);
- if (n->tok == MAN_SH)
- print_otag(h, TAG_H1, "ci", "Sh", id);
- else
- print_otag(h, TAG_H2, "ci", "Ss", id);
+ print_otag(h, tag, "ci", class, id);
if (id != NULL)
print_otag(h, TAG_A, "chR", "permalink", id);
break;
diff --git a/usr.bin/mandoc/mandoc.css b/usr.bin/mandoc/mandoc.css
index 026a5b2eb13..e37e1ace568 100644
--- a/usr.bin/mandoc/mandoc.css
+++ b/usr.bin/mandoc/mandoc.css
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.css,v 1.31 2019/01/11 12:44:10 schwarze Exp $ */
+/* $OpenBSD: mandoc.css,v 1.32 2019/03/01 10:48:58 schwarze Exp $ */
/*
* Standard style sheet for mandoc(1) -Thtml and man.cgi(8).
*
@@ -66,11 +66,13 @@ td.foot-os { text-align: right; }
.manual-text {
margin-left: 3.8em; }
.Nd { }
-.Sh { margin-top: 1.2em;
+section.Sh { }
+h1.Sh { margin-top: 1.2em;
margin-bottom: 0.6em;
margin-left: -3.2em;
font-size: 110%; }
-.Ss { margin-top: 1.2em;
+section.Ss { }
+h2.Ss { margin-top: 1.2em;
margin-bottom: 0.6em;
margin-left: -1.2em;
font-size: 105%; }
@@ -256,7 +258,7 @@ a.In { }
/* Tooltip support. */
-.Sh, .Ss { position: relative; }
+h1.Sh, h2.Ss { position: relative; }
.An, .Ar, .Cd, .Cm, .Dv, .Em, .Er, .Ev, .Fa, .Fd, .Fl, .Fn, .Ft,
.Ic, code.In, .Lb, .Lk, .Ms, .Mt, .Nd, code.Nm, .Pa, .Rs,
.St, .Sx, .Sy, .Va, .Vt, .Xr {
@@ -286,8 +288,8 @@ code.In::before { content: "In"; }
code.Nm::before { content: "Nm"; }
.Pa::before { content: "Pa"; }
.Rs::before { content: "Rs"; }
-.Sh::before { content: "Sh"; }
-.Ss::before { content: "Ss"; }
+h1.Sh::before { content: "Sh"; }
+h2.Ss::before { content: "Ss"; }
.St::before { content: "St"; }
.Sx::before { content: "Sx"; }
.Sy::before { content: "Sy"; }
@@ -301,7 +303,7 @@ code.Nm::before { content: "Nm"; }
.Ic::before, code.In::before, .Lb::before, .Lk::before,
.Ms::before, .Mt::before, .Nd::before, code.Nm::before,
.Pa::before, .Rs::before,
-.Sh::before, .Ss::before, .St::before, .Sx::before, .Sy::before,
+h1.Sh::before, h2.Ss::before, .St::before, .Sx::before, .Sy::before,
.Va::before, .Vt::before, .Xr::before {
opacity: 0;
transition: .15s ease opacity;
@@ -322,7 +324,7 @@ code.Nm::before { content: "Nm"; }
.Ft:hover::before, .Ic:hover::before, code.In:hover::before,
.Lb:hover::before, .Lk:hover::before, .Ms:hover::before, .Mt:hover::before,
.Nd:hover::before, code.Nm:hover::before, .Pa:hover::before,
-.Rs:hover::before, .Sh:hover::before, .Ss:hover::before, .St:hover::before,
+.Rs:hover::before, h1.Sh:hover::before, h2.Ss:hover::before, .St:hover::before,
.Sx:hover::before, .Sy:hover::before, .Va:hover::before, .Vt:hover::before,
.Xr:hover::before {
opacity: 1;
@@ -333,7 +335,7 @@ code.Nm::before { content: "Nm"; }
@media (max-width: 37.5em) {
.manual-text {
margin-left: 0.5em; }
-.Sh, .Ss { margin-left: 0em; }
+h1.Sh, h2.Ss { margin-left: 0em; }
.Bd-indent { margin-left: 2em; }
.Bl-hang > dd {
margin-left: 2em; }
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index ad42d59ecf9..ec3865bf3f8 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.202 2019/01/18 14:36:16 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.203 2019/03/01 10:48:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -529,8 +529,10 @@ mdoc_sh_pre(MDOC_ARGS)
html_close_paragraph(h);
if ((h->oflags & HTML_TOC) == 0 ||
h->flags & HTML_TOCDONE ||
- n->sec <= SEC_SYNOPSIS)
+ n->sec <= SEC_SYNOPSIS) {
+ print_otag(h, TAG_SECTION, "c", "Sh");
break;
+ }
h->flags |= HTML_TOCDONE;
sc = 0;
for (sn = n->next; sn != NULL; sn = sn->next)
@@ -571,6 +573,7 @@ mdoc_sh_pre(MDOC_ARGS)
print_tagq(h, tsec);
}
print_tagq(h, t);
+ print_otag(h, TAG_SECTION, "c", "Sh");
break;
case ROFFT_HEAD:
id = html_make_id(n, 1);
@@ -596,6 +599,7 @@ mdoc_ss_pre(MDOC_ARGS)
switch (n->type) {
case ROFFT_BLOCK:
html_close_paragraph(h);
+ print_otag(h, TAG_SECTION, "c", "Ss");
return 1;
case ROFFT_HEAD:
break;