fix js regex highlighting
adds coloring for escaped entities \s and fixes highlighting regexps like /[]/g
This commit is contained in:
parent
8a6bfe2d24
commit
5b08bf8e1e
1 changed files with 51 additions and 4 deletions
|
|
@ -205,10 +205,9 @@ var JavaScriptHighlightRules = function() {
|
||||||
regex : "\\/\\/.*$"
|
regex : "\\/\\/.*$"
|
||||||
}, {
|
}, {
|
||||||
token: "string.regexp",
|
token: "string.regexp",
|
||||||
regex: "\\/(?:(?:\\[(?:\\\\]|[^\\]])+\\])"
|
regex: "\\/",
|
||||||
+ "|(?:\\\\/|[^\\]/]))*"
|
next: "regex",
|
||||||
+ "[/]\\w*",
|
merge: true
|
||||||
next: "start"
|
|
||||||
}, {
|
}, {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : "\\s+"
|
regex : "\\s+"
|
||||||
|
|
@ -220,6 +219,54 @@ var JavaScriptHighlightRules = function() {
|
||||||
next: "start"
|
next: "start"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"regex": [
|
||||||
|
{
|
||||||
|
token: "regexp.keyword.operator",
|
||||||
|
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
|
||||||
|
next: "regex"
|
||||||
|
}, {
|
||||||
|
// flag
|
||||||
|
token: "string.regexp",
|
||||||
|
regex: "/\\w*",
|
||||||
|
next: "start",
|
||||||
|
merge: true
|
||||||
|
}, {
|
||||||
|
token: "string.regexp",
|
||||||
|
regex: "[^\\\\/\\[]+",
|
||||||
|
next: "regex",
|
||||||
|
merge: true
|
||||||
|
}, {
|
||||||
|
token: "string.regexp.charachterclass",
|
||||||
|
regex: "\\[",
|
||||||
|
next: "regex_character_class",
|
||||||
|
merge: true
|
||||||
|
}, {
|
||||||
|
token: "empty",
|
||||||
|
regex: "",
|
||||||
|
next: "start"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"regex_character_class": [
|
||||||
|
{
|
||||||
|
token: "regexp.keyword.operator",
|
||||||
|
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
|
||||||
|
next: "regex_character_class"
|
||||||
|
}, {
|
||||||
|
token: "string.regexp.charachterclass",
|
||||||
|
regex: "]",
|
||||||
|
next: "regex",
|
||||||
|
merge: true
|
||||||
|
}, {
|
||||||
|
token: "string.regexp.charachterclass",
|
||||||
|
regex: "[^\\\\\\]]+",
|
||||||
|
next: "regex_character_class",
|
||||||
|
merge: true
|
||||||
|
}, {
|
||||||
|
token: "empty",
|
||||||
|
regex: "",
|
||||||
|
next: "start"
|
||||||
|
}
|
||||||
|
],
|
||||||
"comment_regex_allowed" : [
|
"comment_regex_allowed" : [
|
||||||
{
|
{
|
||||||
token : "comment", // closing comment
|
token : "comment", // closing comment
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue