git.iko.soy/typeable/pandoc
on master help sign in
Use lookAhead in parsers for setext headers and
bdf78fefiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+5−1
@@ -227,7 +227,7 @@ block = choice [ header
227-- header blocks
227-- header blocks
228--
228--
229
229
230−header = setextHeader <|> atxHeader <?> "header"
230+header = atxHeader <|> setextHeader <?> "header"
231
231
232atxHeader = try $ do
232atxHeader = try $ do
233 level <- many1 (char '#') >>= return . length
233 level <- many1 (char '#') >>= return . length
@@ -239,6 +239,8 @@ atxHeader = try $ do
239atxClosing = try $ skipMany (char '#') >> blanklines
239atxClosing = try $ skipMany (char '#') >> blanklines
240
240
241setextHeader = try $ do
241setextHeader = try $ do
242+ -- first, see if this block has any chance of being a setextHeader:
243+ lookAhead (anyLine >> oneOf setextHChars)
242 text <- many1Till inline newline >>= return . normalizeSpaces
244 text <- many1Till inline newline >>= return . normalizeSpaces
243 level <- choice $ zipWith
245 level <- choice $ zipWith
244 (\ch lev -> try (many1 $ char ch) >> blanklines >> return lev)
246 (\ch lev -> try (many1 $ char ch) >> blanklines >> return lev)
@@ -406,6 +408,8 @@ bulletList = many1 (listItem bulletListStart) >>=
406definitionListItem = try $ do
408definitionListItem = try $ do
407 notFollowedBy blankline
409 notFollowedBy blankline
408 notFollowedBy' indentSpaces
410 notFollowedBy' indentSpaces
411+ -- first, see if this has any chance of being a definition list:
412+ lookAhead (anyLine >> char ':')
409 term <- manyTill inline newline
413 term <- manyTill inline newline
410 raw <- many1 defRawBlock
414 raw <- many1 defRawBlock
411 state <- getState
415 state <- getState