diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-15 22:56:53 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-15 23:02:17 -0800 |
commit | cc410a71b58de1fa0e508a092b7c1d8ba6d3d3ab (patch) | |
tree | 8787b90c78b7367e46a61833a4bd721e255ab73c | |
parent | 59764fa3884e63ee9711cc2d0da2ef3133c641ba (diff) | |
download | pandoc-cc410a71b58de1fa0e508a092b7c1d8ba6d3d3ab.tar.gz |
Allow `&` in emails (for entities).
Added tests for entities in titles and links.
Closes #723.
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 2 | ||||
-rw-r--r-- | tests/markdown-reader-more.native | 7 | ||||
-rw-r--r-- | tests/markdown-reader-more.txt | 11 |
4 files changed, 19 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 062e66eff..0bb609e5d 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -380,7 +380,7 @@ emailAddress = try $ liftA2 toResult mailbox (char '@' *> domain) notFollowedBy space) emailWord = many1 $ satisfy isEmailChar isEmailChar c = isAlphaNum c || isEmailPunct c - isEmailPunct c = c `elem` "!\"#$%&'*+-/=?^_{|}~" + isEmailPunct c = c `elem` "!\"#$%&'*+-/=?^_{|}~;" -- note: sepBy1 from parsec consumes input when sep -- succeeds and p fails, so we use this variant here. sepby1 p sep = liftA2 (:) p (many (try $ sep >> p)) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 74485fb9d..e037c0897 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -264,7 +264,7 @@ referenceKey = try $ do optional $ newline >> notFollowedBy blankline skipMany spaceChar notFollowedBy' (() <$ reference) - many1 $ escapedChar' <|> satisfy (not . isBlank) + many1 $ notFollowedBy space >> litChar let betweenAngles = try $ char '<' >> manyTill (escapedChar' <|> litChar) (char '>') src <- try betweenAngles <|> sourceURL diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native index 69b29992c..84d3a71e2 100644 --- a/tests/markdown-reader-more.native +++ b/tests/markdown-reader-more.native @@ -124,4 +124,9 @@ [[] ,[]] [[[] - ,[]]]] + ,[]]] +,Header 2 ("entities-in-links-and-titles",[],[]) [Str "Entities",Space,Str "in",Space,Str "links",Space,Str "and",Space,Str "titles"] +,Para [Link [Str "link"] ("/\252rl","\246\246!")] +,Para [Link [Str "http://g\246\246gle.com"] ("http://g\246\246gle.com","")] +,Para [Link [Str "me@ex\228mple.com"] ("mailto:me@ex\228mple.com","")] +,Para [Link [Str "foobar"] ("/\252rl","\246\246!")]] diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt index e471100d2..b0a4ff6e8 100644 --- a/tests/markdown-reader-more.txt +++ b/tests/markdown-reader-more.txt @@ -208,3 +208,14 @@ Empty cells | | | +---+---+ +## Entities in links and titles + +[link](/ürl "öö!") + +<http://göögle.com> + +<me@exämple.com> + +[foobar] + +[foobar]: /ürl "öö!" |