Skip to content

test(markdown): add minimal service plumbing for formatter integration#9070

Merged
ematipico merged 4 commits intobiomejs:mainfrom
jfmcdowell:feat/markdown-formatter-test-harness
Feb 21, 2026
Merged

test(markdown): add minimal service plumbing for formatter integration#9070
ematipico merged 4 commits intobiomejs:mainfrom
jfmcdowell:feat/markdown-formatter-test-harness

Conversation

@jfmcdowell
Copy link
Contributor

Note

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

Summary

This PR adds the minimum Markdown formatter plumbing needed so Markdown is recognized as a formattable language in Biome.

PR #8962 introduced formatter boilerplate. This PR focuses on the required syntax/service/formatter-option integration to make Markdown format-capable from the service layer.

Test corpus and comparison/snapshot-heavy formatter tests are handled separately in #9067

Continues work on #3718

Why

Markdown must be recognized by biome_service as a format-capable language before formatter infrastructure can be exercised end-to-end.

Scope

1) Markdown file source + service routing

  • Added MarkdownFileSource with:
    • extension detection: md, markdown
    • language ID detection: markdown
  • Added DocumentFileSource::Markdown support in service routing/capability dispatch.
  • Added markdown handler in biome_service with:
    • parse + format capabilities
    • debug syntax tree + formatter IR
    • formatter/linter/assist enabled checks

2) Markdown formatter options plumbing

  • Added Display for MarkdownFormatOptions (required by service language trait
    bounds).
  • Added option builders:
    • with_indent_style
    • with_indent_width
    • with_line_ending
    • with_trailing_newline

3) Service/settings integration

  • Added markdown language slot to LanguageListSettings.
  • Added markdown deps/schema wiring in biome_service Cargo config.

4) Exhaustive match maintenance

  • Added DocumentFileSource::Markdown arm in xtask/rules_check for exhaustive handling.

5) Follow-up consistency cleanup in this PR

  • Added DocumentFileSource::to_markdown_file_source() accessor for parity with other file source helpers.
  • Added TODOs in markdown service handler to explicitly mark override-pattern support as pending.

Not Included

  • No substantive Markdown formatting behavior changes yet.
  • No markdown fixture/snapshot corpus in this PR.
  • No Prettier markdown snapshot import in this PR.
  • Markdown override-pattern formatting settings are not implemented yet.

Those tests/corpus are being developed in #9067

Validation

  • just f
  • just l

@changeset-bot
Copy link

changeset-bot bot commented Feb 14, 2026

⚠️ No Changeset found

Latest commit: cf6326b

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-Project Area: project A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools labels Feb 14, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 14, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 156 skipped benchmarks1


Comparing jfmcdowell:feat/markdown-formatter-test-harness (cf6326b) with main (7f1e060)

Open in CodSpeed

Footnotes

  1. 156 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

Caution

Review failed

Failed to post review comments

Walkthrough

This PR introduces Markdown language support to the Biome ecosystem alongside significant enhancements to CSS and SCSS parsing and formatting. It adds a new biome_markdown_syntax crate with file-source detection, integrates Markdown formatting and parsing capabilities into the service layer, and extends the CSS parser and formatter with support for unary expressions, SCSS qualified names, nesting declarations, parent selector values, and improved bracketed-value handling. Additionally, it includes fixes for Astro, HTML, Vue, and Svelte parsing edge cases, plus corresponding changelog entries.

Possibly related PRs

Suggested labels

D-Vue, A-Linter

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding minimal service plumbing for Markdown formatter integration, which aligns with the changeset's primary objective.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the rationale, scope, and what's included/excluded.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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

🤖 Fix all issues with AI agents
In `@crates/biome_service/Cargo.toml`:
- Line 74: The manifest uses an explicit version for the notify dependency
instead of the workspace reference; update the crate's Cargo.toml so the notify
dependency references the workspace-level declaration (use workspace = true) or
move notify into the root workspace [dependencies] and keep workspace = true
here; locate the notify entry (notify = { version = "8.2.0", features =
["crossbeam-channel"] }) and change it to a workspace reference consistent with
other dependencies or add notify to the workspace dependencies table and remove
the explicit version here.
🧹 Nitpick comments (2)
crates/biome_service/src/file_handlers/markdown.rs (1)

210-225: Parser metadata is discarded during AnyParse conversion.

parse_markdown_with_cache returns list_tightness, list_item_indents, and quote_indents alongside the syntax tree (see crates/biome_markdown_parser/src/lib.rs). These are lost when converting to AnyParse via NodeParse. This is fine for the current minimal plumbing, but will need addressing when substantive formatting logic lands — list tightness in particular affects Markdown rendering semantics.

crates/biome_service/src/file_handlers/mod.rs (1)

434-441: can_contain_embeds returns false for Markdown — worth a TODO?

Markdown files commonly contain fenced code blocks (e.g., ```js ... ```), which are semantically embedded snippets. Returning false is fine for this minimal plumbing PR, but it might be worth leaving a short comment or TODO so this isn't forgotten when embedded-language support lands.

