Skip to content

refactor(markdown-parser): promote blank lines between list items to MdNewline nodes#9313

Merged
ematipico merged 4 commits intobiomejs:mainfrom
jfmcdowell:refactor/list-marker-prefix
Mar 3, 2026
Merged

refactor(markdown-parser): promote blank lines between list items to MdNewline nodes#9313
ematipico merged 4 commits intobiomejs:mainfrom
jfmcdowell:refactor/list-marker-prefix

Conversation

@jfmcdowell
Copy link
Contributor

Note

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

Summary

  • Add AnyMdBulletListMember = MdBullet | MdNewline union to the grammar, so MdBulletList can hold both item nodes and blank-line nodes as children.
  • Change MdBulletList from MdBullet* to AnyMdBulletListMember*.
  • Update skip_blank_lines_between_items to emit explicit MdNewline CST nodes instead of calling parse_as_skipped_trivia_tokens.
  • Update to_html.rs ordered list start extraction to use iter().find_map() to unwrap AnyMdBulletListMember::MdBullet (replacing direct .first() call).
  • Regenerate formatter codegen for AnyMdBulletListMember (no manual formatter changes).
  • Add test fixture for blank lines between list items (bullet, ordered, multiple blank lines, mixed tight/loose).
  • Update all list parser snapshots to reflect the new CST shape.

This is the follow-up to #9274. skip_blank_lines_between_items was the last remaining skipped-trivia call site for blank lines in list parsing. Each inter-item blank line is now a real MdNewline CST node visible to the formatter harness.

No user-facing behavior change. Parsed semantics and CommonMark conformance are preserved (652/652); only the internal CST representation changes.

Test Plan

  • cargo test -p biome_markdown_parser — 131 tests pass (63 + 68)
  • cargo run -p xtask_coverage -- --suites=markdown/commonmark — 652/652 (100%)
  • cargo check -p biome_markdown_formatter — compiles cleanly
  • just l — lint passes
  • Snapshots verified: MdNewline nodes appear between MdBullet siblings in loose lists; tight lists have no MdNewline between siblings

Docs

N/A — internal structural change, no new user-facing features.

@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: ebfad90

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 A-Formatter Area: formatter A-Tooling Area: internal tools labels Mar 3, 2026
@jfmcdowell jfmcdowell marked this pull request as ready for review March 3, 2026 16:07
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb05546 and f2c5204.

⛔ Files ignored due to path filters (4)
  • crates/biome_markdown_factory/src/generated/node_factory.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_markdown_factory/src/generated/syntax_factory.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_blank_lines_between_items.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_syntax/src/generated/nodes.rs is excluded by !**/generated/**, !**/generated/** and included by **
📒 Files selected for processing (8)
  • crates/biome_markdown_formatter/src/generated.rs
  • crates/biome_markdown_formatter/src/markdown/any/bullet_list_member.rs
  • crates/biome_markdown_formatter/src/markdown/any/mod.rs
  • crates/biome_markdown_parser/src/syntax/list.rs
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/src/to_html.rs
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_blank_lines_between_items.md
  • xtask/codegen/markdown.ungram
🚧 Files skipped from review as they are similar to previous changes (7)
  • crates/biome_markdown_parser/src/syntax/list.rs
  • crates/biome_markdown_formatter/src/markdown/any/bullet_list_member.rs
  • crates/biome_markdown_formatter/src/markdown/any/mod.rs
  • crates/biome_markdown_parser/src/to_html.rs
  • xtask/codegen/markdown.ungram
  • crates/biome_markdown_formatter/src/generated.rs
  • crates/biome_markdown_parser/tests/md_test_suite/ok/list_blank_lines_between_items.md

Walkthrough

This change makes blank lines between list items explicit in the CST by adding a new union AnyMdBulletListMember = MdBullet | MdNewline, updates the parser to emit MdNewline nodes between bullets, extends to_html to locate MdBullet through the new union, adds a generated formatter FormatAnyMdBulletListMember plus AsFormat/IntoFormat impls and a pub(crate) bullet_list_member formatter module, and adds tests exercising blank lines between list items.

Possibly related PRs

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main refactoring: promoting blank lines between list items from trivia to explicit MdNewline CST nodes.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, outlining the grammar changes, parser updates, formatter codegen, tests, and verification steps.

✏️ 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
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Seems there's a conflict to solve

jfmcdowell and others added 3 commits March 3, 2026 11:57
…m skipped trivia to MdNewline nodes

Introduces AnyMdBulletListMember = MdBullet | MdNewline union so that
MdBulletList can hold explicit MdNewline CST nodes for blank lines
between items, replacing the previous parse_as_skipped_trivia_tokens
approach in skip_blank_lines_between_items. This is the final
trivia-promotion site in Phase 2c.

Key changes:
- Grammar: MdBulletList = AnyMdBulletListMember* (was MdBullet*)
- Parser: skip_blank_lines_between_items emits MdNewline nodes
- Consumer: to_html.rs uses iter().find_map() for ordered list start
- Codegen: regenerated formatter/syntax/factory files
@jfmcdowell jfmcdowell force-pushed the refactor/list-marker-prefix branch from fb05546 to f2c5204 Compare March 3, 2026 17:03
@jfmcdowell
Copy link
Contributor Author

jfmcdowell commented Mar 3, 2026

Seems there's a conflict to solve

@ematipico resolved

@ematipico ematipico merged commit 1022662 into biomejs:main Mar 3, 2026
14 checks passed
@jfmcdowell jfmcdowell deleted the refactor/list-marker-prefix branch March 3, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: internal tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants