summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIacobus1983 <77020754+Iacobus1983@users.noreply.github.com>2024-01-27 20:10:58 +0100
committerGitHub <noreply@github.com>2024-01-27 11:10:58 -0800
commitb837d59fd5a9651ea119f11b97ef6d0c9ef163de (patch)
treed652e65a72b81919be491dbc4187bfbf3101bf17
parentbc1caab557aacee60b80dc4faad2e1e9a49a2fb4 (diff)
EPUB writer: add ARA roles for accessibility (#9378)
This commit adds roles to some html element within epub in order to comply with accessibility best practices. Footnote references are given role "doc-noteref",footnote text gets "doc-footnote", and nav gets "doc-toc".
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs1
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs4
2 files changed, 3 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 9fdd8637a..ea8a46cd1 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -948,6 +948,7 @@ createNavEntry opts meta metadata
let navBlocks = [RawBlock (Format "html")
$ showElement $ -- prettyprinting introduces bad spaces
unode navtag ! ([("epub:type","toc") | version == EPUB3] ++
+ [("role","doc-toc") | version == EPUB3] ++
[("id","toc")]) $
[ unode "h1" ! [("id","toc-title")] $ tocTitle
, unode "ol" ! [("class","toc")] $ tocBlocks ]]
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index e3be8b9fb..18e10f102 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1605,7 +1605,7 @@ inlineToHtml opts inline = do
else H.sup)
$ toHtml ref
return $ case epubVersion of
- Just EPUB3 -> link ! customAttribute "epub:type" "noteref"
+ Just EPUB3 -> link ! customAttribute "epub:type" "noteref" ! customAttribute "role" "doc-noteref"
_ | html5 -> link ! A5.role "doc-noteref"
_ -> link
(Cite cits il)-> do contents <- inlineListToHtml opts
@@ -1668,7 +1668,7 @@ blockListToNote opts ref blocks = do
_ -> Para [backlink , Str "."] : blocks
contents <- blockListToHtml opts blocks'
let noteItem = (if epubv == EPUB3
- then H5.aside ! customAttribute "epub:type" "footnote"
+ then H5.aside ! customAttribute "epub:type" "footnote" ! customAttribute "role" "doc-footnote"
else H.div) ! prefixedId opts ("fn" <> ref)
$ nl >> contents >> nl
return $ noteItem >> nl