Skip to content
Browse files

[ruby mode] Fixes /= operator for highlighting

relates to #314
  • Loading branch information...
1 parent b19b03a commit e6dc18a0f5297180e8a59cd0cf18afa36e9fea24 @bgilb bgilb committed with marijnh
Showing with 13 additions and 0 deletions.
  1. +1 −0 mode/ruby/ruby.js
  2. +11 −0 mode/ruby/test.js
  3. +1 −0 test/index.html
View
1 mode/ruby/ruby.js
@@ -34,6 +34,7 @@ CodeMirror.defineMode("ruby", function(config) {
if (ch == "`" || ch == "'" || ch == '"') {
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
} else if (ch == "/" && !stream.eol() && stream.peek() != " ") {
+ if (stream.eat("=")) return "operator";
return chain(readQuoted(ch, "string-2", true), stream, state);
} else if (ch == "%") {
var style = "string", embed = true;
View
11 mode/ruby/test.js
@@ -0,0 +1,11 @@
+(function() {
+ var mode = CodeMirror.getMode({indentUnit: 2}, "ruby");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
+
+ MT("divide_equal_operator",
+ "[variable bar] [operator /=] [variable foo]");
+
+ MT("divide_equal_operator_no_spacing",
+ "[variable foo][operator /=][number 42]");
+
+})();
View
1 test/index.html
@@ -82,6 +82,7 @@
<script src="../mode/xml/xml.js"></script>
<script src="../mode/htmlmixed/htmlmixed.js"></script>
<script src="../mode/ruby/ruby.js"></script>
+ <script src="../mode/ruby/test.js"></script>
<script src="../mode/haml/haml.js"></script>
<script src="../mode/haml/test.js"></script>
<script src="../mode/markdown/markdown.js"></script>

0 comments on commit e6dc18a

Please sign in to comment.
Something went wrong with that request. Please try again.