Skip to content

Conversation

@ninjamuffin99
Copy link
Contributor

@ninjamuffin99 ninjamuffin99 commented Feb 19, 2024

Changes the regex in the haxe.js highlighting to only highlight new as a keyword if it's not used within a variable/class name, using beginKeywords: 'new' instead of new *

Resolves #3992

Changes

Chnages the regex to use beginKeywords: 'new' instead of *, so that it can capture new as a keyword, but not when it's used within a variable name

Checklist

  • Added markup tests
  • Updated the changelog at CHANGES.md

@ninjamuffin99
Copy link
Contributor Author

ninjamuffin99 commented Feb 19, 2024

I will look into the markup tests sometime soon / hopefully later today.

I am regex noob but I believe this should work okay!

@ninjamuffin99 ninjamuffin99 changed the title use word boundary \b for new keyword in haxe use beginKeywords for new keyword in haxe Feb 20, 2024
@ninjamuffin99
Copy link
Contributor Author

added markup tests, and changed to use beginKeywords: new

@github-actions
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

12 files changed

Total change -58 B

View Changes
file base pr diff
es/core.min.js 8.17 KB 8.17 KB +1 B
es/highlight.min.js 8.17 KB 8.17 KB +1 B
es/languages/css.min.js 3.81 KB 3.8 KB -8 B
es/languages/haxe.min.js 987 B 989 B +2 B
es/languages/less.min.js 4.21 KB 4.21 KB -8 B
es/languages/scss.min.js 4.25 KB 4.24 KB -8 B
es/languages/stylus.min.js 3.91 KB 3.9 KB -8 B
languages/css.min.js 3.81 KB 3.8 KB -8 B
languages/haxe.min.js 995 B 997 B +2 B
languages/less.min.js 4.22 KB 4.21 KB -8 B
languages/scss.min.js 4.26 KB 4.25 KB -8 B
languages/stylus.min.js 3.92 KB 3.91 KB -8 B

@github-actions
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

3 files changed

Total change +2 B

View Changes
file base pr diff
es/languages/haxe.min.js 987 B 989 B +2 B
highlight.min.js 8.23 KB 8.23 KB -2 B
languages/haxe.min.js 995 B 997 B +2 B

@joshgoebel joshgoebel changed the title use beginKeywords for new keyword in haxe fix(haxe) fix new keyword false positives Mar 21, 2024
@joshgoebel joshgoebel merged commit 5fe035c into highlightjs:main Mar 21, 2024
joshtynjala added a commit to joshtynjala/highlight.js that referenced this pull request Aug 29, 2025
PR highlightjs#3993 fixed incorrect highlighting of variable names starting with new, but at the same time, it removed highlighting of type names that follow the new keyword. This commits restores the lost highlighting for type names after the new keyword, while still ensuring that new at the start of a variable name is not highlighted as a keyword.
joshtynjala added a commit to joshtynjala/highlight.js that referenced this pull request Aug 29, 2025
PR highlightjs#3993 fixed incorrect highlighting of variable names starting with new (like newValue), but at the same time, it removed highlighting of type names that follow the new keyword. This commit restores the lost highlighting for type names after the new keyword, while still ensuring that new at the start of a variable name is not highlighted as a keyword.
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.

(Haxe) using new at the start of a variable name highlights it separately from the rest of the variable name

2 participants