diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 5e4c8d3158bd..89ba8828ed81 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -342,7 +342,24 @@ pListItem = do [Span (ident, [], []) ils] : xs) _ -> B.divWith (ident, [], []) bs maybe id addId (lookup "id" attr) <$> - pInTags "li" block + pInTags "li" (pCheckBox <|> block) + where + pCheckBox :: PandocMonad m => TagParser m Blocks + pCheckBox = try $ do + trace "pCheckBox!!!" + pInTag TagsRequired "label" pInput + where + pInput :: PandocMonad m => TagParser m Blocks + pInput = do + TagOpen _ attr' <- lookAhead $ pSatisfy $ matchTagOpen "input" [("type","checkbox")] + let attr = toStringAttr attr' + let isChecked = isJust $ lookup "checked" attr + _ <- pSelfClosing (== "input") (const True) + bs <- inline + return $ if isChecked + then B.Many . Seq.singleton $ B.Plain ([B.Str "\9746", B.Space ] <> B.toList bs) + else B.Many . Seq.singleton $ B.Plain ([B.Str "\9744", B.Space ] <> B.toList bs) + -- | Parses a list item just like 'pListItem', but allows sublists outside of -- @li@ tags to be treated as items. diff --git a/test/command/tasklist.md b/test/command/tasklist.md index b1c6491ccb5c..41d4ff85f95e 100644 --- a/test/command/tasklist.md +++ b/test/command/tasklist.md @@ -103,3 +103,16 @@ round trip: - [ ] foo - [x] bar ``` + +``` +% pandoc -f html -t html + +^D + +``` \ No newline at end of file