git.iko.soy/typeable/pandoc
on master help sign in
HTML5 writer, remove aria-hidden when explicit atl text is provided.
commitcb038bb3125028e17a5b05c32495219a17fb6537 authorAner Lucero <4rgento@gmail.com> dateFri 2 Jul 2021, 11:17 (5 years ago) parent0948af9
2 files changed+8−5
src/Text/Pandoc/Writers/HTML.hs+7−4 test/command/7416.md+1−1
src/Text/Pandoc/Writers/HTML.hs+7−4
@@ -659,17 +659,20 @@ dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height
659659figure :: PandocMonad m
660660 => WriterOptions -> Attr -> [Inline] -> (Text, Text)
661661 -> StateT WriterState m Html
662−figure opts attr txt (s,tit) = do
662+figure opts attr@(_, _, attrList) txt (s,tit) = do
663663 html5 <- gets stHtml5
664664 -- Screen-readers will normally read the @alt@ text and the figure; we
665665 -- want to avoid them reading the same text twice. With HTML5 we can
666666 -- use aria-hidden for the caption; with HTML4, we use an empty
667667 -- alt-text instead.
668+ -- When the alt text differs from the caption both should be read.
668669 let alt = if html5 then txt else [Str ""]
669670 let tocapt = if html5
670− then H5.figcaption !
671− H5.customAttribute (textTag "aria-hidden")
672− (toValue @Text "true")
671+ then (H5.figcaption !) $
672+ if isJust (lookup "alt" attrList)
673+ then mempty
674+ else H5.customAttribute (textTag "aria-hidden")
675+ (toValue @Text "true")
673676 else H.p ! A.class_ "caption"
674677 img <- inlineToHtml opts (Image attr alt (s,tit))
675678 capt <- if null txt
test/command/7416.md+1−1
@@ -4,7 +4,7 @@
44
55^D
66<figure>
7−<img src="../media/rId25.jpg" title="title" alt="alt" /><figcaption aria-hidden="true">caption</figcaption>
7+<img src="../media/rId25.jpg" title="title" alt="alt" /><figcaption>caption</figcaption>
88</figure>
99```
1010