refactor(markdown-parser): simplify inline newline handling#9446
refactor(markdown-parser): simplify inline newline handling#9446ematipico merged 3 commits intobiomejs:mainfrom
Conversation
|
Extract newline handling helpers, restore spec rationale comments, and cover nested list interruption.
b6b7ba3 to
08d45b1
Compare
… and document side effect Add a dedicated CST snapshot fixture for nested list marker interruption after an inline newline, replacing reliance on the HTML-level quick_test. Document the side-effecting behavior of break_for_quote_prefix_after_inline_newline to clarify that it consumes quote prefix tokens in addition to returning a boolean.
|
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 (2)
WalkthroughRefactors inline-newline handling in crates/biome_markdown_parser/src/syntax/mod.rs by extracting inlined branches into pub(crate) helper functions for newline-as-text emission, quote blank-line detection and prefix consumption, setext interruption checks, list-interrupt decisions, and inline-continuation indent emission. handle_inline_newline now orchestrates these helpers with equivalent observable behaviour. Adds tests for nested list interruption after a newline. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 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
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/biome_markdown_parser/src/syntax/mod.rs`:
- Around line 920-932: The setext-detection path after computing real_indent
currently only accepts the underline if it begins immediately, which drops cases
like "- foo\n ---"; update the lookahead/handling so that after confirming the
underline (the p.lookahead closure checking MD_SETEXT_UNDERLINE_LITERAL or
MD_THEMATIC_BREAK_LITERAL via is_dash_only_thematic_break) you perform the same
0–3-space probe used by the non-list path (i.e., consume up to three optional
spaces with p.skip_line_indent or equivalent) before returning true and calling
p.emit_indent_tokens; ensure emitted indent tokens reflect required_indent plus
any consumed optional spaces so the optional setext indent is preserved.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 874cf8b7-8410-4861-93e4-25d272ac3317
⛔ Files ignored due to path filters (1)
crates/biome_markdown_parser/tests/md_test_suite/ok/nested_list_interrupt_after_newline.md.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (3)
crates/biome_markdown_parser/src/syntax/mod.rscrates/biome_markdown_parser/tests/md_test_suite/ok/nested_list_interrupt_after_newline.mdcrates/biome_markdown_parser/tests/spec_test.rs
…side list items Use `at_setext_underline_after_newline` (which probes 0–3 optional spaces) instead of a raw token check so that `- foo\n ---` is correctly parsed as a setext heading rather than a thematic break.
Note
AI Assistance Disclosure: This PR was developed with assistance from Claude Code.
Summary
Refactor
handle_inline_newlineinto smaller helpers so paragraph newline handling is easier to follow and review without changing markdown parsing behavior.Test Plan
just test-crate biome_markdown_parserjust test-markdown-conformance(652/652, 100%)just f && just lDocs
N/A — internal parser refactor with no user-facing behavior change.