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 TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var XmlHighlightRules = function() {
|
var XmlHighlightRules = function() {
|
||||||
|
|
||||||
// regexp must not have capturing parentheses
|
|
||||||
// regexps are ordered -> the first match is used
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
start : [{
|
start : [
|
||||||
token : "text",
|
{token : "text", regex : "<\\!\\[CDATA\\[", next : "cdata"},
|
||||||
regex : "<\\!\\[CDATA\\[",
|
{token : "xml-pe", regex : "<\\?.*?\\?>"},
|
||||||
next : "cdata"
|
{token : "comment", regex : "<\\!--", next : "comment", merge : true},
|
||||||
}, {
|
{token : "xml-pe", regex : "<\\!.*?>"},
|
||||||
token : "xml-pe",
|
{token : "meta.tag", regex : "<\\/?", next : "tag"},
|
||||||
regex : "<\\?.*?\\?>"
|
{token : "text", regex : "\\s+"},
|
||||||
}, {
|
{
|
||||||
token : "comment",
|
token : "constant.character.entity",
|
||||||
merge : true,
|
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
|
||||||
regex : "<\\!--",
|
},
|
||||||
next : "comment"
|
{token : "text", regex : "[^<]+"}
|
||||||
}, {
|
],
|
||||||
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 : "[^<]+"
|
|
||||||
}],
|
|
||||||
|
|
||||||
cdata : [{
|
cdata : [
|
||||||
token : "text",
|
{token : "text", regex : "\\]\\]>", next : "start"},
|
||||||
regex : "\\]\\]>",
|
{token : "text", regex : "\\s+"},
|
||||||
next : "start"
|
{token : "text", regex : "(?:[^\\]]|\\](?!\\]>))+"}
|
||||||
}, {
|
],
|
||||||
token : "text",
|
|
||||||
regex : "\\s+"
|
|
||||||
}, {
|
|
||||||
token : "text",
|
|
||||||
regex : "(?:[^\\]]|\\](?!\\]>))+"
|
|
||||||
}],
|
|
||||||
|
|
||||||
comment : [{
|
comment : [
|
||||||
token : "comment",
|
{token : "comment", regex : ".*?-->", next : "start"},
|
||||||
regex : ".*?-->",
|
{token : "comment", merge : true, regex : ".+"}
|
||||||
next : "start"
|
]
|
||||||
}, {
|
|
||||||
token : "comment",
|
|
||||||
merge : true,
|
|
||||||
regex : ".+"
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
xmlUtil.tag(this.$rules, "tag", "start");
|
xmlUtil.tag(this.$rules, "tag", "start");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue