Markdown citation parser: small refactoring for clarity.

This commit is contained in:
John MacFarlane 2010-11-18 14:16:18 -08:00
parent bbb60a2586
commit 6390103509

View file

@ -1325,6 +1325,10 @@ blankSpace = try $ do
guard $ length res > 0 guard $ length res > 0
guard $ length (filter (=='\n') res) <= 1 guard $ length (filter (=='\n') res) <= 1
noneOfUnlessEscaped :: [Char] -> GenParser Char st Char
noneOfUnlessEscaped cs =
try (char '\\' >> oneOf cs) <|> noneOf cs
textualCite :: GenParser Char ParserState [Citation] textualCite :: GenParser Char ParserState [Citation]
textualCite = try $ do textualCite = try $ do
(_, key) <- citeKey (_, key) <- citeKey
@ -1382,7 +1386,7 @@ locator = try $ do
locatorWord :: GenParser Char st String locatorWord :: GenParser Char st String
locatorWord = try $ do locatorWord = try $ do
spnl spnl
wd <- many1 $ (try $ char '\\' >> oneOf "];, \t\n") <|> noneOf "];, \t\n" wd <- many1 $ noneOfUnlessEscaped "];, \t\n"
guard $ any isDigit wd guard $ any isDigit wd
return wd return wd