Skip to content

fix(markdown_parser): column-aware tab handling around block containers - #10345

Merged
dyc3 merged 1 commit into
biomejs:mainfrom
jfmcdowell:fix/markdown-fuzz-followups
May 12, 2026
Merged

dyc3 merged 1 commit into
biomejs:mainfrom
jfmcdowell:fix/markdown-fuzz-followups

Conversation

@jfmcdowell

@jfmcdowell jfmcdowell commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

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_parser
  • just test-crate biome_markdown_formatter
  • just test-markdown-conformance
  • Differential fuzz against commonmark.js

Docs

N/A

@changeset-bot

changeset-bot Bot commented May 11, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c99d8f9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added A-Parser Area: parser L-Markdown Language: Markdown labels May 11, 2026
@codspeed

codspeed Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 228 skipped benchmarks1


Comparing jfmcdowell:fix/markdown-fuzz-followups (c99d8f9) with main (d50546a)

Open in CodSpeed

Footnotes

  1. 228 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@jfmcdowell
jfmcdowell force-pushed the fix/markdown-fuzz-followups branch from 1cccbbf to b5d206e Compare May 11, 2026 19:43
@jfmcdowell
jfmcdowell marked this pull request as ready for review May 11, 2026 20:25
@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 90b8e0f9-34c8-4ef6-839f-15d975a1efb1

📥 Commits

Reviewing files that changed from the base of the PR and between 2a300ed and c99d8f9.

⛔ Files ignored due to path filters (5)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_ends_at_unprefixed_ordered_list.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet_siblings.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/link_reference_definition_paragraph_continuation.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_item_tab_indented_fenced_code.md.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (12)
  • crates/biome_markdown_parser/src/parser.rs
  • crates/biome_markdown_parser/src/syntax/list.rs
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/src/syntax/quote.rs
  • crates/biome_markdown_parser/src/to_html.rs
  • crates/biome_markdown_parser/tests/fuzz_corpus/seed.jsonl
  • crates/biome_markdown_parser/tests/fuzz_generate_corpus.cjs
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_ends_at_unprefixed_ordered_list.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet_siblings.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/link_reference_definition_paragraph_continuation.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_item_tab_indented_fenced_code.md
✅ Files skipped from review due to trivial changes (5)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet_siblings.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_item_tab_indented_fenced_code.md
  • crates/biome_markdown_parser/tests/fuzz_corpus/seed.jsonl
  • crates/biome_markdown_parser/tests/md_test_suite/ok/link_reference_definition_paragraph_continuation.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • crates/biome_markdown_parser/src/syntax/quote.rs
  • crates/biome_markdown_parser/tests/fuzz_generate_corpus.cjs
  • crates/biome_markdown_parser/src/to_html.rs
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/src/syntax/list.rs
  • crates/biome_markdown_parser/src/parser.rs

Walkthrough

The 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

  • biomejs/biome#9717: Also modifies Markdown parser indentation logic and list/continuation measurements.
  • biomejs/biome#10198: Changes lazy continuation and handle_line_continuation logic in the same parser regions.
  • biomejs/biome#10228: Related quote-breaking and leading/residual-indent fixes.

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: implementing column-aware tab handling for block containers in the Markdown parser.
Description check ✅ Passed The description clearly relates to the changeset, explaining the fix addresses tab handling around block containers and includes test coverage and verification details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d50546a and 2a300ed.

⛔ Files ignored due to path filters (5)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_ends_at_unprefixed_ordered_list.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet_siblings.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/link_reference_definition_paragraph_continuation.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_item_tab_indented_fenced_code.md.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (12)
  • crates/biome_markdown_parser/src/parser.rs
  • crates/biome_markdown_parser/src/syntax/list.rs
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/src/syntax/quote.rs
  • crates/biome_markdown_parser/src/to_html.rs
  • crates/biome_markdown_parser/tests/fuzz_corpus/seed.jsonl
  • crates/biome_markdown_parser/tests/fuzz_generate_corpus.cjs
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_ends_at_unprefixed_ordered_list.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/blockquote_tab_indented_bullet_siblings.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/link_reference_definition_paragraph_continuation.md
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_item_tab_indented_fenced_code.md

@jfmcdowell
jfmcdowell force-pushed the fix/markdown-fuzz-followups branch from 2a300ed to c961dc0 Compare May 11, 2026 20:37
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.
@jfmcdowell
jfmcdowell force-pushed the fix/markdown-fuzz-followups branch from c961dc0 to c99d8f9 Compare May 11, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser L-Markdown Language: Markdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants