Add plain text rule for namespaces (@misfo's idea)

This commit is contained in:
Chris Wanstrath 2011-07-26 00:32:00 -07:00
commit 66790c4c01
2 changed files with 13 additions and 0 deletions

View file

@ -118,6 +118,9 @@ var RubyHighlightRules = function() {
token : "string", // backtick string
regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]"
}, {
token : "text", // namespaces aren't symbols
regex : "::"
}, {
token : "variable.instancce", // instance variable
regex : "@{1,2}(?:[a-zA-Z_]|\d)+"
}, {

View file

@ -60,6 +60,16 @@ module.exports = {
":th!ing", ":thing#"]);
},
"test: namespaces aren't symbols" : function() {
var line = "Namespaced::Class";
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;
assert.equal(3, tokens.length);
assert.equal("variable.class", tokens[0].type);
assert.equal("text", tokens[1].type);
assert.equal("variable.class", tokens[2].type);
},
"test: hex tokenizer" : function() {
assertValidTokens(this.tokenizer, "constant.numeric",
["0x9a", "0XA1", "0x9_a"]);