From 96c2ad7d495f34f2e40efd3b733b8ac194dcecd9 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 29 Mar 2023 16:49:34 +0200 Subject: [PATCH] HTML writer: use first paragraph in task item as checkbox label. Closes: #8729 --- src/Text/Pandoc/Writers/HTML.hs | 2 +- test/command/tasklist.md | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index bbdbbc0ba..17fe2c945 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -501,7 +501,7 @@ listItemToHtml opts bls checkbox' = H.input ! A.type_ "checkbox" isContents <- inlineListToHtml opts is bsContents <- blockListToHtml opts bs - return $ constr (checkbox >> isContents) >> + return $ constr (H.label (checkbox >> isContents)) >> (if null bs then mempty else nl) >> bsContents diff --git a/test/command/tasklist.md b/test/command/tasklist.md index caa8603f4..b1c6491cc 100644 --- a/test/command/tasklist.md +++ b/test/command/tasklist.md @@ -6,8 +6,8 @@ tests adapted from - [x] bar ^D ``` @@ -20,12 +20,12 @@ tests adapted from - [ ] bim ^D
    -
  • foo +
    • -
    • bar
    • -
    • baz
    • +
    • +
  • -
  • bim
  • +
``` @@ -53,21 +53,23 @@ paragraph - [x] checked ^D
    -
  • unchecked
  • +
  • plain item
  • -
  • checked
  • +

paragraph

    -
  1. ordered unchecked
  2. +
  3. [] plain item
  4. -
  5. ordered checked
  6. +

paragraph

    -
  • list item with a

    +
  • second paragraph

  • -
  • checked

  • +
```