Skip to content

feat(md/fmt): format more nodes#9713

Merged
ematipico merged 2 commits intomainfrom
feat/md-fmt-links
Mar 30, 2026
Merged

feat(md/fmt): format more nodes#9713
ematipico merged 2 commits intomainfrom
feat/md-fmt-links

Conversation

@ematipico
Copy link
Copy Markdown
Member

Summary

Markdown formatting of the following nodes:

  • autolink
  • link reference
  • inline image field
  • blockquotes

Added a new printing mode where words are normalised: leading and trailing spaces that exceed 1 are normalised to 1. This matches prettier behaviour

Test Plan

I used AI to help me with the creation of tests

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 30, 2026

⚠️ No Changeset found

Latest commit: e7e110d

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

@ematipico ematipico requested review from a team March 30, 2026 10:25
@github-actions github-actions bot added A-Formatter Area: formatter L-Markdown Language: Markdown labels Mar 30, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 30, 2026

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 228 skipped benchmarks1


Comparing feat/md-fmt-links (e7e110d) with main (dfbdf63)2

Open in CodSpeed

Footnotes

  1. 228 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (fc3f1e3) during the generation of this report, so dfbdf63 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 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: 6caa2390-33eb-4833-95a9-2ab50c7a7fbb

📥 Commits

Reviewing files that changed from the base of the PR and between c379fab and e7e110d.

📒 Files selected for processing (1)
  • crates/biome_markdown_formatter/src/markdown/auxiliary/textual.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_markdown_formatter/src/markdown/auxiliary/textual.rs

Walkthrough

Refactors many Markdown formatter rules to stop emitting verbatim node syntax and instead destructure nodes into fields and format tokens/contents explicitly. Introduces a new trimming variant TrimMode::NormalizeWords and adds normalize-words formatting paths in FormatMdTextual and MdInlineItemList. Numerous auxiliary formatters (autolink, inline code/image, html blocks, links, quotes, thematic breaks, etc.) now format structured fields and tokens, and several new Markdown test specs were added.

Possibly related PRs

  • feat(md/fmt): links, codeblocks #9699 — Similar migrations in the markdown formatter that add/adjust TextPrintMode/TrimMode and convert many nodes from verbatim to structured field-based formatting.

Suggested reviewers

  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: expanding Markdown formatter to handle additional node types.
Description check ✅ Passed The description relates to the changeset by outlining the specific nodes being formatted and the new word-normalisation printing mode introduced.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/md-fmt-links

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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_formatter/src/markdown/auxiliary/textual.rs`:
- Around line 48-49: The whitespace-detection uses ASCII-only checks which
mismatch split_whitespace() Unicode semantics; update the checks that set
has_leading_ws and has_trailing_ws to use char::is_whitespace() (i.e., replace
starts_with(|c: char| c.is_ascii_whitespace()) and ends_with(|c: char|
c.is_ascii_whitespace()) with Unicode-aware checks) so leading/trailing
non-ASCII whitespace (e.g., U+2009) is detected consistently with
split_whitespace().
🪄 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: 9036387a-4567-461d-aa0a-25ce81a1cc25

📥 Commits

Reviewing files that changed from the base of the PR and between dfbdf63 and c379fab.

⛔ Files ignored due to path filters (25)
  • crates/biome_markdown_formatter/tests/specs/markdown/autolink.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/markdown/blockquote.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/markdown/html_block.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/markdown/inline_code.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/markdown/inline_image.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/markdown/link_reference_definition.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/blockquote/code.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/blockquote/ignore-code.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/linkReference/case-and-space/case-and-space.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/markdown/real-world-case.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/paragraph/lorem.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-157.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-158.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-159.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-162.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-170.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-177.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-187.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-200.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-201.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-476.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-507.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-542.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/spec/example-85.md.snap is excluded by !**/*.snap and included by **
  • crates/biome_markdown_formatter/tests/specs/prettier/markdown/splitCjkText/symbolSpaceNewLine.md.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (28)
  • crates/biome_markdown_formatter/src/markdown/auxiliary/autolink.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/entity_reference.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/html_block.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/indent.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/inline_code.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/inline_html.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/inline_image.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/link_destination.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/link_label.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/link_reference_definition.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/link_title.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/newline.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/quote.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/quote_indent.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/quote_prefix.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/soft_break.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/textual.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/thematic_break_block.rs
  • crates/biome_markdown_formatter/src/markdown/auxiliary/thematic_break_char.rs
  • crates/biome_markdown_formatter/src/markdown/lists/inline_item_list.rs
  • crates/biome_markdown_formatter/src/shared.rs
  • crates/biome_markdown_formatter/tests/quick_test.rs
  • crates/biome_markdown_formatter/tests/specs/markdown/autolink.md
  • crates/biome_markdown_formatter/tests/specs/markdown/blockquote.md
  • crates/biome_markdown_formatter/tests/specs/markdown/html_block.md
  • crates/biome_markdown_formatter/tests/specs/markdown/inline_code.md
  • crates/biome_markdown_formatter/tests/specs/markdown/inline_image.md
  • crates/biome_markdown_formatter/tests/specs/markdown/link_reference_definition.md

Comment thread crates/biome_markdown_formatter/src/markdown/auxiliary/textual.rs Outdated
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

snapshots look good

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: revert quick test

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i'll change it a lot, so i'll keep it as is for now

@ematipico ematipico merged commit 9e2ef0d into main Mar 30, 2026
15 checks passed
@ematipico ematipico deleted the feat/md-fmt-links branch March 30, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter L-Markdown Language: Markdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants