git.iko.soy/typeable/pandoc
on master help sign in
Remove duplicated alt text in HTML output.
commitf4ef652a4165fefe4b587882cc75d1e24971ef1f authorAner Lucero <4rgento@gmail.com> dateTue 29 Jun 2021, 08:49 (5 years ago) parent382be73
2 files changed+22−2
src/Text/Pandoc/Writers/HTML.hs+3−2 test/command/7416.md+19
src/Text/Pandoc/Writers/HTML.hs+3−2
@@ -1433,7 +1433,7 @@ inlineToHtml opts inline = do
14331433 return $ if T.null tit
14341434 then link'
14351435 else link' ! A.title (toValue tit)
1436− (Image attr txt (s,tit)) -> do
1436+ (Image attr@(_, _, attrList) txt (s, tit)) -> do
14371437 let alternate = stringify txt
14381438 slideVariant <- gets stSlideVariant
14391439 let isReveal = slideVariant == RevealJsSlides
@@ -1446,7 +1446,8 @@ inlineToHtml opts inline = do
14461446 [A.title $ toValue tit | not (T.null tit)] ++
14471447 attrs
14481448 imageTag = (if html5 then H5.img else H.img
1449− , [A.alt $ toValue alternate | not (null txt)] )
1449+ , [A.alt $ toValue alternate | not (null txt) &&
1450+ isNothing (lookup "alt" attrList)] )
14501451 mediaTag tg fallbackTxt =
14511452 let linkTxt = if null txt
14521453 then fallbackTxt
test/command/7416.mdnew file+19
@@ -0,0 +1,19 @@
1+```
2+% pandoc -f markdown -t html
3+![caption](../media/rId25.jpg "title"){alt="alt"}
4+
5+^D
6+<figure>
7+<img src="../media/rId25.jpg" title="title" alt="alt" /><figcaption aria-hidden="true">caption</figcaption>
8+</figure>
9+```
10+
11+```
12+% pandoc -f markdown -t html
13+![caption](../media/rId25.jpg "title")
14+
15+^D
16+<figure>
17+<img src="../media/rId25.jpg" title="title" alt="caption" /><figcaption aria-hidden="true">caption</figcaption>
18+</figure>
19+```