From cb038bb3125028e17a5b05c32495219a17fb6537 Mon Sep 17 00:00:00 2001 From: Aner Lucero <4rgento@gmail.com> Date: Fri, 2 Jul 2021 11:17:14 -0300 Subject: HTML5 writer, remove aria-hidden when explicit atl text is provided. --- src/Text/Pandoc/Writers/HTML.hs | 11 +++++++---- test/command/7416.md | 2 +- 2 files changed, 8 insertions(+), 5 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 diff --git a/test/command/7416.md b/test/command/7416.md index 70a0257fa..2f9577f10 100644 --- a/test/command/7416.md +++ b/test/command/7416.md @@ -4,7 +4,7 @@ ^D
-alt +alt
caption
``` -- cgit v1.2.3