Skip to content

Ordered list following a blockquote is incorrectly nested inside the blockquote #4002

Closed

Description

@Deuscx

Marked version: 18.0.5

Describe the bug

When an ordered list item immediately follows a blockquote line (no blank line, list marker at column 0), marked’s blockquote tokenizer lazy-continues and absorbs the list into the blockquote. The list is parsed as a nested ordered list inside the blockquote instead of a sibling block.

This affects ordered lists only. An unordered list after a blockquote is parsed correctly as a sibling. A blockquote followed by a blank line and then a list is also parsed correctly.

The root cause appears to be in the blockquote() tokenizer: when the last parsed child inside a blockquote is a list, marked merges remaining lines into that list (h?.type === "list" branch), which pulls in subsequent ordered-list lines that should end the blockquote.

To Reproduce

  1. Marked Demo — paste:
1. test
> blockquote
2. test
> blockquote
  1. CommonMark Dingus — same input.

Or run locally:

npm install marked
node -e "
const { marked } = require('marked');
const md = \`1. test
> blockquote
2. test
> blockquote\`;
console.log(marked.parse(md, { gfm: true, breaks: true }));
"

Actual output (marked):

<ol>
<li>test</li>
</ol>
<blockquote>
<p>blockquote</p>
<ol start="2">
<li>test<br>blockquote</li>
</ol>
</blockquote>

Lexer tokens show the second list item and the second > blockquote line are trapped inside one blockquote token:

// Simplified token tree
[
  { type: 'list', items: [{ text: 'test' }] },
  {
    type: 'blockquote',
    tokens: [
      { type: 'paragraph', text: 'blockquote' },
      { type: 'list', ordered: true, start: 2, items: [{ text: 'test\nblockquote' }] }
    ]
  }
]

Expected behavior

Per CommonMark (and micromark), the blockquote should close after its content, and the following ordered list items and blockquotes should be sibling blocks:

<ol>
<li>test</li>
</ol>
<blockquote>
<p>blockquote</p>
</blockquote>
<ol start="2">
<li>test</li>
</ol>
<blockquote>
<p>blockquote</p>
</blockquote>

Minimal case:

> blockquote
2. test

Expected: <blockquote><p>blockquote</p></blockquote> followed by <ol start="2"><li>test</li></ol>.

Actual: the <ol> is nested inside the <blockquote>.

Activity

  1. added
    L2 - annoying
    on Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    L2 - annoyingcategory: blockquotescategory: lists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions