git.iko.soy/typeable/pandoc
on master help sign in
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

commitbdf78fe33f09979cc0542623e0023a0c3750ba55 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 1 Sep 2007, 02:01 (19 years ago) parentf55d62c
1 file changed+5−1
src/Text/Pandoc/Readers/Markdown.hs+5−1
src/Text/Pandoc/Readers/Markdown.hs+5−1
@@ -227,7 +227,7 @@ block = choice [ header
227227-- header blocks
228228--
229229
230−header = setextHeader <|> atxHeader <?> "header"
230+header = atxHeader <|> setextHeader <?> "header"
231231
232232atxHeader = try $ do
233233 level <- many1 (char '#') >>= return . length
@@ -239,6 +239,8 @@ atxHeader = try $ do
239239atxClosing = try $ skipMany (char '#') >> blanklines
240240
241241setextHeader = try $ do
242+ -- first, see if this block has any chance of being a setextHeader:
243+ lookAhead (anyLine >> oneOf setextHChars)
242244 text <- many1Till inline newline >>= return . normalizeSpaces
243245 level <- choice $ zipWith
244246 (\ch lev -> try (many1 $ char ch) >> blanklines >> return lev)
@@ -406,6 +408,8 @@ bulletList = many1 (listItem bulletListStart) >>=
406408definitionListItem = try $ do
407409 notFollowedBy blankline
408410 notFollowedBy' indentSpaces
411+ -- first, see if this has any chance of being a definition list:
412+ lookAhead (anyLine >> char ':')
409413 term <- manyTill inline newline
410414 raw <- many1 defRawBlock
411415 state <- getState