Skip to content

🐛 FIX: Don't read a > indented by 4+ spaces as a block quote marker on continuation lines - #474

Open
bardrop wants to merge 1 commit into
executablebooks:masterfrom
bardrop-oss:fix-blockquote-indented-marker
Open

bardrop wants to merge 1 commit into
executablebooks:masterfrom
bardrop-oss:fix-blockquote-indented-marker

Conversation

@bardrop

@bardrop bardrop commented Nov 17, 2026

Copy link
Copy Markdown

Fixes #473.

A block quote marker can be indented by at most 3 spaces. blockquote() checks this for the first line (state.is_code_block(startLine)), but the loop over the following lines only checked isOutdented. So a continuation line like > b was read as a marker and its > was dropped:

>>> MarkdownIt("commonmark").render("> a\n    > b\n")
'<blockquote>\n<p>a\nb</p>\n</blockquote>\n'   # before
'<blockquote>\n<p>a\n&gt; b</p>\n</blockquote>\n'   # after, same as commonmark.js 0.31.2

The fix adds not state.is_code_block(nextLine) to the marker check, so such a line goes on to the lazy continuation path. Using is_code_block keeps the existing behaviour when the code rule is disabled (then 4+ space markers are allowed, as for the first line).

I found this by running markdown-it-py and commonmark.js 0.31.2 on ~30,000 generated inputs. markdown-it 15.0.3 has the same gap.

Tests: 4 new cases in tests/test_port/fixtures/issue-fixes.md (top level, inside a list item, nested block quote, and a 3-space guard). The first 3 fail without the change. pytest tests: 1194 passed; pre-commit (ruff, ruff-format, mypy) clean. On the same 30,000 inputs, 4 more now match commonmark.js and none newly differ.

… on continuation lines

A block quote marker may be indented by at most 3 spaces. The first line
already checks this with is_code_block, but the loop over the following
lines did not, so `> a\n    > b` dropped the second `>` instead of keeping
it as lazy paragraph continuation text (as commonmark.js does).

Fixes executablebooks#473

This branch has not been deployed

No deployments
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.

Block quote marker indented by 4+ spaces is still read as a marker on continuation lines

1 participant