Skip to content

Commit 640b9d9

Browse files
cyfung1031aral
authored andcommitted
fix(javascript) incorrect function name highlighting (highlightjs#3940)
* fix(javascript) incorrect function name highlighting
1 parent b8eb3ae commit 640b9d9

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

CHANGES.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
## Version 11.10.0 (Next Release)
2+
3+
Core Grammars:
4+
5+
- fix(cpp) not all kinds of number literals are highlighted correctly [Lê Duy Quang][]
6+
- fix(css) fix overly greedy pseudo class matching [Bradley Mackey][]
7+
- enh(arcade) updated to ArcGIS Arcade version 1.24 [Kristian Ekenes][]
8+
- fix(typescript): params types [Mohamed Ali][]
9+
- fix(rust) fix escaped double quotes in string [Mohamed Ali][]
10+
- fix(yaml) fix for yaml with keys having brackets highlighted incorrectly [Aneesh Kulkarni][]
11+
- fix(bash) fix # within token being detected as the start of a comment [Felix Uhl][]
12+
- fix(python) fix `or` conflicts with string highlighting [Mohamed Ali][]
13+
- enh(delphi) allow digits to be omitted for hex and binary literals [Jonah Jeleniewski][]
14+
- enh(delphi) add support for digit separators [Jonah Jeleniewski][]
15+
- enh(delphi) add support for character strings with non-decimal numerics [Jonah Jeleniewski][]
16+
- fix(javascript) incorrect function name highlighting [CY Fung][]
17+
- fix(1c) fix escaped symbols "+-;():=,[]" literals [Vitaly Barilko][]
18+
19+
New Grammars:
20+
21+
- added 3rd party CODEOWNERS grammar to SUPPORTED_LANGUAGES [nataliia-radina][]
22+
- added 3rd party Luau grammar to SUPPORTED_LANGUAGES [Robloxian Demo][]
23+
- added 3rd party ReScript grammar to SUPPORTED_LANGUAGES [Paul Tsnobiladzé][]
24+
25+
Developer Tool:
26+
27+
- enh(tools): order CSS options picklist [David Schach][]
28+
- enh(tools): remove duplicate CSS options [David Schach][]
29+
30+
Themes:
31+
32+
- Added `1c-light` theme a like in the IDE 1C:Enterprise 8 (for 1c) [Vitaly Barilko][]
33+
34+
[Lê Duy Quang]: https://github.com/leduyquang753
35+
[Mohamed Ali]: https://github.com/MohamedAli00949
36+
[Bradley Mackey]: https://github.com/bradleymackey
37+
[Kristian Ekenes]: https://github.com/ekenes
38+
[Aneesh Kulkarni]: https://github.com/aneesh98
39+
[Bruno Meneguele]: https://github.com/bmeneg
40+
[Felix Uhl]: https://github.com/iFreilicht
41+
[nataliia-radina]: https://github.com/Nataliia-Radina
42+
[Robloxian Demo]: https://github.com/RobloxianDemo
43+
[Paul Tsnobiladzé]: https://github.com/tsnobip
44+
[Jonah Jeleniewski]: https://github.com/cirras
45+
[CY Fung]: https://github.com/cyfung1031
46+
[Vitaly Barilko]: https://github.com/Diversus23
47+
48+
149
## Version 11.9.0
250

351
CAVEATS / POTENTIALLY BREAKING CHANGES

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"syntax"
77
],
88
"homepage": "https://highlightjs.org/",
9-
"version": "11.9.0",
9+
"version": "11.10.0",
1010
"author": "Josh Goebel <[email protected]>",
1111
"contributors": [
1212
"Josh Goebel <[email protected]>",

src/languages/javascript.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ export default function(hljs) {
387387
...ECMAScript.BUILT_IN_GLOBALS,
388388
"super",
389389
"import"
390-
]),
391-
IDENT_RE, regex.lookahead(/\(/)),
390+
].map(x => `${x}\\s*\\(`)),
391+
IDENT_RE, regex.lookahead(/\s*\(/)),
392392
className: "title.function",
393393
relevance: 0
394394
};

test/markup/javascript/class.expect.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,29 @@
3838
<span class="hljs-title class_">InT</span>
3939
<span class="hljs-title class_">CSSParserT</span>
4040
<span class="hljs-title class_">IResponseTsS</span>
41+
42+
<span class="hljs-comment">// this class to show that the params may be seperated with space after the function name and highlighted as params also.</span>
43+
<span class="hljs-keyword">class</span> <span class="hljs-title class_">Car</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_ inherited__">Vehicle</span> {
44+
<span class="hljs-title function_">constructor</span> (<span class="hljs-params">speed, cost</span>) {
45+
<span class="hljs-variable language_">super</span>(speed);
46+
47+
<span class="hljs-keyword">var</span> c = <span class="hljs-title class_">Symbol</span>(<span class="hljs-string">&#x27;cost&#x27;</span>);
48+
<span class="hljs-variable language_">this</span>[c] = cost;
49+
50+
<span class="hljs-variable language_">this</span>.<span class="hljs-property">intro</span> = <span class="hljs-string">`This is a car runs at
51+
<span class="hljs-subst">${speed}</span>.`</span>;
52+
}
53+
54+
<span class="hljs-title function_">join</span> () {
55+
}
56+
57+
<span class="hljs-title function_">other</span> (a = ( ( <span class="hljs-number">3</span> + <span class="hljs-number">2</span> ) ) ) {
58+
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(a)
59+
}
60+
61+
<span class="hljs-title function_">something</span> (a = ( ( <span class="hljs-number">3</span> + <span class="hljs-number">2</span> ) ), b = <span class="hljs-number">1</span> ) {
62+
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(a)
63+
}
64+
65+
<span class="hljs-title function_">onemore</span> (a=(<span class="hljs-number">3</span>+<span class="hljs-number">2</span>, b=(<span class="hljs-number">5</span>*<span class="hljs-number">9</span>))) {}
66+
}

0 commit comments

Comments
 (0)