Repository navigation
Fix tasklist: find the marker inside containers, take the checked state from the marker - #396
Open
itayavtalyon wants to merge 1 commit into
Open
itayavtalyon wants to merge 1 commit into
itayavtalyon wants to merge 1 commit into
Conversation
The tasklist extension scanned for the marker from the start of the raw line, so a task list item inside a block quote (`> - [ ] task`) was never recognised. It also set the checked state with strstr over the rest of the line, so `- [ ] buy [x] item` rendered as checked. Look for the marker at the item's first non-space character, only on the line that opens the item, and take the checked state from that marker. The characters allowed after the marker match the original scanner's spacechar class (space, tab, VT, FF), so `- [ ]` at the end of a line is still not a task. Over every example in spec.txt, extensions.txt, regression.txt and smart_punct.txt with all extensions on, only the new regression examples change output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
itayavtalyon
marked this pull request as ready for review
October 27, 2026 15:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs in
extensions/tasklist.c:checkedcomes fromstrstr(input, "[x]") || strstr(input, "[X]")over the rest of the line, so- [ ] buy [x] itemrenders as a checked task.scan_tasklist(input, len, 0)scans from the start of the raw line, so the container prefix defeats it:> - [ ] quoted(or a task list inside a block quote at any depth) is never a task item.Fix
open_tasklist_itemnow:cmark_parser_get_first_nonspace), not at offset 0 of the line;start_line == line_number), so[ ]at the start of a continuation line stays text, as before;]the same characters as the old scanner'sspacecharclass (space, tab, VT, FF), so- [ ]at the end of a line is still not a task, as before;checkedfrom that marker character only.Tests
Seven new examples in
test/regression.txt, taggedtasklist: the two bugs, a task list in a quote inside a list, and four examples that pin existing behaviour (a continuation line, a marker at line end, a marker on a later line, near-miss markers such as[x)and[y]).A differential run of the unfixed and fixed
cmark-gfmbinaries (this branch andmaster) over every example inspec.txt,extensions.txt,regression.txtandsmart_punct.txt, with all extensions enabled (751 examples), changes the output only for the new regression examples. A further 18 task edge forms (list padding, tabs,[],[ ]x, ordered markers, a marker on a later line) give identical output.ctest: 13/13 pass.The same fix is proposed to swiftlang/swift-cmark in swiftlang#103.
🤖 Generated with Claude Code