From 243bbf699c8f5f47539100307ee450ad65a3256e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 20 Jan 2024 10:34:32 -0800 Subject: HTML writer: ensure that an alt attribute is added in EPUB output. This seems to be required by iBooks; even an empty alt attribute will satisfy it. Closes #9354. --- src/Text/Pandoc/Writers/HTML.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 0f7bc85c8..e3be8b9fb 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -1552,6 +1552,7 @@ inlineToHtml opts inline = do then link' else link' ! A.title (toValue tit) (Image attr@(_, _, attrList) txt (s, tit)) -> do + epubVersion <- gets stEPUBVersion let alternate = stringify txt slideVariant <- gets stSlideVariant let isReveal = slideVariant == RevealJsSlides @@ -1564,8 +1565,9 @@ inlineToHtml opts inline = do [A.title $ toValue tit | not (T.null tit)] ++ attrs imageTag = (if html5 then H5.img else H.img - , [A.alt $ toValue alternate | not (null txt) && - isNothing (lookup "alt" attrList)] ) + , [A.alt $ toValue alternate | + isNothing (lookup "alt" attrList) && + (isJust epubVersion || not (null txt))] ) mediaTag tg fallbackTxt = let linkTxt = if null txt then fallbackTxt -- cgit v1.2.3