diff options
| author | John MacFarlane <[email protected]> | 2024-01-20 10:34:32 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-01-20 10:34:32 -0800 |
| commit | 243bbf699c8f5f47539100307ee450ad65a3256e (patch) | |
| tree | 767f4cf979b58b7dbf508e62c9146602bc3efae3 | |
| parent | f43ffabd3c598f7154cd101069e7e77947f5676d (diff) | |
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.
| -rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 6 |
1 files changed, 4 insertions, 2 deletions
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 |
