summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-11-24 23:28:22 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-11-24 23:28:52 -0800
commit6d91fb25639c6ac985d15c7112e009533d06e5f2 (patch)
tree86dfbc2db26d05aac23c6b3847706b19c68996b3 /src
parent2df4f39db3eb0c4323727d73d1849a6430d72146 (diff)
Markdown writer: use raw HTML for link/image attributes when
the `link_attributes` extension is unset and `raw_html` is set. Closes #2554.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 9f06aa054..ab36832f2 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -906,7 +906,12 @@ inlineToMarkdown opts (Cite (c:cs) lst)
return $ pdoc <+> r
modekey SuppressAuthor = "-"
modekey _ = ""
-inlineToMarkdown opts (Link attr txt (src, tit)) = do
+inlineToMarkdown opts lnk@(Link attr txt (src, tit))
+ | isEnabled Ext_raw_html opts &&
+ not (isEnabled Ext_link_attributes opts) &&
+ attr /= nullAttr = -- use raw HTML
+ return $ text $ trim $ writeHtmlString def $ Pandoc nullMeta [Plain [lnk]]
+ | otherwise = do
plain <- gets stPlain
linktext <- inlineListToMarkdown opts txt
let linktitle = if null tit
@@ -940,7 +945,12 @@ inlineToMarkdown opts (Link attr txt (src, tit)) = do
else "[" <> linktext <> "](" <>
text src <> linktitle <> ")" <>
linkAttributes opts attr
-inlineToMarkdown opts (Image attr alternate (source, tit)) = do
+inlineToMarkdown opts img@(Image attr alternate (source, tit))
+ | isEnabled Ext_raw_html opts &&
+ not (isEnabled Ext_link_attributes opts) &&
+ attr /= nullAttr = -- use raw HTML
+ return $ text $ trim $ writeHtmlString def $ Pandoc nullMeta [Plain [img]]
+ | otherwise = do
plain <- gets stPlain
let txt = if null alternate || alternate == [Str source]
-- to prevent autolinks