diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-28 22:05:22 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-28 22:05:22 -0800 |
commit | 649608d3241eb2222502b9610a8c86fbfe282e9a (patch) | |
tree | e6a8748edbfa0987ad89fcbf85e3de2c2f06acf3 | |
parent | abdaa96b03e8186237032f6c4df0edca34155bb1 (diff) | |
download | pandoc-649608d3241eb2222502b9610a8c86fbfe282e9a.tar.gz |
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
`<http://openclipart.org/detail/22566/lego-smiley----happy-by-pitr>`
should work now.
Closes #768.
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 9 |
1 files changed, 7 insertions, 2 deletions
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 `<http://hi---there>`, + -- 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 |