diff options
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 22 | ||||
-rw-r--r-- | tests/markdown-reader-more.native | 12 | ||||
-rw-r--r-- | tests/markdown-reader-more.txt | 10 |
3 files changed, 33 insertions, 11 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 diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native index 3b2221d7b..d36241a96 100644 --- a/tests/markdown-reader-more.native +++ b/tests/markdown-reader-more.native @@ -47,4 +47,14 @@ ,Para [Link [Str "bat"] ("/bat","")] ,Header 2 [Str "Curly",Space,Str "smart",Space,Str "quotes"] ,Para [Quoted DoubleQuote [Str "Hi"]] -,Para [Quoted SingleQuote [Str "Hi"]]] +,Para [Quoted SingleQuote [Str "Hi"]] +,Header 2 [Str "Consecutive",Space,Str "lists"] +,BulletList + [[Plain [Str "one"]] + ,[Plain [Str "two"]]] +,OrderedList (1,Decimal,Period) + [[Plain [Str "one"]] + ,[Plain [Str "two"]]] +,OrderedList (1,LowerAlpha,Period) + [[Plain [Str "one"]] + ,[Plain [Str "two"]]]] diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt index 258002b8a..b99bb3121 100644 --- a/tests/markdown-reader-more.txt +++ b/tests/markdown-reader-more.txt @@ -123,3 +123,13 @@ $\tuple{x,y}$ “Hi” ‘Hi’ + +## Consecutive lists + +- one +- two +1. one +2. two + + a. one + b. two |