git.iko.soy/typeable/pandoc
on master help sign in
Stop parsing "list lines" when we hit a block tag.

This fixes exponential slowdown in certain input, e.g. a series of lists followed by `</div>`.

commit5314df51f368853f7ee4bf8f75eedf43afc0400e authorJohn MacFarlane <jgm@berkeley.edu> dateWed 4 Dec 2013, 10:00 (13 years ago) parenteebb15b
1 file changed+3−1
src/Text/Pandoc/Readers/Markdown.hs+3−1
src/Text/Pandoc/Readers/Markdown.hs+3−1
@@ -732,7 +732,8 @@ listLine = try $ do
732732 notFollowedBy' (do indentSpaces
733733 many (spaceChar)
734734 listStart)
735− chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 anyChar) newline
735+ chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 (satisfy (/='<'))
736+ <|> (notFollowedBy' (htmlTag isBlockTag) >> count 1 anyChar)) newline
736737 return $ concat chunks
737738
738739-- parse raw text for one list item, excluding start marker and continuations
@@ -759,6 +760,7 @@ listContinuationLine :: MarkdownParser String
759760listContinuationLine = try $ do
760761 notFollowedBy blankline
761762 notFollowedBy' listStart
763+ notFollowedBy' $ try $ skipMany spaceChar >> htmlTag (~== TagClose "div")
762764 optional indentSpaces
763765 result <- anyLine
764766 return $ result ++ "\n"