git.iko.soy/typeable/pandoc
on master help sign in
Parsing: More improvements of anyLine parser.
commitf989ff2d5d6da01d2c0ac70429c0a0bc5e207ff4 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 25 Jan 2013, 18:32 (14 years ago) parentd27dc6a
1 file changed+8−6
src/Text/Pandoc/Parsing.hs+8−6
src/Text/Pandoc/Parsing.hs+8−6
@@ -195,12 +195,14 @@ anyLine = do
195195 -- manyTill anyChar newline
196196 inp <- getInput
197197 pos <- getPosition
198− let (this, rest) = break (=='\n') inp
199− setInput rest
200− let newpos = incSourceLine (setSourceColumn pos 0) 1
201− setPosition newpos
202− void (char '\n') <|> (guard (not $ null this) >> eof)
203− return this
198+ case break (=='\n') inp of
199+ (this, '\n':rest) -> do
200+ -- needed to persuade parsec that this won't match an empty string:
201+ anyChar
202+ setInput rest
203+ setPosition $ incSourceLine (setSourceColumn pos 1) 1
204+ return this
205+ _ -> mzero
204206
205207-- | Like @manyTill@, but reads at least one item.
206208many1Till :: Parser [tok] st a