[xml] ensure tag name starts with letter

This commit is contained in:
Kevin Ushey 2015-01-28 10:53:42 -08:00
commit 3fe1383cdc

View file

@ -35,6 +35,9 @@ var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var XmlHighlightRules = function(normalize) {
var tagRegex = "[a-zA-Z][-_a-zA-Z0-9]*";
this.$rules = {
start : [
{token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
@ -44,7 +47,7 @@ var XmlHighlightRules = function(normalize) {
},
{
token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "processing_instruction",
regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction",
},
{token : "comment.xml", regex : "<\\!--", next : "comment"},
{
@ -60,7 +63,7 @@ var XmlHighlightRules = function(normalize) {
xml_decl : [{
token : "entity.other.attribute-name.decl-attribute-name.xml",
regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
}, {
token : "keyword.operator.decl-attribute-equals.xml",
regex : "="
@ -96,7 +99,7 @@ var XmlHighlightRules = function(normalize) {
next: "pop"
}, {
token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
regex : "(<\\!)([-_a-zA-Z0-9]+)",
regex : "(<\\!)(" + tagRegex + ")",
push : [{
token : "text",
regex : "\\s+"
@ -132,7 +135,7 @@ var XmlHighlightRules = function(normalize) {
tag : [{
token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
regex : "(?:(<)|(</))((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
next: [
{include : "attributes"},
{token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
@ -166,7 +169,7 @@ var XmlHighlightRules = function(normalize) {
attributes: [{
token : "entity.other.attribute-name.xml",
regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
}, {
token : "keyword.operator.attribute-equals.xml",
regex : "="