fix(markdown_parser): break paragraph at sibling list marker without tab#10376
Conversation
|
Merging this PR will not alter performance
Comparing Footnotes
|
10c7543 to
0a69940
Compare
Inside a list item, a sibling ordered marker at column <= the item's marker_indent must end the current paragraph (CommonMark §5.2). break_for_list_interrupt_after_inline_newline only ran the marker lookahead when the leading whitespace contained a tab, so a non-tab sibling ordered marker was missed whenever the parent's post-marker space widened required_indent past the sibling's column. Reproducer (biomejs#10374): 1. first 2. second 1. third 2. fourth Inner item `1. third` has marker_indent=4, required_indent=9. The next line at indent 4 is a sibling, but `indent < required_indent` and no tab in the leading whitespace, so the break check returned false and `2. fourth` plus its leading 4 spaces were swallowed as MD_TEXTUAL_LITERALs inside the first inner item's paragraph. The non-tab path now runs a narrow token lookahead that only flags non-1 ordered markers — parse_inline_item_list's textual_looks_like_list_marker already terminates on bullets and on `1.`/`1)`, so widening to all marker shapes regressed synthetic/nested-lists by ~10% without buying additional correctness. The tab path keeps the original token-aware lookahead (biomejs#10333). Verified: - cargo test -p biome_markdown_parser (all 256 tests pass) - cargo test -p biome_markdown_formatter (all 839 tests pass) - cargo bench synthetic/nested-lists: cached +5%, uncached noise
0a69940 to
716cb1f
Compare
|
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 ignored due to path filters (1)
📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughDetects non- 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md (1)
1-4: ⚡ Quick winPlease add a delimiter-crossing fixture too.
This reproducer proves the list shape, but it will not catch the inline-prescan case above. A variant with an opener on the first line and its closer inside the nested
2.item would pin the paragraph boundary down nicely.As per coding guidelines "All code changes MUST include tests: lint rules in
crates/biome_<lang>_analyze/tests/specs/{group}/{rule}/, formatter snapshot tests with valid/invalid cases, parser tests for valid and error cases, and bug fix tests reproducing and validating the fix".🤖 Prompt for 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. In `@crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md` around lines 1 - 4, Add a second test fixture that crosses a block delimiter: create a variant of ordered_sublist_post_marker_wide_space.md where an opening paragraph/inline delimiter starts on the first top-level item line and its closing delimiter appears inside the nested "2." subitem (so the paragraph runs across the list-item boundary), ensuring this captures the inline-prescan case; name it clearly (e.g., ordered_sublist_post_marker_wide_space_delimiter_cross.md) and place it alongside the existing fixture in the same tests directory so the parser test suite validates the delimiter-crossing behavior.
🤖 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 1169-1173: The prescan path in inline_list_source_len() must
mirror parse_inline_item_list()’s new break logic: when indent <
required_indent, reuse the same predicate used there (i.e. call
at_block_interrupt_after_indent() or the exact checks used by
parse_inline_item_list() such as line_start_indent_contains_tab() followed by
line_starts_with_list_marker_after_indent() or
line_starts_with_nonone_ordered_marker_after_indent()) so the prescan stops on
non-`1` sibling markers the same way; update inline_list_source_len() to invoke
the same helper/predicate sequence (or directly call
at_block_interrupt_after_indent()) instead of only
at_block_interrupt()/textual_looks_like_list_marker() to prevent scanning past
the paragraph boundary and leaking delimiters.
---
Nitpick comments:
In
`@crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md`:
- Around line 1-4: Add a second test fixture that crosses a block delimiter:
create a variant of ordered_sublist_post_marker_wide_space.md where an opening
paragraph/inline delimiter starts on the first top-level item line and its
closing delimiter appears inside the nested "2." subitem (so the paragraph runs
across the list-item boundary), ensuring this captures the inline-prescan case;
name it clearly (e.g.,
ordered_sublist_post_marker_wide_space_delimiter_cross.md) and place it
alongside the existing fixture in the same tests directory so the parser test
suite validates the delimiter-crossing behavior.
🪄 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: 468fa92f-d8af-476f-834d-c7e14831f7a5
⛔ Files ignored due to path filters (1)
crates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (2)
crates/biome_markdown_parser/src/syntax/mod.rscrates/biome_markdown_parser/tests/md_test_suite/ok/ordered_sublist_post_marker_wide_space.md
textual_looks_like_list_marker matches only 1./1) for ordered, so inline_list_source_len walked past sibling 2.-style markers folded into MD_TEXTUAL_LITERAL and leaked emphasis delimiters from the next list item. Mirror parse_inline_item_list's break (biomejs#10374) by adding textual_starts_with_ordered_marker to at_block_interrupt_after_indent. Refs biomejs#10376
Note
I used Codex to help plan, implement, and validate this fix.
Summary
Fixes #10374.
Break markdown list paragraphs when a sibling or parent list marker appears at the current item marker indent. The previous check only handled the tab-indented case, so a nested ordered sibling with wider post-marker spacing was parsed as paragraph text.
Test Plan
just test-crate biome_markdown_parserjust test-crate biome_markdown_formatterjust test-markdown-conformanceDocs
N/A.