Factor list line common parsing into a separate function; refactored
OList and UList line parsing to us it
This commit is contained in:
@@ -301,6 +301,19 @@ parseUListLineItem :: ReadP MdToken
|
|||||||
parseUListLineItem = do
|
parseUListLineItem = do
|
||||||
firstChar <- choice (map char ['*', '+', '-'])
|
firstChar <- choice (map char ['*', '+', '-'])
|
||||||
char ' ' -- At least one space between list indicator and list text.
|
char ' ' -- At least one space between list indicator and list text.
|
||||||
|
parseListLineItemCommon
|
||||||
|
|
||||||
|
-- Parse an ordered list line item.
|
||||||
|
parseOListLineItem :: ReadP MdToken
|
||||||
|
parseOListLineItem = do
|
||||||
|
num <- greedyParse1 (satisfy isDigit)
|
||||||
|
char '.'
|
||||||
|
char ' ' -- At least one space between list indicator and list text.
|
||||||
|
parseListLineItemCommon
|
||||||
|
|
||||||
|
-- Common code for parsing list line items
|
||||||
|
parseListLineItemCommon :: ReadP MdToken
|
||||||
|
parseListLineItemCommon = do
|
||||||
skipSpaces
|
skipSpaces
|
||||||
restOfLine <- many1 parseListLineToken
|
restOfLine <- many1 parseListLineToken
|
||||||
void (char '\n') <++ eof
|
void (char '\n') <++ eof
|
||||||
|
Reference in New Issue
Block a user