aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-25 18:32:06 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-25 18:32:06 -0800
commitf989ff2d5d6da01d2c0ac70429c0a0bc5e207ff4 (patch)
treeef3618caf96bf4df2d9bd2ae36de116e58302078 /src
parentd27dc6a420845ed1b9fd0af96941a546dcd8b98d (diff)
downloadpandoc-f989ff2d5d6da01d2c0ac70429c0a0bc5e207ff4.tar.gz
Parsing: More improvements of anyLine parser.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Parsing.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 8fbcc54b4..0ab4c0694 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -195,12 +195,14 @@ anyLine = do
-- manyTill anyChar newline
inp <- getInput
pos <- getPosition
- let (this, rest) = break (=='\n') inp
- setInput rest
- let newpos = incSourceLine (setSourceColumn pos 0) 1
- setPosition newpos
- void (char '\n') <|> (guard (not $ null this) >> eof)
- return this
+ case break (=='\n') inp of
+ (this, '\n':rest) -> do
+ -- needed to persuade parsec that this won't match an empty string:
+ anyChar
+ setInput rest
+ setPosition $ incSourceLine (setSourceColumn pos 1) 1
+ return this
+ _ -> mzero
-- | Like @manyTill@, but reads at least one item.
many1Till :: Parser [tok] st a