aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-12-07 13:24:19 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2020-12-07 13:24:19 -0800
commitce1791913da713ec35f514006bb532cb9c9c8d22 (patch)
treeee099b2fd36a809626173c42b4844da613a1efa0 /src/Text/Pandoc
parent2f9b684b3a793896bc28a79a07722415cfdc075e (diff)
downloadpandoc-ce1791913da713ec35f514006bb532cb9c9c8d22.tar.gz
Small efficiency improvement in uri parser
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Parsing.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 1d9e182c5..1e8518c90 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -654,7 +654,20 @@ uri = try $ do
let uri' = scheme <> ":" <> fromEntities str'
return (uri', escapeURI uri')
where
- wordChar = alphaNum <|> oneOf "#$%+/@\\_-&="
+ isWordChar '#' = True
+ isWordChar '$' = True
+ isWordChar '%' = True
+ isWordChar '+' = True
+ isWordChar '/' = True
+ isWordChar '@' = True
+ isWordChar '\\' = True
+ isWordChar '_' = True
+ isWordChar '-' = True
+ isWordChar '&' = True
+ isWordChar '=' = True
+ isWordChar c = isAlphaNum c
+
+ wordChar = satisfy isWordChar
percentEscaped = try $ (:) <$> char '%' <*> many1 hexDigit
entity = try $ pure <$> characterReference
punct = try $ many1 (char ',') <|> fmap pure (satisfy (\c -> not (isSpace c) && c /= '<' && c /= '>'))