mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-21 15:05:47 +00:00
Parsing: More improvements of anyLine parser.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user