Repository navigation
fix(markdown_parser): column-aware tab handling around block containers - #10345
Conversation
|
Merging this PR will not alter performance
Comparing Footnotes
|
1cccbbf to
b5d206e
Compare
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (12)
✅ Files skipped from review due to trivial changes (5)
🚧 Files skipped from review as they are similar to previous changes (6)
WalkthroughThe PR adds a single-entry cached absolute-column helper and two tab-stop-aware indentation helpers, applies them to leading-indent checks in parser.rs, list.rs and quote.rs, tightens blockquote/list continuation and quote-break detection, updates HTML rendering to use node start columns for stripping indentation, and expands fuzz generators/seeds plus md fixtures focused on tab-indentation edge cases. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/biome_markdown_parser/src/syntax/mod.rs`:
- Around line 354-365: The branch incorrectly treats textual "1." markers as not
starting with one because is_ordered_list_starts_with_one(p) only checks
MD_ORDERED_LIST_MARKER; update the logic so textual markers are handled or defer
the guard: either extend is_ordered_list_starts_with_one(p) to also return true
when at_order_list_item_textual(p) and the textual marker parses as "1" (inspect
the textual token content or parser lookahead used by
at_order_list_item_textual), or move the check that uses
is_ordered_list_starts_with_one(p) to after the computation of the forced
variable so the forced re-lex path (using
at_order_list_item_textual/at_order_list_item and forced) runs first; adjust
parse_paragraph fallback accordingly to ensure a textual "1. item" after a
link_reference_definition_continuation is treated as a list start.
- Around line 971-999: begins_blockquote_terminating_block currently only
inspects p.cur_text(), so inputs where post-quote whitespace is a separate token
(e.g. "> \\t2. item") are missed; update the function
(begins_blockquote_terminating_block) to perform a small token lookahead on the
MarkdownParser: if the current token is a whitespace-only MD_TEXTUAL_LITERAL,
advance into the next token(s) that are also whitespace-only and then use that
following token's text (or the first non-whitespace token) when calling
textual_starts_with_ordered_marker; keep using p.at(MD_ORDERED_LIST_MARKER) and
p.cur_text() APIs to detect ordered markers and preserve the existing digit_len
logic and the special-case for `1` so semantics are unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d4ebcb77-2a68-4181-a7c1-6829d9ce2737
⛔ Files ignored due to path filters (5)
crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_ends_at_unprefixed_ordered_list.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet_siblings.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_parser/tests/md_test_suite/ok/link_reference_definition_paragraph_continuation.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_parser/tests/md_test_suite/ok/list_item_tab_indented_fenced_code.md.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (12)
crates/biome_markdown_parser/src/parser.rscrates/biome_markdown_parser/src/syntax/list.rscrates/biome_markdown_parser/src/syntax/mod.rscrates/biome_markdown_parser/src/syntax/quote.rscrates/biome_markdown_parser/src/to_html.rscrates/biome_markdown_parser/tests/fuzz_corpus/seed.jsonlcrates/biome_markdown_parser/tests/fuzz_generate_corpus.cjscrates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_ends_at_unprefixed_ordered_list.mdcrates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet.mdcrates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet_siblings.mdcrates/biome_markdown_parser/tests/md_test_suite/ok/link_reference_definition_paragraph_continuation.mdcrates/biome_markdown_parser/tests/md_test_suite/ok/list_item_tab_indented_fenced_code.md
2a300ed to
c961dc0
Compare
Make tab indentation around blockquote markers, list-item continuation indent, paragraph breaks, and fenced/setext code rendering column-aware per CommonMark §2.2. Previously, every tab was counted as four spaces regardless of column position, which mis-parsed or mis-rendered several constructions surfaced by a differential fuzzer against commonmark.js. User-visible parser/rendering fixes: - `> \t- nested` parses as a blockquote containing a bullet list instead of an indented code block, since the tab at column 2 only advances to column 4 (2 cols of indent, not 4). - `> outer\n> \t- nested` interrupts the outer paragraph at the second line so a nested list begins, by skipping leading whitespace in the quote-prefix interrupt classifier before re-lexing at line start. - Fenced code blocks indented by a tab inside a list item strip the full tab from each body line. The renderer cross-checks the fence's absolute column with the explicit `MdIndentTokenList` so a tab that spans the list/quote prefix and the fence's own indent slot is still accounted for when computing the body strip width. - Paragraph rendering trims leading tabs from the first line. - Setext heading rendering reuses `strip_paragraph_indent` so continuation lines no longer leak interior leading whitespace. - After a link reference definition with no blank line, an ordered list whose first number is not `1` is treated as paragraph continuation (it cannot interrupt a paragraph per §5.2). - A blockquote ends when the next unprefixed line begins any block construct (e.g. `10.` ordered list), matching CommonMark's stricter laziness rule. - Tab-indented bullet siblings inside a blockquote are siblings rather than nested. `line_indent_from_current` now expands tabs relative to the absolute column position so the list item continuation check reports the correct indent and breaks out at the marker_indent. Test infrastructure: - Extends the differential fuzz corpus generator with tab-focused combinators (`genTabIndentedSiblings`, `genTabNestedList`, `genMixedTabSpaceIndent`, etc.). - Adds 12 new seed cases locking in the regressions above. - Adds 5 CST snapshot fixtures under `md_test_suite/ok/` for the new parser behaviors. Verification: - `just test-crate biome_markdown_parser` (151 tests). - `just test-crate biome_markdown_formatter` (817 tests). - `just test-markdown-conformance` (651/652, unchanged). - Differential fuzz against commonmark.js: 187361 cases, 0 failures at seed 2026; 4321 cases at seed 10333 also clean.
c961dc0 to
c99d8f9
Compare
Note
I used Claude Code to plan and implement this fix.
Summary
Follow-up to #10333. Fixes the broader class of Markdown parser issues where tabs around block containers were treated as fixed-width indentation instead of column-aware CommonMark whitespace.
Test Plan
Added CST fixtures and fuzz seed cases covering blockquotes, lists, fenced code blocks, setext headings, and link reference continuation cases.
Verified with:
just test-crate biome_markdown_parserjust test-crate biome_markdown_formatterjust test-markdown-conformanceDocs
N/A