git.iko.soy/typeable/pandoc
on master help sign in
Move `citeKey` from Readers.Markdown to Parsing
2423f9eAlbert Krewinkel
src/Text/Pandoc/Parsing.hs+13
@@ -94,6 +94,7 @@ module Text.Pandoc.Parsing ( (>>~),
94 apostrophe,
94 apostrophe,
95 dash,
95 dash,
96 nested,
96 nested,
97+ citeKey,
97 macro,
98 macro,
98 applyMacros',
99 applyMacros',
99 Parser,
100 Parser,
@@ -1144,6 +1145,18 @@ nested p = do
1144 updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
1145 updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
1145 return res
1146 return res
1146
1147
1148+citeKey :: HasLastStrPosition st => Parser [Char] st (Bool, String)
1149+citeKey = try $ do
1150+ guard =<< notAfterString
1151+ suppress_author <- option False (char '-' *> return True)
1152+ char '@'
1153+ firstChar <- letter <|> char '_'
1154+ let regchar = satisfy (\c -> isAlphaNum c || c == '_')
1155+ let internal p = try $ p <* lookAhead regchar
1156+ rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/")
1157+ let key = firstChar:rest
1158+ return (suppress_author, key)
1159+
1147--
1160--
1148-- Macros
1161-- Macros
1149--
1162--
src/Text/Pandoc/Readers/Markdown.hs−14
@@ -1814,20 +1814,6 @@ normalCite = try $ do
1814 char ']'
1814 char ']'
1815 return citations
1815 return citations
1816
1816
1817−citeKey :: MarkdownParser (Bool, String)
1818−citeKey = try $ do
1819− -- make sure we're not right after an alphanumeric,
1820− -- since foo@bar.baz is probably an email address
1821− guard =<< notAfterString
1822− suppress_author <- option False (char '-' >> return True)
1823− char '@'
1824− first <- letter <|> char '_'
1825− let regchar = satisfy (\c -> isAlphaNum c || c == '_')
1826− let internal p = try $ p >>~ lookAhead regchar
1827− rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/")
1828− let key = first:rest
1829− return (suppress_author, key)
1830−
1831suffix :: MarkdownParser (F Inlines)
1817suffix :: MarkdownParser (F Inlines)
1832suffix = try $ do
1818suffix = try $ do
1833 hasSpace <- option False (notFollowedBy nonspaceChar >> return True)
1819 hasSpace <- option False (notFollowedBy nonspaceChar >> return True)