From e051c87f0892c2b1211c112d0ef8d939d9a8c5ba Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Tue, 20 May 2025 16:48:31 -0400 Subject: [PATCH] Factor list line common parsing into a separate function; refactored OList and UList line parsing to us it --- src/MdToHTML.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/MdToHTML.hs b/src/MdToHTML.hs index c9370d5..c4cea44 100644 --- a/src/MdToHTML.hs +++ b/src/MdToHTML.hs @@ -301,6 +301,19 @@ parseUListLineItem :: ReadP MdToken parseUListLineItem = do firstChar <- choice (map char ['*', '+', '-']) 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 restOfLine <- many1 parseListLineToken void (char '\n') <++ eof