From 6d91fb25639c6ac985d15c7112e009533d06e5f2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 24 Nov 2015 23:28:22 -0800 Subject: Markdown writer: use raw HTML for link/image attributes when the `link_attributes` extension is unset and `raw_html` is set. Closes #2554. --- src/Text/Pandoc/Writers/Markdown.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/Text') 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 -- cgit v1.2.3