improve highlighting of ruby strings
This commit is contained in:
parent
5b3bbba54e
commit
ca9bc7a97a
1 changed files with 65 additions and 3 deletions
|
|
@ -141,9 +141,71 @@ var RubyHighlightRules = function() {
|
||||||
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
|
||||||
},
|
},
|
||||||
|
|
||||||
qString,
|
[{
|
||||||
qqString,
|
regex: "[{}]", onMatch: function(val, state, stack) {
|
||||||
tString,
|
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
|
token : "text", // namespaces aren't symbols
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue