summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-02-15 22:39:49 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-02-15 22:39:49 -0800
commit59764fa3884e63ee9711cc2d0da2ef3133c641ba (patch)
tree37ccf85baf7dbebb5241b7da6d35f565f8d5af95
parent5491adbfdb0a1c75d2008ad40da7136dffeeb161 (diff)
Parsing: uri, email: resolve entities.
A markdown link `<http://g&ouml;ogle.com>` should be a link to http://göogle.com.
-rw-r--r--src/Text/Pandoc/Parsing.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index ebff8ec77..062e66eff 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -149,6 +149,7 @@ where
import Text.Pandoc.Definition
import Text.Pandoc.Options
import Text.Pandoc.Builder (Blocks, Inlines, rawBlock)
+import Text.Pandoc.XML (fromEntities)
import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
import Text.Parsec
import Text.Parsec.Pos (newPos)
@@ -369,7 +370,7 @@ romanNumeral upperCase = do
-- escaped mailto: URI.
emailAddress :: Parser [Char] st (String, String)
emailAddress = try $ liftA2 toResult mailbox (char '@' *> domain)
- where toResult mbox dom = let full = mbox ++ '@':dom
+ where toResult mbox dom = let full = fromEntities $ mbox ++ '@':dom
in (full, escapeURI $ "mailto:" ++ full)
mailbox = intercalate "." `fmap` (emailWord `sepby1` dot)
domain = intercalate "." `fmap` (subdomain `sepby1` dot)
@@ -440,7 +441,7 @@ uri = try $ do
<|> enclosed (char '[') (char ']') uriChunk)
<|> uriChunk))
str' <- option str $ char '/' >> return (str ++ "/")
- let uri' = scheme ++ ":" ++ str'
+ let uri' = scheme ++ ":" ++ fromEntities str'
return (uri', escapeURI uri')
-- | Applies a parser, returns tuple of its results and its horizontal