Skip to content

fix(css, less, scss, stylus) do not highlight digits in preserve-3d - #4545

Open
dyk1454683243-sudo wants to merge 2 commits into
highlightjs:mainfrom
dyk1454683243-sudo:cursor/fix-css-preserve-3d-number-4531-23ec
Open

dyk1454683243-sudo wants to merge 2 commits into
highlightjs:mainfrom
dyk1454683243-sudo:cursor/fix-css-preserve-3d-number-4531-23ec

Conversation

@dyk1454683243-sudo

@dyk1454683243-sudo dyk1454683243-sudo commented Sep 20, 2026

Copy link
Copy Markdown

Fixes #4531

Changes

transform-style: preserve-3d highlighted the 3 as hljs-number because shared CSS_NUMBER_MODE is built on NUMBER_RE (\b\d+…), and \b matches between - and a digit.

on:begin now ignores a number whose digit starts after an identifier-continuing hyphen (preserve-3d, *-2d, …). Ordinary lengths (3px, 0.5rem, 100%) and negative lengths (-3px) still highlight as numbers. No per-keyword *-3d list.

Lookbehind would express the same rule, but language grammars are linted as ES2015, so the callback is the 11.x-safe version.

Stylus does not apply UNICODE_RANGE on property values, so U+0025-00FF used to paint 00 after the hyphen as a number. That expect is updated for the same boundary.

Markup coverage is a dedicated preserve-3d CSS case plus the same snippet on the shared css/less/scss/stylus consistency fixtures.

Checklist

Assisted-by: Grok 4.6 (high)

dyk1454683243-sudo and others added 2 commits September 20, 2026 03:15
CSS_NUMBER_MODE used NUMBER_RE's word boundary, so the `3` in
identifier-internal values like `preserve-3d` was scoped as a number.
Require that a number not start after an identifier-continuing
`-<digit>`. Ordinary lengths (`3px`, `0.5rem`) and negative lengths
(`-3px`) are unchanged.

Fixes highlightjs#4531

Assisted-by: Grok 4.6 (high)

Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
Language grammars are linted as ES2015, so lookbehind is rejected.
Ignore number matches whose digit starts after an identifier-continuing
hyphen. Stylus unicode-range no longer paints the digits after the
hyphen in U+0025-00FF, which is the same boundary.

Assisted-by: Grok 4.6 (high)

Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
@dyk1454683243-sudo
dyk1454683243-sudo marked this pull request as ready for review September 20, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(CSS) preserve-3d gets highlighted incorrectly

1 participant