From b837d59fd5a9651ea119f11b97ef6d0c9ef163de Mon Sep 17 00:00:00 2001 From: Iacobus1983 <77020754+Iacobus1983@users.noreply.github.com> Date: Sat, 27 Jan 2024 20:10:58 +0100 Subject: 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". --- src/Text/Pandoc/Writers/EPUB.hs | 1 + src/Text/Pandoc/Writers/HTML.hs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Text') 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 -- cgit v1.2.3