Improvements in tag highlighting.
This commit is contained in:
parent
345b5f7626
commit
aaee55f115
1 changed files with 41 additions and 22 deletions
|
|
@ -35,9 +35,7 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var XQueryHighlightRules = function() {
|
var XQueryHighlightRules = function() {
|
||||||
|
|
||||||
var keywordMapper = this.createKeywordMapper({
|
var keywords = "after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position".split("|");
|
||||||
keyword: "after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position"
|
|
||||||
}, "identifier");
|
|
||||||
|
|
||||||
var nameStartChar = "[_A-Za-z]";
|
var nameStartChar = "[_A-Za-z]";
|
||||||
var nameChar = "[-\\._A-Za-z0-9]";
|
var nameChar = "[-\\._A-Za-z0-9]";
|
||||||
|
|
@ -71,8 +69,8 @@ var XQueryHighlightRules = function() {
|
||||||
next: "comment"
|
next: "comment"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
token: "text", // opening tag
|
token: ["text", "meta.tag"], // opening tag
|
||||||
regex: "<\\/?",
|
regex: "(<)(" + qname + ")",
|
||||||
next: "tag"
|
next: "tag"
|
||||||
}, {
|
}, {
|
||||||
token: "constant", // number
|
token: "constant", // number
|
||||||
|
|
@ -82,30 +80,21 @@ var XQueryHighlightRules = function() {
|
||||||
regex: "\\$" + eqname
|
regex: "\\$" + eqname
|
||||||
}, {
|
}, {
|
||||||
token: "string",
|
token: "string",
|
||||||
regex: '".*?"'
|
regex: "'",
|
||||||
}, {
|
|
||||||
token: "string",
|
|
||||||
regex: "'.*?'"
|
|
||||||
}, {
|
|
||||||
token: "string",
|
|
||||||
regex: "'.*?",
|
|
||||||
next: "apos-string"
|
next: "apos-string"
|
||||||
}, {
|
}, {
|
||||||
token: "string",
|
token: "string",
|
||||||
regex: '".*?',
|
regex: '"',
|
||||||
next: "quot-string"
|
next: "quot-string"
|
||||||
}, {
|
}, {
|
||||||
token: "text",
|
token: "text",
|
||||||
regex: "\\s+"
|
regex: "\\s+"
|
||||||
}, {
|
}, {
|
||||||
token: "support.function",
|
token: function(match) { if(keywords.indexOf(match) !== -1) { return "keyword" } else { return "support.function" } },
|
||||||
regex: "\\w[\\w+_\\-:]+(?=\\()"
|
regex: eqname
|
||||||
}, {
|
|
||||||
token: keywordMapper,
|
|
||||||
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
|
||||||
}, {
|
}, {
|
||||||
token: "keyword.operator",
|
token: "keyword.operator",
|
||||||
regex: "\\*|=|<|>|\\-|\\+"
|
regex: "\\*|:=|=|<|>|\\-|\\+"
|
||||||
}, {
|
}, {
|
||||||
token: "lparen",
|
token: "lparen",
|
||||||
regex: "[[({]"
|
regex: "[[({]"
|
||||||
|
|
@ -116,20 +105,32 @@ var XQueryHighlightRules = function() {
|
||||||
|
|
||||||
tag: [{
|
tag: [{
|
||||||
token: "text",
|
token: "text",
|
||||||
regex: ">",
|
regex: "\\/?>",
|
||||||
next: "start"
|
next: "start"
|
||||||
|
}, {
|
||||||
|
token: ["text", "meta.tag"],
|
||||||
|
regex: "(<\\/)(" + qname + ")",
|
||||||
|
next: "start"
|
||||||
}, {
|
}, {
|
||||||
token: "meta.tag",
|
token: "meta.tag",
|
||||||
regex: "[-_a-zA-Z0-9:]+"
|
regex: qname
|
||||||
}, {
|
}, {
|
||||||
token: "text",
|
token: "text",
|
||||||
regex: "\\s+"
|
regex: "\\s+"
|
||||||
}, {
|
}, {
|
||||||
token: "string",
|
token: "string",
|
||||||
regex: '".*?"'
|
regex: "'",
|
||||||
|
next: "apos-attr"
|
||||||
|
}, {
|
||||||
|
token: "string",
|
||||||
|
regex: '"',
|
||||||
|
next: "quot-attr"
|
||||||
}, {
|
}, {
|
||||||
token: "string",
|
token: "string",
|
||||||
regex: "'.*?'"
|
regex: "'.*?'"
|
||||||
|
}, {
|
||||||
|
token: "text",
|
||||||
|
regex: "="
|
||||||
}],
|
}],
|
||||||
|
|
||||||
pi: [{
|
pi: [{
|
||||||
|
|
@ -214,6 +215,24 @@ var XQueryHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
token: "string",
|
token: "string",
|
||||||
regex: ".*"
|
regex: ".*"
|
||||||
|
}],
|
||||||
|
|
||||||
|
"apos-attr": [{
|
||||||
|
token: "string",
|
||||||
|
regex: ".*?'",
|
||||||
|
next: "tag"
|
||||||
|
}, {
|
||||||
|
token: "string",
|
||||||
|
regex: ".*"
|
||||||
|
}],
|
||||||
|
|
||||||
|
"quot-attr": [{
|
||||||
|
token: "string",
|
||||||
|
regex: '.*?"',
|
||||||
|
next: "tag"
|
||||||
|
}, {
|
||||||
|
token: "string",
|
||||||
|
regex: ".*"
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue