improve highlighting of ruby strings

This commit is contained in:
nightwing 2014-11-01 21:44:53 +04:00
commit ca9bc7a97a

View file

@ -141,9 +141,71 @@ var RubyHighlightRules = function() {
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
},
qString,
qqString,
tString,
[{
regex: "[{}]", onMatch: function(val, state, stack) {
this.next = val == "{" ? this.nextState : "";
if (val == "{" && stack.length) {
stack.unshift("start", state);
return "paren.lparen";
}
if (val == "}" && stack.length) {
stack.shift();
this.next = stack.shift();
if (this.next.indexOf("string") != -1)
return "paren.end";
}
return val == "{" ? "paren.lparen" : "paren.rparen";
},
nextState: "start"
}, {
token : "string.start",
regex : /"/,
push : [{
token : "constant.language.escape",
regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/
}, {
token : "paren.start",
regex : /\#{/,
push : "start"
}, {
token : "string.end",
regex : /"/,
next : "pop"
}, {
defaultToken: "string"
}]
}, {
token : "string.start",
regex : /`/,
push : [{
token : "constant.language.escape",
regex : /\\(?:[nsrtvfbae'"\\]|c.|C-.|M-.(?:\\C-.)?|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4})/
}, {
token : "paren.start",
regex : /\#{/,
push : "start"
}, {
token : "string.end",
regex : /`/,
next : "pop"
}, {
defaultToken: "string"
}]
}, {
token : "string.start",
regex : /'/,
push : [{
token : "constant.language.escape",
regex : /\\['\\]/
}, {
token : "string.end",
regex : /'/,
next : "pop"
}, {
defaultToken: "string"
}]
}],
// TODO: add support for %[QqxWwrs][{[(]
{
token : "text", // namespaces aren't symbols