fix: allow tabs in the thematic break that ends a list item - #4087
Merged
Merged
Conversation
CommonMark 0.31.2 says each -, _, or * of a thematic break may be followed by any number of spaces or tabs, but the hrRegex that closes a list item allowed spaces only, so a break written with tabs was taken as paragraph continuation instead. "- foo" followed by a line of underscores separated by tabs put the hr inside the list item, and "- foo" followed by "---" plus a tab turned foo into a setext heading. The block hr rule already allows tabs; this makes the list item check agree with it.
|
@giaBaoJS is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
UziTech
approved these changes
Sep 6, 2026
styfle
approved these changes
Sep 8, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Sep 12, 2026
## [18.0.13](v18.0.12...v18.0.13) (2026-09-12) ### Bug Fixes * allow tabs in the thematic break that ends a list item ([#4087](#4087)) ([afbb27c](afbb27c)) * avoid O(n^2) scanning in reflinkSearch ([#4090](#4090)) ([c6a25bb](c6a25bb)) * case fold reference link labels ([#4077](#4077)) ([aed9336](aed9336)) * drop the leading whitespace after a hard line break ([#4075](#4075)) ([123ce04](123ce04)) * match html block start conditions when ending a list item ([#4072](#4072)) ([c2facac](c2facac)) * respect raw tokens when closing link labels ([#4066](#4066)) ([ef394f7](ef394f7)) * strip a tab that follows spaces in an indented code block ([#4080](#4080)) ([dbb393d](dbb393d))
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.
Marked version: 18.0.11 (master, 4417582)
Markdown flavor: CommonMark
Description
A thematic break whose characters are separated or followed by tabs does not end an open list item.
Input (tabs shown as
<TAB>):Expected:
Actual:
A trailing tab is enough to trigger it for every break character, and with
-the result is worse, because the line is then read as a setext underline:Expected
<ul><li>foo</li></ul><hr>, actual<ul><li><h2>foo</h2></li></ul>.The same input with spaces instead of tabs (
_ _ _,---) is already handled correctly, and*<TAB>*<TAB>*happens to work only becausenextBulletRegexcatches the leading*first.Spec
CommonMark 0.31.2, section 4.1 Thematic breaks:
A thematic break is not paragraph continuation text, so it cannot be a lazy continuation line of the list item (section 5.2, rule 5) and closes the list. Spec example 57 (
- foo/***/- bar) already covers the space-only form, which marked passes.commonmark0.31.2, the reference implementation already in devDependencies, produces the expected output above for all three tab variants.Root cause
other.hrRegexinsrc/rules.ts, used by the list tokenizer to decide that a following line closes the item, allowed only spaces after each break character, while the blockhrrule it is supposed to mirror already allows[ \t]. The break line therefore fell through to the paragraph-continuation path and stayed inside the item.Spec suite
Before: 1801 tests, 1801 pass, 0 fail.
After: 1803 tests, 1803 pass, 0 fail (the two added tests). The CommonMark and GFM completion tables are unchanged, including the known failures (Entity and numeric character references 15/17, Links 84/90, GFM Autolinks 15/19 and 11/14, Disallowed Raw HTML 0/1).
npm run test:unit(191 pass),npm run test:lintandtscare clean.Contributor
Committer
In most cases, this should be a different person than the contributor.