diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-01-02 17:04:59 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-01-02 17:04:59 -0800 |
commit | 5b7c209373a441c2c7b296031025baa56a9f0c43 (patch) | |
tree | b11adb2e9a4a3814db45536897fe24ad17712578 /src/Text/Pandoc/Readers | |
parent | 9001506f3398485512f46fe28ab93915d7a3314a (diff) | |
download | pandoc-5b7c209373a441c2c7b296031025baa56a9f0c43.tar.gz |
Markdown reader: Fix parsing of consecutive lists.
Pandoc previously behaved like Markdown.pl for consecutive
lists of different styles. Thus, the following would be parsed
as a single ordered list, rather than an ordered list followed
by an unordered list:
1. one
2. two
- one
- two
This patch makes pandoc behave more sensibly, parsing this as
two lists. Any change in list type (ordered/unordered) or in
list number style will trigger a new list. Thus, the following
will also be parsed as two lists:
1. one
2. two
a. one
b. two
Since we regard this as a bug in Markdown.pl, and not something
anyone would ever rely on, we do not preserve the old behavior
even when `--strict` is selected.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index d854bd3c7..9f6609c6d 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -556,9 +556,9 @@ listLine = try $ do return $ concat chunks ++ "\n" -- parse raw text for one list item, excluding start marker and continuations -rawListItem :: GenParser Char ParserState [Char] -rawListItem = try $ do - listStart +rawListItem :: GenParser Char ParserState a -> GenParser Char ParserState [Char] +rawListItem start = try $ do + start result <- many1 listLine blanks <- many blankline return $ concat result ++ blanks @@ -581,9 +581,9 @@ listContinuationLine = try $ do result <- manyTill anyChar newline return $ result ++ "\n" -listItem :: GenParser Char ParserState [Block] -listItem = try $ do - first <- rawListItem +listItem :: GenParser Char ParserState a -> GenParser Char ParserState [Block] +listItem start = try $ do + first <- rawListItem start continuations <- many listContinuation -- parsing with ListItemState forces markers at beginning of lines to -- count as list item markers, even if not separated by blank space. @@ -600,13 +600,15 @@ listItem = try $ do orderedList :: GenParser Char ParserState Block orderedList = try $ do (start, style, delim) <- lookAhead anyOrderedListStart - items <- many1 listItem + items <- many1 $ listItem $ try $ + do optional newline -- if preceded by a Plain block in a list context + skipNonindentSpaces + orderedListMarker style delim return $ OrderedList (start, style, delim) $ compactify items bulletList :: GenParser Char ParserState Block -bulletList = try $ do - lookAhead bulletListStart - many1 listItem >>= return . BulletList . compactify +bulletList = + many1 (listItem bulletListStart) >>= return . BulletList . compactify -- definition lists |