git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: Fix autolinks rendering for gfm.

Previously, autolinks rendered as raw HTML, due to the `class="uri"` added by pandoc's markdown reader. Closes #6740.

commit2007cff20318e1f086623e8fed16dcf927b1e027 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 12 Oct 2020, 18:57 (6 years ago) parent4789fc5
2 files changed+30−24
src/Text/Pandoc/Writers/Markdown.hs+23−24 test/command/6740.md+7
src/Text/Pandoc/Writers/Markdown.hs+23−24
@@ -1296,13 +1296,7 @@ inlineToMarkdown opts (Cite (c:cs) lst)
12961296 return $ pdoc <+> r
12971297 modekey SuppressAuthor = "-"
12981298 modekey _ = ""
1299−inlineToMarkdown opts lnk@(Link attr txt (src, tit))
1300− | isEnabled Ext_raw_html opts &&
1301− not (isEnabled Ext_link_attributes opts) &&
1302− attr /= nullAttr = -- use raw HTML
1303− literal . T.strip <$>
1304− writeHtml5String opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain [lnk]])
1305− | otherwise = do
1299+inlineToMarkdown opts lnk@(Link attr txt (src, tit)) = do
13061300 variant <- asks envVariant
13071301 linktext <- inlineListToMarkdown opts txt
13081302 let linktitle = if T.null tit
@@ -1320,23 +1314,28 @@ inlineToMarkdown opts lnk@(Link attr txt (src, tit))
13201314 reftext <- if useRefLinks
13211315 then literal <$> getReference attr linktext (src, tit)
13221316 else return mempty
1323− return $ if useAuto
1324− then case variant of
1325− PlainText -> literal srcSuffix
1326− _ -> "<" <> literal srcSuffix <> ">"
1327− else if useRefLinks
1328− then let first = "[" <> linktext <> "]"
1329− second = if getKey linktext == getKey reftext
1330− then if useShortcutRefLinks
1331− then ""
1332− else "[]"
1333− else "[" <> reftext <> "]"
1334− in first <> second
1335− else case variant of
1336− PlainText -> linktext
1337− _ -> "[" <> linktext <> "](" <>
1338− literal src <> linktitle <> ")" <>
1339− linkAttributes opts attr
1317+ case variant of
1318+ PlainText
1319+ | useAuto -> return $ literal srcSuffix
1320+ | otherwise -> return linktext
1321+ _ | useAuto -> return $ "<" <> literal srcSuffix <> ">"
1322+ | useRefLinks ->
1323+ let first = "[" <> linktext <> "]"
1324+ second = if getKey linktext == getKey reftext
1325+ then if useShortcutRefLinks
1326+ then ""
1327+ else "[]"
1328+ else "[" <> reftext <> "]"
1329+ in return $ first <> second
1330+ | isEnabled Ext_raw_html opts
1331+ , not (isEnabled Ext_link_attributes opts)
1332+ , attr /= nullAttr -> -- use raw HTML to render attributes
1333+ literal . T.strip <$>
1334+ writeHtml5String opts{ writerTemplate = Nothing }
1335+ (Pandoc nullMeta [Plain [lnk]])
1336+ | otherwise -> return $
1337+ "[" <> linktext <> "](" <> literal src <> linktitle <> ")" <>
1338+ linkAttributes opts attr
13401339inlineToMarkdown opts img@(Image attr alternate (source, tit))
13411340 | isEnabled Ext_raw_html opts &&
13421341 not (isEnabled Ext_link_attributes opts) &&
test/command/6740.mdnew file+7
@@ -0,0 +1,7 @@
1+```
2+% pandoc -t gfm
3+<https://www.google.com>
4+^D
5+<https://www.google.com>
6+```
7+