Skip to content

fix(html): handle escaped regex literals in astro frontmatter#9728

Merged
dyc3 merged 3 commits intobiomejs:mainfrom
mkosei:fix/astro-regex-frontmatter
Mar 30, 2026
Merged

fix(html): handle escaped regex literals in astro frontmatter#9728
dyc3 merged 3 commits intobiomejs:mainfrom
mkosei:fix/astro-regex-frontmatter

Conversation

@mkosei
Copy link
Copy Markdown
Contributor

@mkosei mkosei commented Mar 30, 2026

Summary

Fixes #9696

Fix Astro frontmatter parsing for regex literals like /\d{4}/.

The lexer now resolves a deferred / before generic escape handling, so regex literals starting with an escaped character are recognized correctly inside frontmatter.

Test Plan

  • cargo test -p biome_html_parser quotes_seen -- --nocapture

Docs

Not applicable.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 30, 2026

🦋 Changeset detected

Latest commit: 9350f15

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added A-Parser Area: parser L-HTML Language: HTML and super languages labels Mar 30, 2026
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.

  • link the issue in your pr description
  • needs changeset
  • must have ai disclosure if used

@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: c1c73daa-d1e7-4c11-8cb2-d02b4ed99a21

📥 Commits

Reviewing files that changed from the base of the PR and between 3413ac3 and 9350f15.

⛔ Files ignored due to path filters (1)
  • crates/biome_html_parser/tests/html_specs/ok/astro/issue_9696.astro.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (1)
  • crates/biome_html_parser/tests/html_specs/ok/astro/issue_9696.astro
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_html_parser/tests/html_specs/ok/astro/issue_9696.astro

Walkthrough

The HTML lexer’s QuotesSeen::check_byte was changed to move backslash (\) escape handling later in the control flow — after regex/comment opener detection and string-delimiter tracking — instead of toggling escaped immediately on \\. A unit test issue_9187_regex_with_escape_and_quantifier was added to assert that regex like /\d{4}/ leaves QuotesSeen empty (cleanly closed) during Astro frontmatter parsing.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: fixing Astro frontmatter parsing for escaped regex literals, which is the core objective addressed by this PR.
Description check ✅ Passed The description clearly explains the fix, references the related issue (#9696), and provides a concrete test plan relevant to the changeset.
Linked Issues check ✅ Passed The PR successfully addresses issue #9696 by reordering escape-sequence handling in the lexer so regex literals with escaped characters (like /\\d{4}/) are correctly parsed in Astro frontmatter, eliminating the parse errors.
Out of Scope Changes check ✅ Passed All changes are focused on fixing Astro frontmatter regex parsing: lexer escape-sequence reordering, unit test, changeset documentation, and a test fixture—all directly related to the stated objective.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 30, 2026

Merging this PR will not alter performance

✅ 67 untouched benchmarks
⏩ 189 skipped benchmarks1


Comparing mkosei:fix/astro-regex-frontmatter (9350f15) with main (467fd87)2

Open in CodSpeed

Footnotes

  1. 189 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 (8b7f55c) during the generation of this report, so 467fd87 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@mkosei
Copy link
Copy Markdown
Contributor Author

mkosei commented Mar 30, 2026

Updated the PR description to link #9696, added a changeset.

@mkosei mkosei requested a review from dyc3 March 30, 2026 18:00
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.

Let's also add a snapshot test for this

@dyc3 dyc3 merged commit 5085424 into biomejs:main Mar 30, 2026
17 checks passed
@github-actions github-actions Bot mentioned this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Astro: Parse error for certain RegExps in the frontmatter

2 participants