Skip to content

refactor(markdown-parser): simplify inline newline handling#9446

Merged
ematipico merged 3 commits intobiomejs:mainfrom
jfmcdowell:refactor/handle-inline-newline
Mar 11, 2026
Merged

refactor(markdown-parser): simplify inline newline handling#9446
ematipico merged 3 commits intobiomejs:mainfrom
jfmcdowell:refactor/handle-inline-newline

Conversation

@jfmcdowell
Copy link
Contributor

@jfmcdowell jfmcdowell commented Mar 11, 2026

Note

AI Assistance Disclosure: This PR was developed with assistance from Claude Code.

Summary

Refactor handle_inline_newline into smaller helpers so paragraph newline handling is easier to follow and review without changing markdown parsing behavior.

  • Extract helpers for newline text emission, quote blank-line detection, quote-prefix breaks, setext breaks, list interrupts, and continuation indent emission.
  • Document side-effecting boolean helpers with doc comments referencing CommonMark spec sections.
  • Add focused regression coverage for nested list interruption after an inline newline.

Test Plan

  • just test-crate biome_markdown_parser
  • just test-markdown-conformance (652/652, 100%)
  • just f && just l

Docs

N/A — internal parser refactor with no user-facing behavior change.

@changeset-bot
Copy link

changeset-bot bot commented Mar 11, 2026

⚠️ No Changeset found

Latest commit: fafc828

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 the A-Parser Area: parser label Mar 11, 2026
Extract newline handling helpers, restore spec rationale comments, and cover nested list interruption.
@jfmcdowell jfmcdowell force-pushed the refactor/handle-inline-newline branch from b6b7ba3 to 08d45b1 Compare March 11, 2026 13:05
… 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.
@jfmcdowell jfmcdowell changed the title refactor(markdown_parser): simplify inline newline handling refactor(markdown-parser): simplify inline newline handling Mar 11, 2026
@jfmcdowell jfmcdowell marked this pull request as ready for review March 11, 2026 13:51
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

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: 4d3303f6-2f63-45e8-a900-fd4fbfa93bf1

📥 Commits

Reviewing files that changed from the base of the PR and between 198a9b1 and fafc828.

📒 Files selected for processing (2)
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/tests/spec_test.rs

Walkthrough

Refactors 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

  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarises the main refactoring work—extracting inline newline handling into smaller helper functions without changing observable behaviour.
Description check ✅ Passed The description clearly relates to the changeset, explaining the refactoring, listing extracted helpers, and detailing the test plan and regression coverage added.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between f2debed and 198a9b1.

⛔ Files ignored due to path filters (1)
  • crates/biome_markdown_parser/tests/md_test_suite/ok/nested_list_interrupt_after_newline.md.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (3)
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/tests/md_test_suite/ok/nested_list_interrupt_after_newline.md
  • crates/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.
@ematipico ematipico merged commit 09e4a62 into biomejs:main Mar 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants