aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-09-01 02:01:12 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-09-01 02:01:12 +0000
commitbdf78fe33f09979cc0542623e0023a0c3750ba55 (patch)
treec222f634ef6f9b9cde0043961ff46b1353af4a6c
parentf55d62c04ae0f6ca9b0bb7050ab9ce72f21a67df (diff)
downloadpandoc-bdf78fe33f09979cc0542623e0023a0c3750ba55.tar.gz
Use lookAhead in parsers for setext headers and
definition lists to see if the next line begins appropriately; if not, don't waste any more time parsing... git-svn-id: https://pandoc.googlecode.com/svn/trunk@976 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 1159d4269..0306ed7c5 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -227,7 +227,7 @@ block = choice [ header
-- header blocks
--
-header = setextHeader <|> atxHeader <?> "header"
+header = atxHeader <|> setextHeader <?> "header"
atxHeader = try $ do
level <- many1 (char '#') >>= return . length
@@ -239,6 +239,8 @@ atxHeader = try $ do
atxClosing = try $ skipMany (char '#') >> blanklines
setextHeader = try $ do
+ -- first, see if this block has any chance of being a setextHeader:
+ lookAhead (anyLine >> oneOf setextHChars)
text <- many1Till inline newline >>= return . normalizeSpaces
level <- choice $ zipWith
(\ch lev -> try (many1 $ char ch) >> blanklines >> return lev)
@@ -406,6 +408,8 @@ bulletList = many1 (listItem bulletListStart) >>=
definitionListItem = try $ do
notFollowedBy blankline
notFollowedBy' indentSpaces
+ -- first, see if this has any chance of being a definition list:
+ lookAhead (anyLine >> char ':')
term <- manyTill inline newline
raw <- many1 defRawBlock
state <- getState