Skip to content

Unicode support for XML and HTML tags name #196

Description

@afu-dev

Tempest version

3.0

PHP version

8.5

Operating system

macOS

Description

Currently, for XML and HTML, we are capturing at best \w which translate into [a-zA-Z0-9_]. But tag names can contains almost any unicode characters after the first char (this one must be [a-zA-Z] for HTML, a bit more permissive for XML).

Here's the specs I've found for each language:

The HTML spec even gave us a valid ReGex: /^(?:[A-Za-z][^\0\t\n\f\r\u0020/>]*|[:_\u0080-\u{10FFFF}][A-Za-z0-9-.:_\u0080-\u{10FFFF}]*)$/u

So the following are valid in HTML:

<math-α></math-α>
<emotion-😍-emoji></emotion-😍-emoji>

(And I guess even GitHub doesn't render then correctly 🥲)

Here's how Gecko (Firefox) is rendering the above HTML:

Image

Activity

  1. added theissue type on Feb 13, 2026
  2. Akiyo974 commented on Oct 20, 2026

    @Akiyo974

    Hi @afu-dev , I opened #237 to fix this.

    Tag name patterns for both HTML and XML now accept non-ASCII characters, so <math-α>, <emotion-😍-emoji> and <données> are highlighted as a whole.

    • HTML: the first character still has to be an ASCII letter, as the spec requires (<αtag> is not highlighted).
    • XML: non-ASCII characters are also allowed as the first character, following NameStartChar.

    I kept the patterns byte-based (non-ASCII bytes \x80-\xFF) rather than adding the /u modifier, so input with invalid UTF-8 still gets highlighted instead of failing silently.

    Unicode in attribute names isn't covered yet. I can open a follow-up PR if that's wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions