aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Markdown.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2013-12-04 10:00:40 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2013-12-04 10:18:05 -0800
commit5314df51f368853f7ee4bf8f75eedf43afc0400e (patch)
treebadab107cbc4e8d973d161b6975feaaeaa40134b /src/Text/Pandoc/Readers/Markdown.hs
parenteebb15ba1d135169495641748bbe83cb6899441b (diff)
downloadpandoc-5314df51f368853f7ee4bf8f75eedf43afc0400e.tar.gz
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>`.
Diffstat (limited to 'src/Text/Pandoc/Readers/Markdown.hs')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 33d1a9620..4cb75d86c 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -732,7 +732,8 @@ listLine = try $ do
notFollowedBy' (do indentSpaces
many (spaceChar)
listStart)
- chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 anyChar) newline
+ chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 (satisfy (/='<'))
+ <|> (notFollowedBy' (htmlTag isBlockTag) >> count 1 anyChar)) newline
return $ concat chunks
-- parse raw text for one list item, excluding start marker and continuations
@@ -759,6 +760,7 @@ listContinuationLine :: MarkdownParser String
listContinuationLine = try $ do
notFollowedBy blankline
notFollowedBy' listStart
+ notFollowedBy' $ try $ skipMany spaceChar >> htmlTag (~== TagClose "div")
optional indentSpaces
result <- anyLine
return $ result ++ "\n"