fix html tokenizer regressions
This commit is contained in:
parent
6abddb1746
commit
b323001d29
2 changed files with 10 additions and 15 deletions
|
|
@ -47,8 +47,7 @@ var HtmlHighlightRules = function() {
|
||||||
// regexp must not have capturing parentheses
|
// regexp must not have capturing parentheses
|
||||||
// regexps are ordered -> the first match is used
|
// regexps are ordered -> the first match is used
|
||||||
function string(state) {
|
function string(state) {
|
||||||
return [
|
return [{
|
||||||
{
|
|
||||||
token : "string",
|
token : "string",
|
||||||
regex : '".*?"'
|
regex : '".*?"'
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -94,6 +93,9 @@ var HtmlHighlightRules = function() {
|
||||||
next : name + "-attribute-list"
|
next : name + "-attribute-list"
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
states[name + "-qstring"] = multiLineString("'", name);
|
||||||
|
states[name + "-qqstring"] = multiLineString("\"", name);
|
||||||
|
|
||||||
states[name + "-attribute-list"] = [{
|
states[name + "-attribute-list"] = [{
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : ">",
|
regex : ">",
|
||||||
|
|
@ -107,7 +109,7 @@ var HtmlHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : "\\s+"
|
regex : "\\s+"
|
||||||
}].concat(string("attribute-list"));
|
}].concat(string(name));
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
|
|
@ -143,14 +145,7 @@ var HtmlHighlightRules = function() {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : "[^<]+"
|
regex : "[^<]+"
|
||||||
} ],
|
} ],
|
||||||
|
|
||||||
"style-qstring": multiLineString("'", "style"),
|
|
||||||
"style-qqstring": multiLineString('"', "style"),
|
|
||||||
"script-qstring": multiLineString("'", "script"),
|
|
||||||
"script-qqstring": multiLineString('"', "script"),
|
|
||||||
"tag-qstring": multiLineString("'", "tag"),
|
|
||||||
"tag-qqstring": multiLineString('"', "tag"),
|
|
||||||
|
|
||||||
cdata : [ {
|
cdata : [ {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : "\\]\\]>",
|
regex : "\\]\\]>",
|
||||||
|
|
|
||||||
|
|
@ -56,15 +56,15 @@ module.exports = {
|
||||||
|
|
||||||
//assert.equal(10, tokens.length);
|
//assert.equal(10, tokens.length);
|
||||||
assert.equal("text", tokens[0].type);
|
assert.equal("text", tokens[0].type);
|
||||||
assert.equal("keyword", tokens[1].type);
|
assert.equal("meta.tag", tokens[1].type);
|
||||||
assert.equal("text", tokens[2].type);
|
assert.equal("text", tokens[2].type);
|
||||||
assert.equal("keyword", tokens[3].type);
|
assert.equal("entity.other.attribute-name", tokens[3].type);
|
||||||
assert.equal("text", tokens[4].type);
|
assert.equal("text", tokens[4].type);
|
||||||
assert.equal("string", tokens[5].type);
|
assert.equal("string", tokens[5].type);
|
||||||
assert.equal("text", tokens[6].type);
|
assert.equal("text", tokens[6].type);
|
||||||
assert.equal("keyword", tokens[7].type);
|
assert.equal("keyword", tokens[7].type);
|
||||||
assert.equal("text", tokens[8].type);
|
assert.equal("text", tokens[8].type);
|
||||||
assert.equal("keyword", tokens[9].type);
|
assert.equal("meta.tag", tokens[9].type);
|
||||||
assert.equal("text", tokens[10].type);
|
assert.equal("text", tokens[10].type);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: tokenize multiline attribute value with single quotes": function() {
|
"test: tokenize multiline attribute value with single quotes": function() {
|
||||||
var line1 = this.tokenizer.getLineTokens('<a href=\'abc', "start");
|
var line1 = this.tokenizer.getLineTokens("<a href='abc", "start");
|
||||||
var t1 = line1.tokens;
|
var t1 = line1.tokens;
|
||||||
var t2 = this.tokenizer.getLineTokens('def\'>', line1.state).tokens;
|
var t2 = this.tokenizer.getLineTokens('def\'>', line1.state).tokens;
|
||||||
assert.equal(t1[t1.length-1].type, "string");
|
assert.equal(t1[t1.length-1].type, "string");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue