fix js regex highlighting

adds coloring for escaped entities \s
  and fixes highlighting regexps like /[]/g
This commit is contained in:
nightwing 2011-12-04 20:33:54 +04:00
commit 5b08bf8e1e

View file

@ -205,10 +205,9 @@ var JavaScriptHighlightRules = function() {
regex : "\\/\\/.*$"
}, {
token: "string.regexp",
regex: "\\/(?:(?:\\[(?:\\\\]|[^\\]])+\\])"
+ "|(?:\\\\/|[^\\]/]))*"
+ "[/]\\w*",
next: "start"
regex: "\\/",
next: "regex",
merge: true
}, {
token : "text",
regex : "\\s+"
@ -220,6 +219,54 @@ var JavaScriptHighlightRules = function() {
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" : [
{
token : "comment", // closing comment