git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Correctly handle empty bullet list items.

For example: - one - - two This should NOT be parsed as a setext header followed by a list.

commit4301fa4a2794cc354da0bc15e7a4ebb214bb9966 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 3 Nov 2013, 21:16 (13 years ago) parent732f6ab
1 file changed+5−4
src/Text/Pandoc/Readers/Markdown.hs+5−4
src/Text/Pandoc/Readers/Markdown.hs+5−4
@@ -444,6 +444,9 @@ block = choice [ mempty <$ blanklines
444444 , codeBlockFenced
445445 , yamlMetaBlock
446446 , guardEnabled Ext_latex_macros *> (macro >>= return . return)
447+ -- note: bulletList needs to be before header because of
448+ -- the possibility of empty list items: -
449+ , bulletList
447450 , header
448451 , lhsCodeBlock
449452 , rawTeXBlock
@@ -454,7 +457,6 @@ block = choice [ mempty <$ blanklines
454457 , codeBlockIndented
455458 , blockQuote
456459 , hrule
457− , bulletList
458460 , orderedList
459461 , definitionList
460462 , noteBlock
@@ -699,7 +701,7 @@ bulletListStart = try $ do
699701 skipNonindentSpaces
700702 notFollowedBy' (() <$ hrule) -- because hrules start out just like lists
701703 satisfy isBulletListMarker
702− spaceChar
704+ spaceChar <|> lookAhead newline
703705 skipSpaces
704706
705707anyOrderedListStart :: MarkdownParser (Int, ListNumberStyle, ListNumberDelim)
@@ -727,7 +729,6 @@ listStart = bulletListStart <|> (anyOrderedListStart >> return ())
727729-- parse a line of a list item (start = parser for beginning of list item)
728730listLine :: MarkdownParser String
729731listLine = try $ do
730− notFollowedBy blankline
731732 notFollowedBy' (do indentSpaces
732733 many (spaceChar)
733734 listStart)
@@ -740,7 +741,7 @@ rawListItem :: MarkdownParser a
740741rawListItem start = try $ do
741742 start
742743 first <- listLine
743− rest <- many (notFollowedBy listStart >> listLine)
744+ rest <- many (notFollowedBy listStart >> notFollowedBy blankline >> listLine)
744745 blanks <- many blankline
745746 return $ unlines (first:rest) ++ blanks
746747