diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-11-03 21:16:47 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-11-03 21:16:47 -0800 |
commit | 4301fa4a2794cc354da0bc15e7a4ebb214bb9966 (patch) | |
tree | ebcca5ade211565f23064779143fe82ce3506a08 /src/Text/Pandoc | |
parent | 732f6abe15b75724c2eb7a8bf0763f054b2dc500 (diff) | |
download | pandoc-4301fa4a2794cc354da0bc15e7a4ebb214bb9966.tar.gz |
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.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 8f804f863..ea49d8c1d 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -444,6 +444,9 @@ block = choice [ mempty <$ blanklines , codeBlockFenced , yamlMetaBlock , guardEnabled Ext_latex_macros *> (macro >>= return . return) + -- note: bulletList needs to be before header because of + -- the possibility of empty list items: - + , bulletList , header , lhsCodeBlock , rawTeXBlock @@ -454,7 +457,6 @@ block = choice [ mempty <$ blanklines , codeBlockIndented , blockQuote , hrule - , bulletList , orderedList , definitionList , noteBlock @@ -699,7 +701,7 @@ bulletListStart = try $ do skipNonindentSpaces notFollowedBy' (() <$ hrule) -- because hrules start out just like lists satisfy isBulletListMarker - spaceChar + spaceChar <|> lookAhead newline skipSpaces anyOrderedListStart :: MarkdownParser (Int, ListNumberStyle, ListNumberDelim) @@ -727,7 +729,6 @@ listStart = bulletListStart <|> (anyOrderedListStart >> return ()) -- parse a line of a list item (start = parser for beginning of list item) listLine :: MarkdownParser String listLine = try $ do - notFollowedBy blankline notFollowedBy' (do indentSpaces many (spaceChar) listStart) @@ -740,7 +741,7 @@ rawListItem :: MarkdownParser a rawListItem start = try $ do start first <- listLine - rest <- many (notFollowedBy listStart >> listLine) + rest <- many (notFollowedBy listStart >> notFollowedBy blankline >> listLine) blanks <- many blankline return $ unlines (first:rest) ++ blanks |