started scaffolding out a new way to do lists
This commit is contained in:
parent
aa69b3f6ef
commit
ef61e282d2
1 changed files with 33 additions and 1 deletions
34
src/Djot.hs
34
src/Djot.hs
|
|
@ -95,9 +95,41 @@ blockQuote attrs = do
|
||||||
space
|
space
|
||||||
manyTill anySingle $ lookAhead newline
|
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 :: (Logger m, Characters s) => Attrs -> Parser s m Element
|
||||||
listBlock attrs = do
|
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 :: (Logger m, Characters s) => Attrs -> Parser s m Element
|
||||||
taskListBlock attrs = do
|
taskListBlock attrs = do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue