git.iko.soy/typeable/pandoc
on master help sign in
Remove duplicated alt text in HTML output.
f4ef652Aner Lucero
src/Text/Pandoc/Writers/HTML.hs+3−2
@@ -1433,7 +1433,7 @@ inlineToHtml opts inline = do
1433 return $ if T.null tit
1433 return $ if T.null tit
1434 then link'
1434 then link'
1435 else link' ! A.title (toValue tit)
1435 else link' ! A.title (toValue tit)
1436− (Image attr txt (s,tit)) -> do
1436+ (Image attr@(_, _, attrList) txt (s, tit)) -> do
1437 let alternate = stringify txt
1437 let alternate = stringify txt
1438 slideVariant <- gets stSlideVariant
1438 slideVariant <- gets stSlideVariant
1439 let isReveal = slideVariant == RevealJsSlides
1439 let isReveal = slideVariant == RevealJsSlides
@@ -1446,7 +1446,8 @@ inlineToHtml opts inline = do
1446 [A.title $ toValue tit | not (T.null tit)] ++
1446 [A.title $ toValue tit | not (T.null tit)] ++
1447 attrs
1447 attrs
1448 imageTag = (if html5 then H5.img else H.img
1448 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)] )
1450 mediaTag tg fallbackTxt =
1451 mediaTag tg fallbackTxt =
1451 let linkTxt = if null txt
1452 let linkTxt = if null txt
1452 then fallbackTxt
1453 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+```