Optional: leave a breadcrumb
             Self::Html(_) | Self::Js(_) => true,
             Self::Css(_)
             | Self::Graphql(_)
             | Self::Json(_)
             | Self::Grit(_)
+            // TODO: Markdown fenced code blocks may contain embeds — revisit when embedded support lands.
             | Self::Markdown(_)
             | Self::Ignore
             | Self::Unknown => false,

@@ -0,0 +1,267 @@
use super::{
Copy link
Contributor

@tidefield tidefield Feb 15, 2026

Choose a reason for hiding this comment

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

Hi @jfmcdowell . Sorry I'm afraid this will conflict with #9067 soon. :(

I was having this implementation in my local so I can verify the snapshots are correctly captured in the tests. I'm fixing some errors before pushing it to my PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI the reason I needed to implement what you had in this PR is because the tests need to have a TestFormatLanguage implementation which then requires ServiceLanguage implementation. So it overlaps with what you're doing in the PR.

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.

It looks good, however we need to gate the implementation under a cargo feature or Biome will start parsing the files


pub fn try_from_extension(extension: &str) -> Result<Self, FileSourceError> {
match extension {
"md" | "markdown" => Ok(Self::markdown()),
Copy link
Member

Choose a reason for hiding this comment

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

This will enable handling markdown to our users, and we're not ready for this yet. To prevent this, do the same thing I did for SCSS in this PR: #9091

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


pub fn try_from_language_id(language_id: &str) -> Result<Self, FileSourceError> {
match language_id {
"markdown" => Ok(Self::markdown()),
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here, let's gate it under a cargo feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

#[derive(
Debug, Clone, Default, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize,
)]
pub struct MarkdownFileSource {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I would call it MdFileSource, just because it's shorter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@jfmcdowell
Copy link
Contributor Author

@ematipico given @tidefield's comment on #9067 do you want me to hold off on this?

@ematipico
Copy link
Member

ematipico commented Feb 16, 2026

@ematipico given @tidefield's comment on #9067 do you want me to hold off on this?

To be honest, I lack the context of the comment. I don't know what that's about. To me, this PR seems fine cc @tidefield

@jfmcdowell
Copy link
Contributor Author

@ematipico given @tidefield's comment on #9067 do you want me to hold off on this?

To be honest, I lack the context of the comment. I don't know what that's about. To me, this PR seems fine cc @tidefield

#9067 and #9076 mention comments about potential clashes. I think you (@ematipico) gave a path forward but I want to make sure we are all aligned. Cc @tidefield

@tidefield
Copy link
Contributor

Hi @jfmcdowell. Given @ematipico 's comment in #9076 (comment), I think we can prioritize your PR first (switching it to base on main and addressing the comments)

I'll rebase my branch to main after your PR is submitted. 🎉

@jfmcdowell jfmcdowell force-pushed the feat/markdown-formatter-test-harness branch from c9228e0 to f66e03d Compare February 20, 2026 20:55
@jfmcdowell jfmcdowell changed the base branch from next to main February 20, 2026 20:56
@github-actions github-actions bot removed the A-Formatter Area: formatter label Feb 20, 2026
Add the minimum markdown service integration so markdown is recognized as a formattable language and formatter tests can run against the standard service path.

- Add MarkdownFileSource detection for md/markdown extensions and markdown language id.
- Add DocumentFileSource::Markdown routing and markdown handler capabilities in biome_service.
- Add markdown ServiceLanguage settings/format option resolution and formatter entry points.
- Add MarkdownFormatOptions Display + missing option builder methods required by service plumbing.
- Add focused service tests for markdown file-source detection and formatter capability routing.
- Add markdown exhaustive match handling in xtask rules_check.

Scope intentionally excludes Prettier markdown comparison tests (tracked separately).
- Added an experimental-markdown cargo feature to biome_markdown_syntax and
  gated Markdown detection in MdFileSource for:
- file extensions (md, markdown)
- language ID (markdown)
- Renamed MarkdownFileSource to MdFileSource per maintainer feedback and updated all service/syntax references.
- Updated biome_service markdown file-source capability tests to assert default feature-off behavior (Markdown stays Unknown unless the feature is enabled).
@jfmcdowell jfmcdowell force-pushed the feat/markdown-formatter-test-harness branch from f66e03d to e676f78 Compare February 20, 2026 21:02
@jfmcdowell jfmcdowell force-pushed the feat/markdown-formatter-test-harness branch from e676f78 to e512804 Compare February 20, 2026 22:27
@jfmcdowell jfmcdowell requested a review from ematipico February 20, 2026 22:59
@ematipico ematipico merged commit b834078 into biomejs:main Feb 21, 2026
33 checks passed
@jfmcdowell jfmcdowell deleted the feat/markdown-formatter-test-harness branch February 24, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser A-Project Area: project A-Tooling Area: internal tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants