xml highlighter fix #521
This commit is contained in:
parent
0b633711a0
commit
e0aaedaa0d
3 changed files with 28 additions and 8 deletions
|
|
@ -86,7 +86,7 @@ var XmlHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
token : "string", // multi line string start
|
token : "string", // multi line string start
|
||||||
merge : true,
|
merge : true,
|
||||||
regex : '["].*$',
|
regex : '["].*',
|
||||||
next : "qqstring"
|
next : "qqstring"
|
||||||
}, {
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
|
|
@ -94,13 +94,13 @@ var XmlHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
token : "string", // multi line string start
|
token : "string", // multi line string start
|
||||||
merge : true,
|
merge : true,
|
||||||
regex : "['].*$",
|
regex : "['].*",
|
||||||
next : "qstring"
|
next : "qstring"
|
||||||
}],
|
}],
|
||||||
|
|
||||||
qstring: [{
|
qstring: [{
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : ".*'",
|
regex : ".*?'",
|
||||||
next : "tag"
|
next : "tag"
|
||||||
}, {
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
|
|
@ -110,7 +110,7 @@ var XmlHighlightRules = function() {
|
||||||
|
|
||||||
qqstring: [{
|
qqstring: [{
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : ".*\"",
|
regex : ".*?\"",
|
||||||
next : "tag"
|
next : "tag"
|
||||||
}, {
|
}, {
|
||||||
token : "string",
|
token : "string",
|
||||||
|
|
|
||||||
|
|
@ -62,11 +62,31 @@ module.exports = {
|
||||||
assert.equal("text", tokens[2].type);
|
assert.equal("text", tokens[2].type);
|
||||||
assert.equal("keyword", tokens[3].type);
|
assert.equal("keyword", tokens[3].type);
|
||||||
assert.equal("text", tokens[4].type);
|
assert.equal("text", tokens[4].type);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test: multiline attributes": function() {
|
||||||
|
var multiLine = ['<copy set="{', '}" undo="{', '}"/>'];
|
||||||
|
|
||||||
|
var state = "start";
|
||||||
|
var multiLineTokens = multiLine.map(function(line) {
|
||||||
|
var tokens = this.tokenizer.getLineTokens(line, state);
|
||||||
|
state = tokens.state;
|
||||||
|
return tokens.tokens;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
assert.equal(multiLineTokens[0].length, 6);
|
||||||
|
assert.equal(multiLineTokens[1].length, 5);
|
||||||
|
assert.equal(multiLineTokens[2].length, 2);
|
||||||
|
|
||||||
|
assert.equal(multiLineTokens[0][5].type, "string");
|
||||||
|
assert.equal(multiLineTokens[1][0].type, "string");
|
||||||
|
assert.equal(multiLineTokens[1][4].type, "string");
|
||||||
|
assert.equal(multiLineTokens[2][0].type, "string");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof module !== "undefined" && module === require.main) {
|
if (typeof module !== "undefined" && module === require.main) {
|
||||||
require("asyncjs").test.testcase(module.exports).exec()
|
require("asyncjs").test.testcase(module.exports).exec();
|
||||||
}
|
}
|
||||||
|
|
@ -121,7 +121,7 @@ var Tokenizer = function(rules) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
if (value[0]) {
|
if (value[0]) {
|
||||||
if (typeof type == "string") {
|
if (typeof type == "string") {
|
||||||
|
|
@ -139,7 +139,7 @@ var Tokenizer = function(rules) {
|
||||||
token = {
|
token = {
|
||||||
type: type[i],
|
type: type[i],
|
||||||
value: value[i]
|
value: value[i]
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +148,7 @@ var Tokenizer = function(rules) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
lastIndex = re.lastIndex;
|
lastIndex = re.lastIndex;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (token.type)
|
if (token.type)
|
||||||
tokens.push(token);
|
tokens.push(token);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue