Skip to content
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

JS: Fixed variables named "async" #1738

Merged
merged 4 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
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.