Skip to content

Commit

Permalink
Markdown: allow ---- in angle-bracket autolinks.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
John MacFarlane committed Mar 1, 2013
1 parent abdaa96 commit 649608d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Text/Pandoc/Readers/Markdown.hs
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 649608d

Please sign in to comment.