fix(md): parse space+tab indented sublists as nested list items#10703
Conversation
Tabs were counted as a flat 4 columns and sibling list markers were only matched at the item content indent, so space+tab-indented sublist items were absorbed as lazy paragraph continuation (biomejs#10558). Make tab expansion column-relative per CommonMark 2.2 (TAB_STOP_SPACES minus column mod TAB_STOP_SPACES) and add at_sibling_list_marker to detect sibling bullet and ordered markers at the enclosing item marker indent. The issue input now parses as a single nested ul with three li children. Parser suite (169 spec tests incl. a new regression test), formatter suite (817 tests) and factory tests all pass. The three formatter snapshots that changed were documenting formatter bugs caused by this parser bug and now match Prettier.
|
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughThe Markdown parser gains CommonMark-compliant tab-stop expansion: 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)
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 |
Merging this PR will not alter performance
Comparing Footnotes
|
compute_marker_indent now scans through leading tabs (column-relative) to the marker when the line's leading whitespace contains a tab, so 2space+tab and 3space+tab indents that expand to column 4 are measured as 4 rather than as the space count only. Pure-space lines keep the original behavior. Adds regression tests for both variants. All fuzz genLooseTabSublist cases (space+tab, 2space+tab, 3space+tab, pure tab) now parse as three sibling list items.
Replace the pure-space char-count loop with chars().count() so the loop variable is no longer unused. Behavior is unchanged.
ematipico
left a comment
There was a problem hiding this comment.
Looks good, but the docs need some. Please look after them
| // A sibling list item sits at the enclosing item's *marker* indent, | ||
| // which can be below its content (`required`) indent when the marker | ||
| // is followed by more than one space (or a tab). Detect siblings at | ||
| // the marker indent too, otherwise such lines are absorbed as lazy | ||
| // paragraph continuation (biomejs/biome#10558). |
There was a problem hiding this comment.
Do you understand this comment? What does the mention of "required" mean? Also, why is there a mention of an issue? We're fixing a bug.
| /// Tabs expand column-relative to the next multiple of `TAB_STOP_SPACES` (4), | ||
| /// per CommonMark §2.2. Counting a tab as a flat 4 would over-count when the | ||
| /// tab does not start at a column that is already a multiple of 4 (e.g. a | ||
| /// leading ` \t` is 4 columns, not 5), which mis-classifies space+tab-indented | ||
| /// sub-list markers as lazy paragraph continuation (biomejs/biome#10558). |
There was a problem hiding this comment.
Did you read the comment? This isn't documentation, it's Claude Code writing a diary. Please reword it so it's sounds like proper documentation. There's also no need to track the issue. We're fixing a bug.
|
give me 20min i think need to do myself. |
Closes #10558.
Summary
Space+tab-indented sublists were parsed as lazy paragraph continuation instead of nested list items. The fix makes tab expansion column-relative per CommonMark 2.2, and detects sibling list markers at the enclosing item's marker indent.
Before, only the first
- foobecame a list item;lreumandbarwere absorbed as paragraph text. They are now three sibling<li>items.Test Plan
cargo test -p biome_markdown_parser(incl. new regression testsublist_loose_space_tab_indent.md)cargo test -p biome_markdown_formattercargo test -p biome_markdown_factoryAll pass. Three formatter snapshots (
tab.md,nested-tab.md,indent.md) were previously capturing formatter bugs caused by this parser bug; they now match Prettier.Note: the pure 4-space indent variant (
- foo/- lreum) has a separate pre-existing issue (siblings nesting one level too deep) that is out of scope here.