aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2017-11-20 16:48:43 -0800
committerJohn MacFarlane <[email protected]>2017-11-20 16:48:43 -0800
commit04d9b9b6df55af0f64f8669f5b352b573d8ebcba (patch)
treee31b8d97ef75ad2902580a40905b2302256bb8c3 /src/Text/Pandoc
parent35ced1621df6b1dfe7de79e994343a539b624d8d (diff)
Allow URI as cite key.uri-cite-key
This affects Markdown and Org with `+citations`. Note that we had to constrain the type of the `citeKey` parser in `Text.Pandoc.Parsing` to accept `[Char]` instead of arbitrary streams.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Parsing.hs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index c86f6718a..9475081c4 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -548,7 +548,7 @@ emailAddress = try $ toResult <$> mailbox <*> (char '@' *> domain)
sepby1 p sep = (:) <$> p <*> many (try $ sep >> p)
-uriScheme :: Stream s m Char => ParserT s st m String
+uriScheme :: (Monad m, Stream s m Char) => ParserT s st m String
uriScheme = oneOfStringsCI (Set.toList schemes)
-- | Parses a URI. Returns pair of original and URI-escaped version.
@@ -1388,18 +1388,20 @@ nested p = do
updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
return res
-citeKey :: (Stream s m Char, HasLastStrPosition st)
- => ParserT s st m (Bool, String)
+citeKey :: (Monad m, HasLastStrPosition st)
+ => ParserT [Char] st m (Bool, String)
citeKey = try $ do
guard =<< notAfterString
suppress_author <- option False (char '-' *> return True)
char '@'
- firstChar <- alphaNum <|> char '_' <|> char '*' -- @* for wildcard in nocite
- let regchar = satisfy (\c -> isAlphaNum c || c == '_')
- let internal p = try $ p <* lookAhead regchar
- rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/") <|>
- try (oneOf ":/" <* lookAhead (char '/'))
- let key = firstChar:rest
+ key <- (fst <$> uri) <|>
+ do firstChar <- alphaNum <|> char '_' <|> char '*'
+ -- @* for wildcard in nocite
+ let regchar = satisfy (\c -> isAlphaNum c || c == '_')
+ let internal p = try $ p <* lookAhead regchar
+ rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/") <|>
+ try (oneOf ":/" <* lookAhead (char '/'))
+ return (firstChar:rest)
return (suppress_author, key)