Repository navigation
fix: text after a heading or code block in a nested list item is pulled into the outer item - #4179
Merged
Conversation
A line with less indentation than a list item is only a lazy continuation when it continues a paragraph. The list tokenizer checked the previous line for a fence, heading or hr, but it used the regexes scaled to the item indent on a line that is already relative to the item content, and it did not look inside a nested list item or blockquote on that line. So text after `- - # heading`, `- > ***`, or a fenced code block in a nested item was pulled into the outer item.
|
@yxshee 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.
|
styfle
approved these changes
Nov 8, 2026
This was referenced Nov 9, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 9, 2026
# [18.2.0](v18.1.3...v18.2.0) (2026-11-09) ### Bug Fixes * keep hard line breaks in image alt text ([#4187](#4187)) ([ed54c54](ed54c54)) * let emphasis open after the other delimiter character ([#4169](#4169)) ([219492a](219492a)) * let emphasis open and close in angle brackets that are not html ([#4190](#4190)) ([7bfa1f7](7bfa1f7)) * preserve zero from named extension renderers ([#4199](#4199)) ([b81a00a](b81a00a)) * text after a heading or code block in a nested list item is pulled into the outer item ([#4179](#4179)) ([4cb767a](4cb767a)) ### Features * add lastToken to lexer state ([#4160](#4160)) ([e4ab77f](e4ab77f))
11 of 15 tasks
This was referenced Nov 13, 2026
This branch was successfully deployed
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.1.2 (also master at 8babc79)
Markdown flavor: CommonMark
Description
A line with less indentation than a list item is only a lazy continuation when it continues a paragraph. When the line before it ends a fenced code block, or is a heading or a thematic break inside a nested list item or block quote, there is no open paragraph, so the list should end there. marked keeps the line in the outer list item instead.
Expectation
Then run it.is a paragraph after the list (commonmark.js 0.31 and the CommonMark dingus agree).Result
marked 18.1.2 renders
<p>Then run it.</p>inside the outer<li>. The same happens for- - # headingand- > ***followed by an unindented line; with- > ***the text even ends up as bare text in the item.Cause
In the "not enough indentation" branch of the list tokenizer,
lineis the previous line already relative to the item content, but it was tested withfencesBeginRegex(indent),headingBeginRegex(indent)andhrRegex(indent), which only allowindent - 1leading spaces. A closing fence in a nested item (three backticks after two spaces, relative to the outer item) has more than that. Those checks also never looked past a nested list marker or>on the line.The fix tests the previous line with the block rules (0 to 3 spaces), after stripping nested list and block quote markers, and only when that line was not itself a lazy line (a lazy line is paragraph text, so
- a\nb\n# cbehaves as before). Pedantic mode is unchanged.Contributor
test/specs/new/list_lazy_after_nested_block.mdcovers the fence, heading, hr and block quote cases, plus a nested lazy line that must stay in the nested item.Committer
In most cases, this should be a different person than the contributor.