diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2022-06-24 11:15:53 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2022-06-24 11:15:53 +0000 |
commit | 775d26d8d971fc94e1220bd3c8f87e4a1409a2ca (patch) | |
tree | 32a9a794f2256527eabce00439cb226c70a6e996 | |
parent | 57d5a8a3f3e52ca15b81371ea3b38c3124a45ec4 (diff) | |
download | mandoc-775d26d8d971fc94e1220bd3c8f87e4a1409a2ca.tar.gz mandoc-775d26d8d971fc94e1220bd3c8f87e4a1409a2ca.tar.zst mandoc-775d26d8d971fc94e1220bd3c8f87e4a1409a2ca.zip |
Improve accessibility of -T html -O toc output by using the <nav> element
in the DPUB-ARIA doc-toc role.
Patch from Anna Vyalkova <cyber at sysrq dot in> slightly tweaked by me.
This is hopefully the start of a collaboration to improve accessibility
of Unix manual pages using the WAI-ARIA, HTML-ARIA, and DPUB-ARIA standards.
Progress appears to be possible without changing *anything* with respect to
the way manual pages are written. Instead, it seems sufficient to properly
translate semantic cues already implied by existing mdoc(7) markup into the
appropriate HTML elements and ARIA attributes. Overall, the total length
of HTML output is likely to increase slightly, but not much.
-rw-r--r-- | html.c | 6 | ||||
-rw-r--r-- | html.h | 3 | ||||
-rw-r--r-- | mandoc_html.3 | 8 | ||||
-rw-r--r-- | mdoc_html.c | 7 |
4 files changed, 17 insertions, 7 deletions
@@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.275 2021/09/09 14:47:24 schwarze Exp $ */ +/* $Id: html.c,v 1.276 2022/06/24 11:15:53 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze <schwarze@openbsd.org> @@ -69,6 +69,7 @@ static const struct htmldata htmltags[TAG_MAX] = { {"body", HTML_NLALL}, {"div", HTML_NLAROUND}, {"section", HTML_NLALL}, + {"nav", HTML_NLALL}, {"table", HTML_NLALL | HTML_INDENT}, {"tr", HTML_NLALL | HTML_INDENT}, {"td", HTML_NLAROUND}, @@ -708,6 +709,9 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...) case 'i': attr = "id"; break; + case 'r': + attr = "role"; + break; case '?': attr = arg1; arg1 = va_arg(ap, char *); @@ -1,4 +1,4 @@ -/* $Id: html.h,v 1.109 2021/09/09 14:47:24 schwarze Exp $ */ +/* $Id: html.h,v 1.110 2022/06/24 11:15:53 schwarze Exp $ */ /* * Copyright (c) 2017, 2018, 2019, 2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> @@ -29,6 +29,7 @@ enum htmltag { TAG_BODY, TAG_DIV, TAG_SECTION, + TAG_NAV, TAG_TABLE, TAG_TR, TAG_TD, diff --git a/mandoc_html.3 b/mandoc_html.3 index a77d0e04..a7c8d796 100644 --- a/mandoc_html.3 +++ b/mandoc_html.3 @@ -1,4 +1,4 @@ -.\" $Id: mandoc_html.3,v 1.23 2020/04/24 13:13:06 schwarze Exp $ +.\" $Id: mandoc_html.3,v 1.24 2022/06/24 11:15:53 schwarze Exp $ .\" .\" Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 24 2020 $ +.Dd $Mdocdate: June 24 2022 $ .Dt MANDOC_HTML 3 .Os .Sh NAME @@ -221,6 +221,10 @@ option. Print an .Cm id attribute. +.It Cm r +Print an ARIA +.Cm role +attribute. .It Cm \&? Print an arbitrary attribute. This format letter requires two diff --git a/mdoc_html.c b/mdoc_html.c index c0a0a6a5..85969a19 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.342 2021/03/30 19:26:20 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.343 2022/06/24 11:15:53 schwarze Exp $ */ /* * Copyright (c) 2014-2021 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> @@ -515,7 +515,7 @@ static int mdoc_sh_pre(MDOC_ARGS) { struct roff_node *sn, *subn; - struct tag *t, *tsec, *tsub; + struct tag *t, *tnav, *tsec, *tsub; char *id; int sc; @@ -536,6 +536,7 @@ mdoc_sh_pre(MDOC_ARGS) break; if (sc < 2) break; + tnav = print_otag(h, TAG_NAV, "r", "doc-toc"); t = print_otag(h, TAG_H1, "c", "Sh"); print_text(h, "TABLE OF CONTENTS"); print_tagq(h, t); @@ -567,7 +568,7 @@ mdoc_sh_pre(MDOC_ARGS) } print_tagq(h, tsec); } - print_tagq(h, t); + print_tagq(h, tnav); print_otag(h, TAG_SECTION, "c", "Sh"); break; case ROFFT_HEAD: |