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
|
||||
merge : true,
|
||||
regex : '["].*$',
|
||||
regex : '["].*',
|
||||
next : "qqstring"
|
||||
}, {
|
||||
token : "string",
|
||||
|
|
@ -94,13 +94,13 @@ var XmlHighlightRules = function() {
|
|||
}, {
|
||||
token : "string", // multi line string start
|
||||
merge : true,
|
||||
regex : "['].*$",
|
||||
regex : "['].*",
|
||||
next : "qstring"
|
||||
}],
|
||||
|
||||
qstring: [{
|
||||
token : "string",
|
||||
regex : ".*'",
|
||||
regex : ".*?'",
|
||||
next : "tag"
|
||||
}, {
|
||||
token : "string",
|
||||
|
|
@ -110,7 +110,7 @@ var XmlHighlightRules = function() {
|
|||
|
||||
qqstring: [{
|
||||
token : "string",
|
||||
regex : ".*\"",
|
||||
regex : ".*?\"",
|
||||
next : "tag"
|
||||
}, {
|
||||
token : "string",
|
||||
|
|
|
|||
|
|
@ -62,11 +62,31 @@ module.exports = {
|
|||
assert.equal("text", tokens[2].type);
|
||||
assert.equal("keyword", tokens[3].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) {
|
||||
require("asyncjs").test.testcase(module.exports).exec()
|
||||
require("asyncjs").test.testcase(module.exports).exec();
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ var Tokenizer = function(rules) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (value[0]) {
|
||||
if (typeof type == "string") {
|
||||
|
|
@ -139,7 +139,7 @@ var Tokenizer = function(rules) {
|
|||
token = {
|
||||
type: type[i],
|
||||
value: value[i]
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ var Tokenizer = function(rules) {
|
|||
break;
|
||||
|
||||
lastIndex = re.lastIndex;
|
||||
};
|
||||
}
|
||||
|
||||
if (token.type)
|
||||
tokens.push(token);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue