git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Don't autolink a bare URI that is followed by `</a>`.

Closes #937.

commit9b0b9b6e03c05ca81ff3cf52787a30ea00cb3a76 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 1 Sep 2013, 15:18 (13 years ago) parent8b0052b
2 files changed+5−1
src/Text/Pandoc/Readers/Markdown.hs+1 tests/Tests/Readers/Markdown.hs+4−1
src/Text/Pandoc/Readers/Markdown.hs+1
@@ -1662,6 +1662,7 @@ bareURL :: MarkdownParser (F Inlines)
16621662bareURL = try $ do
16631663 guardEnabled Ext_autolink_bare_uris
16641664 (orig, src) <- uri <|> emailAddress
1665+ notFollowedBy $ try $ spaces >> htmlTag (~== TagClose "a")
16651666 return $ return $ B.link src "" (B.str orig)
16661667
16671668autoLink :: MarkdownParser (F Inlines)
tests/Tests/Readers/Markdown.hs+4−1
@@ -24,7 +24,7 @@ infix 4 =:
2424testBareLink :: (String, Inlines) -> Test
2525testBareLink (inp, ils) =
2626 test (readMarkdown def{ readerExtensions =
27− Set.fromList [Ext_autolink_bare_uris] })
27+ Set.fromList [Ext_autolink_bare_uris, Ext_raw_html] })
2828 inp (inp, doc $ para ils)
2929
3030autolink :: String -> Inlines
@@ -34,6 +34,9 @@ bareLinkTests :: [(String, Inlines)]
3434bareLinkTests =
3535 [ ("http://google.com is a search engine.",
3636 autolink "http://google.com" <> " is a search engine.")
37+ , ("<a href=\"http://foo.bar.baz\">http://foo.bar.baz</a>",
38+ rawInline "html" "<a href=\"http://foo.bar.baz\">" <>
39+ "http://foo.bar.baz" <> rawInline "html" "</a>")
3740 , ("Try this query: http://google.com?search=fish&time=hour.",
3841 "Try this query: " <> autolink "http://google.com?search=fish&time=hour" <> ".")
3942 , ("HTTPS://GOOGLE.COM,",