git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: use raw HTML for link/image attributes when

the `link_attributes` extension is unset and `raw_html` is set. Closes #2554.

commit6d91fb25639c6ac985d15c7112e009533d06e5f2 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 24 Nov 2015, 23:28 (11 years ago) parent2df4f39
1 file changed+12−2
src/Text/Pandoc/Writers/Markdown.hs+12−2
src/Text/Pandoc/Writers/Markdown.hs+12−2
@@ -906,7 +906,12 @@ inlineToMarkdown opts (Cite (c:cs) lst)
906906 return $ pdoc <+> r
907907 modekey SuppressAuthor = "-"
908908 modekey _ = ""
909−inlineToMarkdown opts (Link attr txt (src, tit)) = do
909+inlineToMarkdown opts lnk@(Link attr txt (src, tit))
910+ | isEnabled Ext_raw_html opts &&
911+ not (isEnabled Ext_link_attributes opts) &&
912+ attr /= nullAttr = -- use raw HTML
913+ return $ text $ trim $ writeHtmlString def $ Pandoc nullMeta [Plain [lnk]]
914+ | otherwise = do
910915 plain <- gets stPlain
911916 linktext <- inlineListToMarkdown opts txt
912917 let linktitle = if null tit
@@ -940,7 +945,12 @@ inlineToMarkdown opts (Link attr txt (src, tit)) = do
940945 else "[" <> linktext <> "](" <>
941946 text src <> linktitle <> ")" <>
942947 linkAttributes opts attr
943−inlineToMarkdown opts (Image attr alternate (source, tit)) = do
948+inlineToMarkdown opts img@(Image attr alternate (source, tit))
949+ | isEnabled Ext_raw_html opts &&
950+ not (isEnabled Ext_link_attributes opts) &&
951+ attr /= nullAttr = -- use raw HTML
952+ return $ text $ trim $ writeHtmlString def $ Pandoc nullMeta [Plain [img]]
953+ | otherwise = do
944954 plain <- gets stPlain
945955 let txt = if null alternate || alternate == [Str source]
946956 -- to prevent autolinks