Created a list of document parsers; implemented ordered list parsing.
This commit is contained in:
@@ -350,6 +350,34 @@ parseUnorderedList = do
|
||||
void (char '\n') <++ eof -- A list must end in an extra newline or eof
|
||||
return $ UnordList lineItems
|
||||
|
||||
-- --------
|
||||
|
||||
parseOListItem :: ReadP MdToken
|
||||
parseOListItem = parseOListParaItem <++ parseOListLineItem
|
||||
|
||||
-- Parses the first element of an ordered list, which must start with '1.'
|
||||
parseFirstOListItem :: ReadP MdToken
|
||||
parseFirstOListItem = do
|
||||
remaining <- look
|
||||
when (take 2 remaining /= "1.") pfail
|
||||
parseOListLineItem
|
||||
|
||||
parseOrderedList :: ReadP MdToken
|
||||
parseOrderedList = do
|
||||
firstLine <- parseFirstOListItem
|
||||
lineItems <- greedyParse1 parseOListItem
|
||||
void (char '\n') <++ eof
|
||||
return $ OrdList (firstLine : lineItems)
|
||||
|
||||
documentParsers :: [ReadP MdToken]
|
||||
documentParsers =
|
||||
[ parseHeader,
|
||||
parseBlockquote,
|
||||
parseUnorderedList,
|
||||
parseOrderedList,
|
||||
parsePara
|
||||
]
|
||||
|
||||
-- Parse a document, which is multiple paragraphs.
|
||||
parseDocument :: ReadP MdToken
|
||||
parseDocument = do
|
||||
|
Reference in New Issue
Block a user