add ruby symbol and erb

This commit is contained in:
Heigh Tech LLC 2011-03-16 05:04:02 +08:00 committed by Fabian Jakobs
commit ae8e262395
2 changed files with 34 additions and 0 deletions

View file

@ -40,6 +40,7 @@ define(function(require, exports, module) {
var oop = require("pilot/oop");
var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules;
var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
var RubyHighlightRules = require("ace/mode/ruby_highlight_rules").RubyHighlightRules;
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var HtmlHighlightRules = function() {
@ -67,6 +68,10 @@ var HtmlHighlightRules = function() {
token : "text",
regex : "<(?=\s*style)",
next : "css"
}, {
token : "text",
regex : "<(?=\s*%)",
next : "ruby"
}, {
token : "text", // opening tag
regex : "<\\/?",
@ -115,6 +120,24 @@ var HtmlHighlightRules = function() {
regex : "'.*?'"
} ],
ruby : [ {
token : "text",
regex : ">",
next : "ruby-start"
}, {
token : "keyword",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "text",
regex : "\\s+"
}, {
token : "string",
regex : '".*?"'
}, {
token : "string",
regex : "'.*?'"
} ],
tag : [ {
token : "text",
regex : ">",
@ -174,6 +197,14 @@ var HtmlHighlightRules = function() {
regex: "<\\/(?=style)",
next: "tag"
});
var rubyRules = new RubyHighlightRules().getRules();
this.addRules(rubyRules, "ruby-");
this.$rules["ruby-start"].unshift({
token: "text",
regex: "<\\/(?=%)",
next: "tag"
});
};
oop.inherits(HtmlHighlightRules, TextHighlightRules);

View file

@ -86,6 +86,9 @@ var RubyHighlightRules = function() {
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token: "string", // symbol
regex: "[:](?:[a-zA-Z]|\d)+"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"