Skip to content

fix(parse/html): don't lex "use" as USE_KW when in html text content#9151

Merged
dyc3 merged 1 commit intomainfrom
dyc3/fix-use-keyword-in-html-content
Feb 20, 2026
Merged

fix(parse/html): don't lex "use" as USE_KW when in html text content#9151
dyc3 merged 1 commit intomainfrom
dyc3/fix-use-keyword-in-html-content

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Feb 19, 2026

Summary

Previously, the HTML lexer emitted keyword tokens (e.g. USE_KW, STYLE_KW) when those words appear as plain text content between HTML tags. The parser has a guard (is_at_svelte_keyword) that re-lexes keyword tokens as HtmlText when they appear in a text-content position, but T![use] and T![style] were missing from that guard.

planned by sonnet 4.6 and tests generated by kimi k2.5

Test Plan

added snapshot tests

Docs

@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: 0cabd62

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 Feb 19, 2026
@dyc3 dyc3 marked this pull request as ready for review February 19, 2026 21:08

// #region Check functions

const SVELTE_KEYWORDS: TokenSet<HtmlSyntaxKind> = token_set!(
Copy link
Member

Choose a reason for hiding this comment

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

I would rename this, because now it doesn't contain all Svelte keywords

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does because of the .union

@dyc3 dyc3 changed the base branch from dyc3/refactor-html-use-token-sets to graphite-base/9151 February 19, 2026 22:28
@dyc3 dyc3 force-pushed the graphite-base/9151 branch from cc891a3 to bf0f5a8 Compare February 19, 2026 22:29
@dyc3 dyc3 force-pushed the dyc3/fix-use-keyword-in-html-content branch from 4027bb2 to 5ef8c9a Compare February 19, 2026 22:29
@dyc3 dyc3 changed the base branch from graphite-base/9151 to dyc3/refactor-html-use-token-sets February 19, 2026 22:29
@dyc3 dyc3 force-pushed the dyc3/refactor-html-use-token-sets branch 2 times, most recently from d24c2d1 to 5f1fdb5 Compare February 20, 2026 12:22
@dyc3 dyc3 force-pushed the dyc3/fix-use-keyword-in-html-content branch from 5ef8c9a to 5f731a2 Compare February 20, 2026 12:22
@dyc3 dyc3 changed the base branch from dyc3/refactor-html-use-token-sets to graphite-base/9151 February 20, 2026 12:59
@dyc3 dyc3 force-pushed the dyc3/fix-use-keyword-in-html-content branch from 5f731a2 to cb3acb7 Compare February 20, 2026 13:00
@graphite-app graphite-app bot changed the base branch from graphite-base/9151 to main February 20, 2026 13:01
@dyc3 dyc3 force-pushed the dyc3/fix-use-keyword-in-html-content branch from cb3acb7 to 0cabd62 Compare February 20, 2026 13:01
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

This patch fixes incorrect parsing of Svelte directive keywords when they appear as plain text content in HTML/Svelte files. The change modifies the SVELTE\_KEYWORDS constant to include directive keywords (use, style, bind, transition, in, out, class, animate) via union with SVELTE\_DIRECTIVE\_KEYWORDS. This ensures plain text like "use JavaScript" is correctly treated as text content rather than triggering directive parsing. Test files verify the fix handles keyword directives rendered as text within span and paragraph elements.

Possibly related PRs

Suggested reviewers

  • ematipico
  • chansuke
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the core change: fixing the lexing of 'use' as a keyword when appearing in HTML text content rather than as a Svelte directive.
Description check ✅ Passed The description clearly explains the problem (missing keywords in the is_at_svelte_keyword guard), the motivation (preventing incorrect keyword token emission in text content), and includes test coverage details.

✏️ 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
  • Commit unit tests in branch dyc3/fix-use-keyword-in-html-content

Tip

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


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

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 20, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 152 skipped benchmarks1


Comparing dyc3/fix-use-keyword-in-html-content (0cabd62) with main (4317572)

Open in CodSpeed

Footnotes

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

Copy link
Contributor Author

dyc3 commented Feb 20, 2026

Merge activity

  • Feb 20, 1:16 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 20, 1:16 PM UTC: @dyc3 merged this pull request with Graphite.

@dyc3 dyc3 merged commit c0d4b0c into main Feb 20, 2026
18 checks passed
@dyc3 dyc3 deleted the dyc3/fix-use-keyword-in-html-content branch February 20, 2026 13:16
@github-actions github-actions bot mentioned this pull request Feb 20, 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.

2 participants