From 328f0cb347baa2ae51b7aa5f9eb59785363ff704 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 28 Feb 2013 12:24:19 +0400 Subject: [PATCH] add more tests for ruby highlighting --- lib/ace/mode/_test/text_ruby.txt | 21 +++++- lib/ace/mode/_test/tokens_ruby.json | 97 ++++++++++++++++++++++++++++ lib/ace/mode/ruby_highlight_rules.js | 4 +- 3 files changed, 119 insertions(+), 3 deletions(-) diff --git a/lib/ace/mode/_test/text_ruby.txt b/lib/ace/mode/_test/text_ruby.txt index c52fe4c3..1343a270 100644 --- a/lib/ace/mode/_test/text_ruby.txt +++ b/lib/ace/mode/_test/text_ruby.txt @@ -12,4 +12,23 @@ #test: float tokenizer [1, +1, -1, 12_345, 0.000_1, _, 3_1, 1_2, 1_.0, 0._1]; - \ No newline at end of file + +{:id => 34, :key => "value"} + +=begin +=end + +=begin x +=end- +=end x + + herDocs = [<<'FOO', <"], + ["text"," "], + ["constant.numeric","34"], + ["text",", "], + ["constant.other.symbol.ruby",":key"], + ["text"," "], + ["punctuation.separator.key-value","=>"], + ["text"," "], + ["string","\"value\""], + ["paren.rparen","}"] +],[ + "start" +],[ + "comment", + ["comment","=begin"] +],[ + "start", + ["comment","=end"] +],[ + "start" +],[ + "comment", + ["comment","=begin x"] +],[ + "comment", + ["comment","=end-"] +],[ + "start", + ["comment","=end x"] +],[ + "start" +],[ + ["heredoc","FOO","heredoc","BAR","indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["text"," "], + ["identifier","herDocs"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["constant","<<"], + ["string","'"], + ["support.class","FOO"], + ["string","'"], + ["text",", "], + ["constant","<<"], + ["string",""], + ["support.class","BAR"], + ["string",""], + ["text",", "], + ["constant","<<-"], + ["string",""], + ["support.class","BAZ"], + ["string",""], + ["text",", "], + ["constant","<<-"], + ["string","`"], + ["support.class","EXEC"], + ["string","`"], + ["paren.rparen","]"], + ["text"," "], + ["comment","#comment"] +],[ + ["heredoc","FOO","heredoc","BAR","indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["string"," FOO #{literal}"] +],[ + ["heredoc","BAR","indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["support.class","FOO"] +],[ + ["heredoc","BAR","indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["string"," BAR #{fact(10)}"] +],[ + ["indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["support.class","BAR"] +],[ + ["indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["string"," BAZ indented"] +],[ + ["indentedHeredoc","EXEC"], + ["string"," "], + ["support.class","BAZ"] +],[ + ["indentedHeredoc","EXEC"], + ["string"," echo hi"] +],[ + "start", + ["string"," "], + ["support.class","EXEC"] +],[ + "start", + ["support.function","puts"], + ["text"," "], + ["identifier","herDocs"] ]] \ No newline at end of file diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index 2fd64a85..f0c45800 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -134,7 +134,7 @@ var RubyHighlightRules = function() { regex : "#.*$" }, { token : "comment", // multi line comment - regex : "^=begin\\s", + regex : "^=begin(?:$|\\s.*$)", next : "comment" }, { token : "string.regexp", @@ -231,7 +231,7 @@ var RubyHighlightRules = function() { "comment" : [ { token : "comment", // closing comment - regex : "^=end\\s.*$", + regex : "^=end(?:$|\\s.*$)", next : "start" }, { token : "comment", // comment spanning whole line