add es6 template string highlighting to javascript mode
This commit is contained in:
parent
9f2fba320d
commit
30f7f8a3f2
2 changed files with 37 additions and 0 deletions
|
|
@ -117,6 +117,7 @@ function BracketMatch() {
|
|||
typeRe = new RegExp(
|
||||
"(\\.?" +
|
||||
token.type.replace(".", "\\.").replace("rparen", ".paren")
|
||||
.replace(/\b(?:end|start|begin)\b/, "")
|
||||
+ ")+"
|
||||
);
|
||||
}
|
||||
|
|
@ -173,6 +174,7 @@ function BracketMatch() {
|
|||
typeRe = new RegExp(
|
||||
"(\\.?" +
|
||||
token.type.replace(".", "\\.").replace("lparen", ".paren")
|
||||
.replace(/\b(?:end|start|begin)\b/, "")
|
||||
+ ")+"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,6 +193,39 @@ var JavaScriptHighlightRules = function() {
|
|||
token : "punctuation.operator",
|
||||
regex : /\?|\:|\,|\;|\./,
|
||||
next : "start"
|
||||
}, {
|
||||
regex: "[{}]", onMatch: function(val, state, stack) {
|
||||
console.log(val, state, stack)
|
||||
this.next = "";
|
||||
if (val == "{" && stack.length) {
|
||||
stack.unshift("start", state);
|
||||
return "paren";
|
||||
}
|
||||
if (val == "}" && stack.length) {
|
||||
stack.shift();
|
||||
this.next = stack.shift();
|
||||
if (this.next.indexOf("string") != -1)
|
||||
return "paren.quasi.end";
|
||||
}
|
||||
return "paren";
|
||||
}
|
||||
}, {
|
||||
token : "string.quasi.start",
|
||||
regex : /`/,
|
||||
push : [{
|
||||
token : "constant.language.escape",
|
||||
regex : escapedRe
|
||||
}, {
|
||||
token : "paren.quasi.start",
|
||||
regex : /\${/,
|
||||
push : "start"
|
||||
}, {
|
||||
token : "string.quasi.end",
|
||||
regex : /`/,
|
||||
next : "pop"
|
||||
}, {
|
||||
defaultToken: "string.quasi"
|
||||
}]
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : /[\[({]/,
|
||||
|
|
@ -357,6 +390,8 @@ var JavaScriptHighlightRules = function() {
|
|||
|
||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue