@@ -1,6 +1,7 @@
11{-# LANGUAGE MultiWayIf #-}
22{-# LANGUAGE OverloadedStrings #-}
33{-# LANGUAGE ScopedTypeVariables #-}
4+{-# LANGUAGE TypeApplications #-}
45{-# LANGUAGE ViewPatterns #-}
56{- |
67 Module : Text.Pandoc.Writers.HTML
@@ -587,11 +588,18 @@ figure :: PandocMonad m
587588 => WriterOptions -> Attr -> [Inline] -> (Text, Text)
588589 -> StateT WriterState m Html
589590figure opts attr txt (s,tit) = do
590− img <- inlineToHtml opts (Image attr [Str ""] (s,tit))
591591 html5 <- gets stHtml5
592+ -- Screen-readers will normally read the @alt@ text and the figure; we
593+ -- want to avoid them reading the same text twice. With HTML5 we can
594+ -- use aria-hidden for the caption; with HTML4, we use an empty
595+ -- alt-text instead.
596+ let alt = if html5 then txt else [Str ""]
592597 let tocapt = if html5
593− then H5.figcaption
598+ then H5.figcaption !
599+ H5.customAttribute (textTag "aria-hidden")
600+ (toValue @Text "true")
594601 else H.p ! A.class_ "caption"
602+ img <- inlineToHtml opts (Image attr alt (s,tit))
595603 capt <- if null txt
596604 then return mempty
597605 else tocapt `fmap` inlineListToHtml opts txt