Skip to content

Commit

Permalink
JS: Fixed variables named "async" (#1738)
Browse files Browse the repository at this point in the history
Fixes variables names "async" in JS.
  • Loading branch information
RunDevelopment authored Feb 28, 2019
1 parent c3862a2 commit 3560c64
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/prism-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', {
pattern: /((?:^|})\s*)(?:catch|finally)\b/,
lookbehind: true
},
/\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
/\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
],
'number': /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
Expand Down
2 changes: 1 addition & 1 deletion components/prism-javascript.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', {
pattern: /((?:^|})\s*)(?:catch|finally)\b/,
lookbehind: true
},
/\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
/\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
],
'number': /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
Expand Down
10 changes: 6 additions & 4 deletions tests/languages/javascript/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
catch finally;
async function;

as; async; await; break; case;
as; await; break; case;
class; const; continue; debugger;
default; delete; do; else; enum;
export; extends; for;
from; function; get; if; implements;
from; get; if; implements;
import; in; instanceof; interface; let;
new; null; of; package; private;
protected; public; return; set; static;
Expand All @@ -18,8 +19,10 @@ with; yield;
["keyword", "catch"],
["keyword", "finally"], ["punctuation", ";"],

["keyword", "async"],
["keyword", "function"], ["punctuation", ";"],

["keyword", "as"], ["punctuation", ";"],
["keyword", "async"], ["punctuation", ";"],
["keyword", "await"], ["punctuation", ";"],
["keyword", "break"], ["punctuation", ";"],
["keyword", "case"], ["punctuation", ";"],
Expand All @@ -36,7 +39,6 @@ with; yield;
["keyword", "extends"], ["punctuation", ";"],
["keyword", "for"], ["punctuation", ";"],
["keyword", "from"], ["punctuation", ";"],
["keyword", "function"], ["punctuation", ";"],
["keyword", "get"], ["punctuation", ";"],
["keyword", "if"], ["punctuation", ";"],
["keyword", "implements"], ["punctuation", ";"],
Expand Down
15 changes: 15 additions & 0 deletions tests/languages/javascript/variable_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let async = true;

----------------------------------------------------

[
["keyword", "let"],
" async ",
["operator", "="],
["boolean", "true"],
["punctuation", ";"]
]

----------------------------------------------------

Checks for variables with special names.

0 comments on commit 3560c64

Please sign in to comment.