cleanup xml highlight rules
This commit is contained in:
parent
bce93cf031
commit
70cd01d858
1 changed files with 22 additions and 52 deletions
|
|
@ -36,61 +36,31 @@ var xmlUtil = require("./xml_util");
|
|||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var XmlHighlightRules = function() {
|
||||
|
||||
// regexp must not have capturing parentheses
|
||||
// regexps are ordered -> the first match is used
|
||||
this.$rules = {
|
||||
start : [{
|
||||
token : "text",
|
||||
regex : "<\\!\\[CDATA\\[",
|
||||
next : "cdata"
|
||||
}, {
|
||||
token : "xml-pe",
|
||||
regex : "<\\?.*?\\?>"
|
||||
}, {
|
||||
token : "comment",
|
||||
merge : true,
|
||||
regex : "<\\!--",
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "xml-pe",
|
||||
regex : "<\\!.*?>"
|
||||
}, {
|
||||
token : "meta.tag", // opening tag
|
||||
regex : "<\\/?",
|
||||
next : "tag"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
token : "constant.character.entity",
|
||||
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "[^<]+"
|
||||
}],
|
||||
start : [
|
||||
{token : "text", regex : "<\\!\\[CDATA\\[", next : "cdata"},
|
||||
{token : "xml-pe", regex : "<\\?.*?\\?>"},
|
||||
{token : "comment", regex : "<\\!--", next : "comment", merge : true},
|
||||
{token : "xml-pe", regex : "<\\!.*?>"},
|
||||
{token : "meta.tag", regex : "<\\/?", next : "tag"},
|
||||
{token : "text", regex : "\\s+"},
|
||||
{
|
||||
token : "constant.character.entity",
|
||||
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
|
||||
},
|
||||
{token : "text", regex : "[^<]+"}
|
||||
],
|
||||
|
||||
cdata : [{
|
||||
token : "text",
|
||||
regex : "\\]\\]>",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "(?:[^\\]]|\\](?!\\]>))+"
|
||||
}],
|
||||
cdata : [
|
||||
{token : "text", regex : "\\]\\]>", next : "start"},
|
||||
{token : "text", regex : "\\s+"},
|
||||
{token : "text", regex : "(?:[^\\]]|\\](?!\\]>))+"}
|
||||
],
|
||||
|
||||
comment : [{
|
||||
token : "comment",
|
||||
regex : ".*?-->",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "comment",
|
||||
merge : true,
|
||||
regex : ".+"
|
||||
}]
|
||||
comment : [
|
||||
{token : "comment", regex : ".*?-->", next : "start"},
|
||||
{token : "comment", merge : true, regex : ".+"}
|
||||
]
|
||||
};
|
||||
|
||||
xmlUtil.tag(this.$rules, "tag", "start");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue