Skip to content

fix: place task checkboxes after list loose is finalized - #4046

Merged
UziTech merged 1 commit into
markedjs:masterfrom
Hashim1999164:fix/loose-task-list-checkbox-placement
Aug 15, 2026
Merged

fix: place task checkboxes after list loose is finalized#4046
UziTech merged 1 commit into
markedjs:masterfrom
Hashim1999164:fix/loose-task-list-checkbox-placement

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #4045

Test plan

  • npm run build
  • npm run test:specs (1781 passed, including new list_loose_nested_tasks and existing task/list fixtures)
  • Manually confirmed loose items render checkboxes inside <p>; tight nested items stay without <p>

Loose nested task lists could leave checkboxes outside <p> because
checkbox placement used list.loose before spacer detection finished.
Compute the final loose state first, then place checkboxes.

Fixes markedjs#4045
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
marked-website Ready Ready Preview Aug 8, 2026 3:24am

Request Review

@UziTech UziTech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing this! 💯

@UziTech
UziTech requested review from calculuschild and styfle August 8, 2026 21:21
Comment thread src/Tokenizer.ts
Comment on lines +426 to +429
const spacers = item.tokens.filter(t => t.type === 'space');
const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => this.rules.other.anyLine.test(t.raw));

list.loose = hasMultipleLineBreaks;

@styfle styfle Aug 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In a follow up, we could change this one be one line without

list.loose = item.tokens.some(t => t.type === 'space' && this.rules.other.anyLine.test(t.raw));

Though no need to change here since its just moving existing code

@UziTech
UziTech merged commit b8cf7dc into markedjs:master Aug 15, 2026
8 checks passed
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.

Task list checkbox rendered outside the <p> in loose nested lists, inconsistently within the same list

3 participants