From 7062a64e528c047b3c8c46a6f2cb649b5a3b15c9 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 11 Feb 2025 12:03:06 -0700 Subject: [PATCH 1/3] Fix incorrectly computed indent on task_list --- .../src/Commonmark/Extensions/TaskList.hs | 4 ++-- commonmark-extensions/test/task_lists.md | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs b/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs index c011cee7..d53b75f0 100644 --- a/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs +++ b/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs @@ -184,11 +184,11 @@ itemStart = do pos <- getPosition ty <- bulletListMarker aftercol <- sourceColumn <$> getPosition - checked <- parseCheckbox lookAhead whitespace numspaces <- try (gobbleUpToSpaces 4 <* notFollowedBy whitespace) <|> gobbleSpaces 1 - <|> 1 <$ lookAhead lineEnd + checked <- parseCheckbox + lookAhead whitespace return $! (pos, ListItemData{ listItemType = ty , listItemChecked = checked diff --git a/commonmark-extensions/test/task_lists.md b/commonmark-extensions/test/task_lists.md index d3b51954..40d5d9c7 100644 --- a/commonmark-extensions/test/task_lists.md +++ b/commonmark-extensions/test/task_lists.md @@ -28,3 +28,23 @@ As in GitHub-flavored Markdown. ```````````````````````````````` + +```````````````````````````````` example +- [x]unreal +. + +```````````````````````````````` + + +```````````````````````````````` example +- [x] real + + not indented enough +. + +

not indented enough

+```````````````````````````````` From 988e0ba4aa1175eec13f725b26e8746fbbb97b03 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 11 Feb 2025 12:55:02 -0700 Subject: [PATCH 2/3] Fix disagreement with GitHub about block nesting in tasklists This is a bit non-obvious, but it makes some sense with the way indentation works. Text on the same line as the task marker can't start a block. It has to be paragraph text. --- .../src/Commonmark/Extensions/TaskList.hs | 11 ++++++++++ commonmark-extensions/test/task_lists.md | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs b/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs index d53b75f0..25e8b3dd 100644 --- a/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs +++ b/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs @@ -133,6 +133,17 @@ taskListItemBlockSpec = BlockSpec listItemType lidata -> addNodeToStack linode _ -> addNodeToStack listnode >> addNodeToStack linode + blankAfterMarker <- optionMaybe lineEnd + pos' <- getPosition + case blankAfterMarker of + Just _ -> return () + Nothing -> do + toks <- many (satisfyTok (not . hasType LineEnd)) + addNodeToStack $ + Node (defBlockData paraSpec){ + blockStartPos = [pos'] + , blockLines = [toks] } + [] return BlockStartMatch , blockCanContain = const True , blockContainsLines = False diff --git a/commonmark-extensions/test/task_lists.md b/commonmark-extensions/test/task_lists.md index 40d5d9c7..5a892cba 100644 --- a/commonmark-extensions/test/task_lists.md +++ b/commonmark-extensions/test/task_lists.md @@ -48,3 +48,24 @@ As in GitHub-flavored Markdown.

not indented enough

```````````````````````````````` + + +```````````````````````````````` example +- [x] * some text +- [ ] > some text +- [x] + * some text +- [ ] + > some text +. + +```````````````````````````````` From 372c784d181979e2a67da96051077baebf846ee4 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 14 Feb 2025 08:46:20 -0700 Subject: [PATCH 3/3] Fix the blank line scanner after the `]` --- .../src/Commonmark/Extensions/TaskList.hs | 2 +- commonmark-extensions/test/task_lists.md | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs b/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs index 25e8b3dd..4680b8f0 100644 --- a/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs +++ b/commonmark-extensions/src/Commonmark/Extensions/TaskList.hs @@ -133,7 +133,7 @@ taskListItemBlockSpec = BlockSpec listItemType lidata -> addNodeToStack linode _ -> addNodeToStack listnode >> addNodeToStack linode - blankAfterMarker <- optionMaybe lineEnd + blankAfterMarker <- optionMaybe blankLine pos' <- getPosition case blankAfterMarker of Just _ -> return () diff --git a/commonmark-extensions/test/task_lists.md b/commonmark-extensions/test/task_lists.md index 5a892cba..b541c9b6 100644 --- a/commonmark-extensions/test/task_lists.md +++ b/commonmark-extensions/test/task_lists.md @@ -69,3 +69,25 @@ As in GitHub-flavored Markdown. ```````````````````````````````` + +There is no empty paragraph after the `]`. + +```````````````````````````````` example +- [x] * some text + +- [x] + + some text + +- [x]→ + + some text +. +
    +
  • * some text

  • +
  • some text

    +
  • +
  • some text

    +
  • +
+````````````````````````````````