diff --git a/src/Djot.hs b/src/Djot.hs index 158c931..270ab93 100644 --- a/src/Djot.hs +++ b/src/Djot.hs @@ -95,9 +95,41 @@ blockQuote attrs = do space manyTill anySingle $ lookAhead newline +newtype ListTypeEq = LTE ListType + +instance Eq ListTypeEq where + (LTE (Ordered {style = s1})) == (LTE (Ordered {style = s2})) = s1 == s2 + (LTE (Unordered {style = s1})) == (LTE (Unordered {style = s2})) = s1 == s2 + _ == _ = False + listBlock :: (Logger m, Characters s) => Attrs -> Parser s m Element listBlock attrs = do - error "todo" + (list_type, item) <- listItem + remaining_items <- many $ listItem' list_type + pure $ List (L {list_type, items = item : remaining_items}) attrs + where + listItem = do + list_type <- listMarker + first_line <- listLine $ pure () + content <- some $ listLine $ notFollowedBy $ listMarker' list_type + error "todo" + -- any listMarker + -- can probably just use listMarker' via choice or smth like that + listMarker = error "todo" + -- listItem which must be of list_type + listItem' list_type = do + listMarker' list_type + first_line <- listLine $ pure () + content <- some $ listLine $ notFollowedBy $ listMarker' list_type + + error "todo" + + -- listMarker which must be of list_type + listMarker' list_type = error "todo" + -- list line which must parse check before the rest of the line + listLine check = do + check + manyTill anySingle newline taskListBlock :: (Logger m, Characters s) => Attrs -> Parser s m Element taskListBlock attrs = do