list item and handling children lists potentially being different from the parent
This commit is contained in:
parent
dbb501b1da
commit
9330e44b58
3 changed files with 9 additions and 5 deletions
|
|
@ -64,7 +64,7 @@ generateLiElems (element : remainder) =
|
|||
-- We assume child lists are stricly after our contents
|
||||
-- if they aren't this is fucked
|
||||
serializeInlineToHTML element.content,
|
||||
T.concat $ map (elementToHTML . List) element.children,
|
||||
fromMaybe "" $ fmap (elementToHTML . List) element.child,
|
||||
"</li>",
|
||||
generateLiElems remainder
|
||||
]
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ data BlockQuote = Q [InlineText] deriving (Show)
|
|||
|
||||
data ListItem = LI
|
||||
{ content :: [InlineText], -- Flatten continuations into here
|
||||
children :: [List]
|
||||
child :: Maybe List
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
|
|
|
|||
|
|
@ -125,17 +125,21 @@ listBlock list_type prefix child_parser_factory nest_level = do
|
|||
items <- some $ (try (listItem <* notFollowedBy blockEnding)) <|> (listItem <* lineEnding)
|
||||
pure $ List $ L {list_type, items}
|
||||
where
|
||||
listItem = error "listItem"
|
||||
listItem = do
|
||||
prefix
|
||||
content <- many inlineText
|
||||
child <- optional $ child_parser_factory $ nest_level + 1
|
||||
pure $ LI {content, child}
|
||||
|
||||
unorderedListBlock :: (Logger m, Characters s) => Int -> Parser s m Element
|
||||
unorderedListBlock = listBlock Unordered unordered_prefix (\level -> unwrap <$> unorderedListBlock level)
|
||||
unorderedListBlock = listBlock Unordered unordered_prefix (\level -> unwrap <$> ((try $ unorderedListBlock level) <|> orderedListBlock level))
|
||||
where
|
||||
unordered_prefix = (choice $ map char "*-+") *> optional spaceChar
|
||||
-- not exhaustive but we know listBlock is returning a List
|
||||
unwrap (List l) = l
|
||||
|
||||
orderedListBlock :: (Logger m, Characters s) => Int -> Parser s m Element
|
||||
orderedListBlock = listBlock Ordered ordered_prefix (\level -> unwrap <$> orderedListBlock level)
|
||||
orderedListBlock = listBlock Ordered ordered_prefix (\level -> unwrap <$> ((try $ unorderedListBlock level) <|> orderedListBlock level))
|
||||
where
|
||||
ordered_prefix = error "ordered_prefix"
|
||||
-- not exhaustive but we know listBlock is returning a List
|
||||
|
|
|
|||
Loading…
Reference in a new issue