diff --git a/demo/kitchen-sink/docs/ruby.rb b/demo/kitchen-sink/docs/ruby.rb index 48e26ae0..c4d73d19 100644 --- a/demo/kitchen-sink/docs/ruby.rb +++ b/demo/kitchen-sink/docs/ruby.rb @@ -20,4 +20,16 @@ class Range end end -{:id => 34, :sdfasdfasdf => "asdasdads"} \ No newline at end of file +{:id => 34, :key => "value"} + + + herDocs = [<<'FOO', <" + }, { + stateName: "heredoc", + token : function(value, currentState, stack) { + var next = value[0].length == 2 ? "heredoc" : "indentedHeredoc" + stack.push(next, value[2]) + return ["constant", "string", "support.class", "string"] + }, + regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)", + rules: { + heredoc: [{ + token: function(value, currentState, stack) { + if (value == stack[1]) { + stack.shift(); + stack.shift(); + return "support.class"; + } + return "string"; + }, + regex: ".*$", + "next": "start" + }], + indentedHeredoc: [{ + token: "string", + regex: "^ +" + }, { + token: function(value, currentState, stack) { + if (value == stack[1]) { + stack.shift(); + stack.shift(); + return "support.class"; + } + return "string"; + }, + regex: ".*$", + "next": "start" + }] + } }, { token : "keyword.operator", regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" @@ -196,6 +233,8 @@ var RubyHighlightRules = function() { } ] }; + + this.normalizeRules(); }; oop.inherits(RubyHighlightRules, TextHighlightRules); diff --git a/lib/ace/mode/text_highlight_rules.js b/lib/ace/mode/text_highlight_rules.js index 2dd176f4..25a8bc87 100644 --- a/lib/ace/mode/text_highlight_rules.js +++ b/lib/ace/mode/text_highlight_rules.js @@ -54,7 +54,7 @@ var TextHighlightRules = function() { this.addRules = function(rules, prefix) { for (var key in rules) { var state = rules[key]; - for (var i=0; i