Skip to content

fix(javascript) correctly highlight 'for await' again #4240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ New Grammars:

Core Grammars:

- fix(javascript) correctly highlight 'for await' again [wolfgang42][]
- enh(csp) add missing directives / keywords from MDN (7 more) [Max Liashuk][]
- enh(ada) add new `parallel` keyword, allow `[]` for Ada 2022 [Max Reznik][]

3 changes: 2 additions & 1 deletion src/languages/javascript.js
Original file line number Diff line number Diff line change
@@ -387,7 +387,8 @@ export default function(hljs) {
noneOf([
...ECMAScript.BUILT_IN_GLOBALS,
"super",
"import"
"import",
"await",
].map(x => `${x}\\s*\\(`)),
IDENT_RE, regex.lookahead(/\s*\(/)),
className: "title.function",
3 changes: 3 additions & 0 deletions test/markup/javascript/keywords.expect.txt
Original file line number Diff line number Diff line change
@@ -11,4 +11,7 @@
<span class="hljs-keyword">return</span> <span class="hljs-regexp">/\d+[\s/]/g</span>;
}
<span class="hljs-keyword">using</span> val = <span class="hljs-title function_">condition</span>();
<span class="hljs-keyword">for</span> <span class="hljs-keyword">await</span> (<span class="hljs-keyword">const</span> item <span class="hljs-keyword">of</span> items) {
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(item);
}
}
3 changes: 3 additions & 0 deletions test/markup/javascript/keywords.txt
Original file line number Diff line number Diff line change
@@ -11,4 +11,7 @@ function $initHighlight(block, cls) {
return /\d+[\s/]/g;
}
using val = condition();
for await (const item of items) {
console.log(item);
}
}