diff options
author | Aner Lucero <4rgento@gmail.com> | 2021-07-02 11:17:14 -0300 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-07-02 13:02:52 -0700 |
commit | cb038bb3125028e17a5b05c32495219a17fb6537 (patch) | |
tree | 2ba9d07187000860703b29f22c15ddff70322f9d /src | |
parent | 0948af9cc549f0ea3b85fa760aa521b8deaad2c0 (diff) | |
download | pandoc-cb038bb3125028e17a5b05c32495219a17fb6537.tar.gz |
HTML5 writer, remove aria-hidden when explicit atl text is provided.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index df01fc35f..7eb8dfe12 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -659,17 +659,20 @@ dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height figure :: PandocMonad m => WriterOptions -> Attr -> [Inline] -> (Text, Text) -> StateT WriterState m Html -figure opts attr txt (s,tit) = do +figure opts attr@(_, _, attrList) txt (s,tit) = do html5 <- gets stHtml5 -- Screen-readers will normally read the @alt@ text and the figure; we -- want to avoid them reading the same text twice. With HTML5 we can -- use aria-hidden for the caption; with HTML4, we use an empty -- alt-text instead. + -- When the alt text differs from the caption both should be read. let alt = if html5 then txt else [Str ""] let tocapt = if html5 - then H5.figcaption ! - H5.customAttribute (textTag "aria-hidden") - (toValue @Text "true") + then (H5.figcaption !) $ + if isJust (lookup "alt" attrList) + then mempty + else H5.customAttribute (textTag "aria-hidden") + (toValue @Text "true") else H.p ! A.class_ "caption" img <- inlineToHtml opts (Image attr alt (s,tit)) capt <- if null txt |