git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: use raw HTML for link/image attributes when
6d91fb2John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+12−2
@@ -906,7 +906,12 @@ inlineToMarkdown opts (Cite (c:cs) lst)
906 return $ pdoc <+> r
906 return $ pdoc <+> r
907 modekey SuppressAuthor = "-"
907 modekey SuppressAuthor = "-"
908 modekey _ = ""
908 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
910 plain <- gets stPlain
915 plain <- gets stPlain
911 linktext <- inlineListToMarkdown opts txt
916 linktext <- inlineListToMarkdown opts txt
912 let linktitle = if null tit
917 let linktitle = if null tit
@@ -940,7 +945,12 @@ inlineToMarkdown opts (Link attr txt (src, tit)) = do
940 else "[" <> linktext <> "](" <>
945 else "[" <> linktext <> "](" <>
941 text src <> linktitle <> ")" <>
946 text src <> linktitle <> ")" <>
942 linkAttributes opts attr
947 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
944 plain <- gets stPlain
954 plain <- gets stPlain
945 let txt = if null alternate || alternate == [Str source]
955 let txt = if null alternate || alternate == [Str source]
946 -- to prevent autolinks
956 -- to prevent autolinks