summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Parsing.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 2a5780f8f..7a3c5f27b 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -190,7 +190,14 @@ a >>~ b = a >>= \x -> b >> return x
-- | Parse any line of text
anyLine :: Parser [Char] st [Char]
-anyLine = manyTill anyChar newline
+anyLine = do
+ -- This is much faster than:
+ -- manyTill anyChar newline
+ inp <- getInput
+ let (this, rest) = break (=='\n') inp
+ setInput rest
+ void (char '\n') <|> (guard (not $ null this) >> eof)
+ return this
-- | Like @manyTill@, but reads at least one item.
many1Till :: Parser [tok] st a