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.
This commit is contained in:
John MacFarlane
2024-01-20 10:34:32 -08:00
parent f43ffabd3c
commit 243bbf699c
+4 -2
View File
@@ -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