From 649608d3241eb2222502b9610a8c86fbfe282e9a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 28 Feb 2013 22:05:22 -0800 Subject: Markdown: allow ---- in angle-bracket autolinks. The uri parser is designed for bare URIs. In angle-bracket contexts, we can be sure that we don't have trailing punctuation. So `` should work now. Closes #768. --- src/Text/Pandoc/Readers/Markdown.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 29eac02bf..c311ff158 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -41,6 +41,7 @@ import qualified Text.Pandoc.Builder as B import Text.Pandoc.Builder (Inlines, Blocks, trimInlines, (<>)) import Text.Pandoc.Options import Text.Pandoc.Shared +import Text.Pandoc.XML (fromEntities) import Text.Pandoc.Parsing hiding (tableWith) import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock ) import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag, @@ -1565,8 +1566,12 @@ autoLink :: MarkdownParser (F Inlines) autoLink = try $ do char '<' (orig, src) <- uri <|> emailAddress - char '>' - return $ return $ B.link src "" (B.str orig) + -- in rare cases, something may remain after the uri parser + -- is finished, because the uri parser tries to avoid parsing + -- final punctuation. for example: in ``, + -- the URI parser will stop before the dashes. + extra <- fromEntities <$> manyTill nonspaceChar (char '>') + return $ return $ B.link (src ++ escapeURI extra) "" (B.str $ orig ++ extra) image :: MarkdownParser (F Inlines) image = try $ do -- cgit v1.2.3