diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-25 18:32:06 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-25 18:32:06 -0800 |
commit | f989ff2d5d6da01d2c0ac70429c0a0bc5e207ff4 (patch) | |
tree | ef3618caf96bf4df2d9bd2ae36de116e58302078 /src | |
parent | d27dc6a420845ed1b9fd0af96941a546dcd8b98d (diff) | |
download | pandoc-f989ff2d5d6da01d2c0ac70429c0a0bc5e207ff4.tar.gz |
Parsing: More improvements of anyLine parser.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 14 |
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 |