Skip to content

languages: Add syntax highlighting for HTML character references#48629

Merged
yeskunall merged 1 commit intozed-industries:mainfrom
br-schneider:highlight-html-entities
Feb 23, 2026
Merged

languages: Add syntax highlighting for HTML character references#48629
yeskunall merged 1 commit intozed-industries:mainfrom
br-schneider:highlight-html-entities

Conversation

@br-schneider
Copy link
Contributor

@br-schneider br-schneider commented Feb 6, 2026

HTML character references like ·, ', and { are correctly parsed by tree-sitter as named nodes (html_character_reference in TSX/JavaScript, entity in HTML), but no highlight query captures them. This means they render as plain, unhighlighted text in the editor.

This PR adds one-line highlight captures for each:

  • TSX (crates/languages/src/tsx/highlights.scm): (html_character_reference) @string.special
  • JavaScript (crates/languages/src/javascript/highlights.scm): (html_character_reference) @string.special
  • HTML (extensions/html/languages/html/highlights.scm): (entity) @string.special

@string.special is already styled by all built-in themes (One Dark, Ayu, Gruvbox, etc.), so no theme changes are needed.

Release Notes:

  • Added syntax highlighting for HTML character references (·, ', {, etc.) in TSX, JavaScript, and HTML files.

@cla-bot
Copy link

cla-bot bot commented Feb 6, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @br-schneider on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Feb 6, 2026
@br-schneider
Copy link
Contributor Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Feb 6, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @br-schneider on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot
Copy link

cla-bot bot commented Feb 6, 2026

The cla-bot has been summoned, and re-checked this pull request!

@br-schneider
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 6, 2026
@cla-bot
Copy link

cla-bot bot commented Feb 6, 2026

The cla-bot has been summoned, and re-checked this pull request!

@yeskunall yeskunall self-assigned this Feb 7, 2026
@yeskunall yeskunall changed the title Add syntax highlighting for HTML character references languages: Add syntax highlighting for HTML character references Feb 7, 2026
Copy link
Member

@yeskunall yeskunall left a comment

Choose a reason for hiding this comment

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

Did you test this with an HTML file? I get syntax highlighting for JSX/TSX files, but not HTML files. I tested with all the default themes Zed ships with, so the ones in your list should have worked. Maybe I’m missing something?

@br-schneider
Copy link
Contributor Author

br-schneider commented Feb 7, 2026

Yes, I tested with an HTML file and confirmed it works. Here's what I verified:

  1. The tree-sitter HTML grammar correctly parses entities like · as named entity nodes (confirmed via dev: open syntax tree view)
  2. The highlight query (entity) @string.special captures them and they render with the expected color

Since the TSX/JS changes are in built-in languages (crates/languages/) they take effect immediately when building from source, but the HTML change is in the extension (extensions/html/). Could the HTML extension's wasm/highlights need a clean rebuild to pick up the change? That might explain why it's not showing for you.

@br-schneider
Copy link
Contributor Author

br-schneider commented Feb 21, 2026

@yeskunall Just bumping this! Thank you again for reviewing!

@yeskunall yeskunall enabled auto-merge (squash) February 21, 2026 04:44
@yeskunall
Copy link
Member

yeskunall commented Feb 21, 2026

@br-schneider apologies -- this slipped through my notifications! Do you mind rebasing onto main to fix the CI failure?

# You probably have this already
git remote add upstream https://github.com/zed-industries/zed.git

git fetch upstream main
git rebase upstream/main
git push --force-with-lease

HTML character references (e.g., `·`, `'`, `&zed-industries#123;`) are parsed
by tree-sitter but not captured by any highlight query, so they render as
unhighlighted plain text.

This adds highlight captures for:
- `html_character_reference` in TSX and JavaScript (JSX context)
- `entity` in HTML

All three are captured as `@string.special`, which is already styled by
the built-in themes.
auto-merge was automatically disabled February 22, 2026 15:46

Head branch was pushed to by a user without write access

@br-schneider br-schneider force-pushed the highlight-html-entities branch from ee9856d to 0dded3a Compare February 22, 2026 15:46
@br-schneider
Copy link
Contributor Author

br-schneider commented Feb 22, 2026

No problem! Thanks for taking another look, done!

@yeskunall
Copy link
Member

Thank you @br-schneider and congratulations on your first contribution to Zed! 💖

@yeskunall yeskunall merged commit d54a262 into zed-industries:main Feb 23, 2026
27 checks passed
@yeskunall yeskunall removed their assignment Feb 23, 2026
Anthony-Eid pushed a commit to bobbymannino/zed that referenced this pull request Feb 25, 2026
…-industries#48629)

HTML character references like `·`, `'`, and `&zed-industries#123;` are
correctly parsed by tree-sitter as named nodes
(`html_character_reference` in TSX/JavaScript, `entity` in HTML), but no
highlight query captures them. This means they render as plain,
unhighlighted text in the editor.

This PR adds one-line highlight captures for each:

- **TSX** (`crates/languages/src/tsx/highlights.scm`):
`(html_character_reference) @string.special`
- **JavaScript** (`crates/languages/src/javascript/highlights.scm`):
`(html_character_reference) @string.special`
- **HTML** (`extensions/html/languages/html/highlights.scm`): `(entity)
@string.special`

`@string.special` is already styled by all built-in themes (One Dark,
Ayu, Gruvbox, etc.), so no theme changes are needed.

Release Notes:

- Added syntax highlighting for HTML character references (`·`,
`'`, `&zed-industries#123;`, etc.) in TSX, JavaScript, and HTML files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants