update html highlight rules
This commit is contained in:
parent
bca423f826
commit
857857611c
1 changed files with 34 additions and 37 deletions
|
|
@ -46,7 +46,6 @@ var HtmlHighlightRules = function() {
|
|||
|
||||
// regexp must not have capturing parentheses
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
function string(state) {
|
||||
return [
|
||||
{
|
||||
|
|
@ -80,6 +79,36 @@ var HtmlHighlightRules = function() {
|
|||
regex : '.+'
|
||||
}]
|
||||
}
|
||||
|
||||
function tag(states, name, nextState) {
|
||||
states[name] = [{
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "[-_a-zA-Z0-9:]+",
|
||||
next : name + "-attribute-list"
|
||||
}, {
|
||||
token: "empty",
|
||||
regex: "",
|
||||
next : name + "-attribute-list"
|
||||
}];
|
||||
|
||||
states[name + "-attribute-list"] = [{
|
||||
token : "text",
|
||||
regex : ">",
|
||||
next : nextState
|
||||
}, {
|
||||
token : "entity.other.attribute-name",
|
||||
regex : "[-_a-zA-Z0-9:]+"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}].concat(string("attribute-list"));
|
||||
};
|
||||
|
||||
this.$rules = {
|
||||
start : [ {
|
||||
|
|
@ -115,42 +144,6 @@ var HtmlHighlightRules = function() {
|
|||
regex : "[^<]+"
|
||||
} ],
|
||||
|
||||
script : [ {
|
||||
token : "text",
|
||||
regex : ">",
|
||||
next : "js-start"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : "[-_a-zA-Z0-9:]+"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}].concat(string("script")),
|
||||
|
||||
css : [ {
|
||||
token : "text",
|
||||
regex : ">",
|
||||
next : "css-start"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : "[-_a-zA-Z0-9:]+"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}].concat(string("style")),
|
||||
|
||||
tag : [ {
|
||||
token : "text",
|
||||
regex : ">",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : "[-_a-zA-Z0-9:]+"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}].concat(string("tag")),
|
||||
|
||||
"style-qstring": multiLineString("'", "style"),
|
||||
"style-qqstring": multiLineString('"', "style"),
|
||||
"script-qstring": multiLineString("'", "script"),
|
||||
|
|
@ -183,6 +176,10 @@ var HtmlHighlightRules = function() {
|
|||
} ]
|
||||
};
|
||||
|
||||
tag(this.$rules, "tag", "start");
|
||||
tag(this.$rules, "css", "css-start");
|
||||
tag(this.$rules, "script", "js-start");
|
||||
|
||||
this.embedRules(JavaScriptHighlightRules, "js-", [{
|
||||
token: "comment",
|
||||
regex: "\\/\\/.*(?=<\\/script>)",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue