Skip to content

Conversation

@siketyan
Copy link
Member

@siketyan siketyan commented Nov 3, 2025

Summary

Fixes biomejs/website#1391

Backquotes (`) were needed to be escaped in MDX, otherwise it may cause invisible backquotes or broken markups.

Test Plan

Used the updated biome_console crate in the website repository to see if it works on my machine.

image

Docs

N/A

@siketyan siketyan self-assigned this Nov 3, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2025

⚠️ No Changeset found

Latest commit: d42e1b9

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-CLI Area: CLI label Nov 3, 2025
@siketyan
Copy link
Member Author

siketyan commented Nov 3, 2025

I would skip a changeset because we don't support any direct usages of our internal crates, and there are no user-facing interface that emits a markup for MDX.

@siketyan siketyan requested review from a team November 3, 2025 07:20
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

The change modifies the HTML output writer in the console crate to properly escape backtick characters when MDX mode is enabled. Previously, backticks were left unescaped in MDX output; now they are emitted as ` to match the existing HTML escape sequences. This resolves documentation rendering issues where template literal examples were incorrectly displayed due to missing backtick escapes.

Suggested labels

L-HTML

Suggested reviewers

  • Conaclos
  • ematipico

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title "fix(console): escape backquotes in MDX context" directly and clearly describes the primary change in the pull request. It specifies what is being fixed (escaping backquotes), which component is affected (console), and the context where it applies (MDX). The title is concise, avoids vague terminology, and provides sufficient clarity for scanning commit history.
Linked Issues Check ✅ Passed The code changes directly address the requirements in linked issue #1391. The issue identifies HTML escaping problems in documentation examples for the useTemplate lint rule, expecting fixes to be correctly escaped. The modification to crates/biome_console/src/write/html.rs implements backtick escaping in MDX mode (emitting ` instead of raw backticks), which resolves the escaping issue preventing correct rendering of documentation examples.
Out of Scope Changes Check ✅ Passed The changes are narrowly scoped to the stated objective of fixing backquote escaping in MDX. The modification to crates/biome_console/src/write/html.rs adds support for escaping backticks when with_mdx is enabled, directly addressing the HTML escaping issue described in issue #1391. No extraneous changes or unrelated modifications appear to be present.
Description Check ✅ Passed The pull request description is clearly related to the changeset and effectively communicates what's being fixed. It specifically describes the problem (backquotes in MDX causing invisible characters or broken markup), references the exact issue being resolved (#1391), and provides concrete evidence through a test screenshot. The description aligns well with the code changes that add backtick escaping to the MDX HTML rendering path in the biome_console crate. The level of detail is appropriate and the content is directly relevant to the modifications made.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 0

🧹 Nitpick comments (1)
crates/biome_console/src/write/html.rs (1)

122-122: LGTM! Backtick escaping correctly added.

The change properly escapes backticks in MDX mode using the correct HTML entity. This matches the existing pattern for other MDX-specific escapes and directly addresses the documentation rendering issue.

However, consider adding a test case to verify backtick escaping works correctly, similar to the existing tests for curly braces and newlines.

Example test to add at the end of the test module:

#[test]
fn escape_backticks() {
    let mut buf = Vec::new();
    let mut writer = super::HTML(&mut buf, false).with_mdx();
    let mut formatter = Formatter::new(&mut writer);

    formatter
        .write_markup(markup! {
            "Template literal: `foo`"
        })
        .unwrap();

    assert_eq!(
        String::from_utf8(buf).unwrap(),
        "Template literal: `foo`"
    );
}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71f600e and d42e1b9.

📒 Files selected for processing (1)
  • crates/biome_console/src/write/html.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files before committing (e.g., via just f)

Files:

  • crates/biome_console/src/write/html.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and their options with inline rustdoc in the Rust source

Files:

  • crates/biome_console/src/write/html.rs
🧠 Learnings (1)
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Use `dbg_write!` to debug and inspect the emitted IR during formatting

Applied to files:

  • crates/biome_console/src/write/html.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Documentation
  • GitHub Check: autofix
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test Node.js API

@siketyan siketyan merged commit 3e54958 into biomejs:main Nov 3, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📚 Incorrect example fixes for "useTemplate" lint rule

2 participants