From f4ef652a4165fefe4b587882cc75d1e24971ef1f Mon Sep 17 00:00:00 2001
From: Aner Lucero <4rgento@gmail.com>
Date: Tue, 29 Jun 2021 08:49:36 -0300
Subject: Remove duplicated alt text in HTML output.
---
src/Text/Pandoc/Writers/HTML.hs | 5 +++--
test/command/7416.md | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
create mode 100644 test/command/7416.md
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index b99b1a413..df01fc35f 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1433,7 +1433,7 @@ inlineToHtml opts inline = do
return $ if T.null tit
then link'
else link' ! A.title (toValue tit)
- (Image attr txt (s,tit)) -> do
+ (Image attr@(_, _, attrList) txt (s, tit)) -> do
let alternate = stringify txt
slideVariant <- gets stSlideVariant
let isReveal = slideVariant == RevealJsSlides
@@ -1446,7 +1446,8 @@ 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)] )
+ , [A.alt $ toValue alternate | not (null txt) &&
+ isNothing (lookup "alt" attrList)] )
mediaTag tg fallbackTxt =
let linkTxt = if null txt
then fallbackTxt
diff --git a/test/command/7416.md b/test/command/7416.md
new file mode 100644
index 000000000..70a0257fa
--- /dev/null
+++ b/test/command/7416.md
@@ -0,0 +1,19 @@
+```
+% pandoc -f markdown -t html
+{alt="alt"}
+
+^D
+
+
caption
+
+```
+
+```
+% pandoc -f markdown -t html
+
+
+^D
+
+
caption
+
+```
--
cgit v1.2.3