Skip to content

fix: avoid task checkbox for setext heading text#3960

Merged
UziTech merged 5 commits intomarkedjs:masterfrom
AbdelrahmanHafez:fix-task-list-setext-heading
May 1, 2026
Merged

fix: avoid task checkbox for setext heading text#3960
UziTech merged 5 commits intomarkedjs:masterfrom
AbdelrahmanHafez:fix-task-list-setext-heading

Conversation

@AbdelrahmanHafez
Copy link
Copy Markdown
Contributor

Marked version: 18.0.2

Markdown flavor: GitHub Flavored Markdown

Description

re #3828
Setext headings inside list items that start with [x] or [ ] were parsed as task list items, so the marker was removed and a disabled checkbox was inserted.

Expectation

- [x] title
  ---

renders as a list item containing <h2>[x] title</h2>.

Result

Demo
Marked rendered the same input as a checked task list item with a heading.

What was attempted

Only finalize task-list parsing when the preserved checkbox marker belongs to a text-like first child token. Added unit coverage for the rendered HTML and lexer token shape.

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

@AbdelrahmanHafez is attempting to deploy a commit to the MarkedJS Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the Tokenizer to prevent setext headings within list items from being incorrectly identified as task checkboxes. The logic now ensures that task checkbox processing only occurs if the first token of a list item is of type 'text' or 'paragraph'. Corresponding unit tests have been added to Lexer.test.js and marked.test.js to verify that these headings are rendered correctly without checkbox inputs. I have no feedback to provide.

@AbdelrahmanHafez AbdelrahmanHafez marked this pull request as ready for review April 28, 2026 16:11
Comment thread test/unit/marked.test.js Outdated
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marked-website Ready Ready Preview, Comment Apr 30, 2026 2:48pm

Request Review

Copy link
Copy Markdown
Member

@UziTech UziTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving marked! 💯

@UziTech UziTech requested review from calculuschild and styfle April 30, 2026 14:51
@UziTech UziTech merged commit 2608e81 into markedjs:master May 1, 2026
8 checks passed
github-actions Bot pushed a commit that referenced this pull request May 1, 2026
## [18.0.3](v18.0.2...v18.0.3) (2026-05-01)

### Bug Fixes

* avoid task checkbox for setext heading text ([#3960](#3960)) ([2608e81](2608e81))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants