diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-04-13 11:12:18 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-04-13 11:12:18 -0700 |
commit | e37c4526b2ae9d52a2f43d83c00f6f720637ce5c (patch) | |
tree | bf585b5449d0d9fceed17c911c57bd9d6a84a6f1 /src/Text/Pandoc/Readers | |
parent | d28ad2b0f13d39863f3aff101e348a380f79f5d1 (diff) | |
download | pandoc-e37c4526b2ae9d52a2f43d83c00f6f720637ce5c.tar.gz |
Markdown reader: Allow lists as list items.
So, for example:
1. * x
* y
2. * z
* w
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 749963cd0..19ceb0b53 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -554,7 +554,6 @@ listStart = bulletListStart <|> (anyOrderedListStart >> return ()) -- parse a line of a list item (start = parser for beginning of list item) listLine :: GenParser Char ParserState [Char] listLine = try $ do - notFollowedBy' listStart notFollowedBy blankline notFollowedBy' (do indentSpaces many (spaceChar) @@ -563,12 +562,14 @@ listLine = try $ do return $ concat chunks ++ "\n" -- parse raw text for one list item, excluding start marker and continuations -rawListItem :: GenParser Char ParserState a -> GenParser Char ParserState [Char] +rawListItem :: GenParser Char ParserState a + -> GenParser Char ParserState [Char] rawListItem start = try $ do start - result <- many1 listLine + first <- listLine + rest <- many (notFollowedBy listStart >> listLine) blanks <- many blankline - return $ concat result ++ blanks + return $ concat (first:rest) ++ blanks -- continuation of a list item - indented and separated by blankline -- or (in compact lists) endline. @@ -588,8 +589,9 @@ listContinuationLine = try $ do result <- manyTill anyChar newline return $ result ++ "\n" -listItem :: GenParser Char ParserState a -> GenParser Char ParserState [Block] -listItem start = try $ do +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 |