diff --git a/demo/editor.html b/demo/editor.html
index f8b2f1a1..9ea770af 100644
--- a/demo/editor.html
+++ b/demo/editor.html
@@ -42,7 +42,9 @@
+
+
diff --git a/jsTestDriver.conf b/jsTestDriver.conf
index 7d00e89d..44db80ab 100644
--- a/jsTestDriver.conf
+++ b/jsTestDriver.conf
@@ -3,8 +3,9 @@ server: http://localhost:4224
load:
- src/ace/ace.js
- - src/ace/MEventEmitter.js
+ - src/ace/MEventEmitter.js
- src/ace/mode/Text.js
+ - src/ace/mode/TextHighlightRules.js
- src/ace/mode/*.js
- src/ace/layer/*.js
- src/ace/*.js
diff --git a/src/ace/Document.js b/src/ace/Document.js
index b624176b..577fd915 100644
--- a/src/ace/Document.js
+++ b/src/ace/Document.js
@@ -72,7 +72,6 @@ ace.Document = function(text, mode) {
this.$detectNewLine = function(text) {
var match = text.match(/^.*?(\r?\n)/m);
- console.log(match);
if (match) {
this.$autoNewLine = match[1];
} else {
diff --git a/src/ace/mode/CssHighlightRules.js b/src/ace/mode/CssHighlightRules.js
index a36871a7..1adcff59 100644
--- a/src/ace/mode/CssHighlightRules.js
+++ b/src/ace/mode/CssHighlightRules.js
@@ -175,10 +175,4 @@ ace.mode.CssHighlightRules = function() {
};
};
-(function() {
-
- this.getRules = function() {
- return this.$rules;
- };
-
-}).call(ace.mode.CssHighlightRules.prototype);
\ No newline at end of file
+ace.inherits(ace.mode.CssHighlightRules, ace.mode.TextHighlightRules);
\ No newline at end of file
diff --git a/src/ace/mode/DocCommentHighlightRules.js b/src/ace/mode/DocCommentHighlightRules.js
new file mode 100644
index 00000000..28533ced
--- /dev/null
+++ b/src/ace/mode/DocCommentHighlightRules.js
@@ -0,0 +1,38 @@
+ace.provide("ace.mode.DocCommentHighlightRules");
+
+ace.mode.DocCommentHighlightRules = function() {
+
+ this.$rules = {
+ "start" : [ {
+ token : "doc-comment", // closing comment
+ regex : "\\*\\/",
+ next : "start"
+ }, {
+ token : "doc-comment-tag",
+ regex : "@[\\w\\d_]+"
+ }, {
+ token : "doc-comment",
+ regex : "\s+"
+ }, {
+ token : "doc-comment",
+ regex : "[^@\\*]+"
+ }, {
+ token : "doc-comment",
+ regex : "."
+ }]
+ };
+};
+
+ace.inherits(ace.mode.DocCommentHighlightRules, ace.mode.TextHighlightRules);
+
+(function() {
+
+ this.getStartRule = function(start) {
+ return {
+ token : "doc-comment", // doc comment
+ regex : "\\/\\*\\*",
+ next: start
+ };
+ };
+
+}).call(ace.mode.DocCommentHighlightRules.prototype);
\ No newline at end of file
diff --git a/src/ace/mode/HtmlHighlightRules.js b/src/ace/mode/HtmlHighlightRules.js
index 9bd69914..f3daf6c2 100644
--- a/src/ace/mode/HtmlHighlightRules.js
+++ b/src/ace/mode/HtmlHighlightRules.js
@@ -114,7 +114,7 @@ ace.mode.HtmlHighlightRules = function() {
};
var jsRules = new ace.mode.JavaScriptHighlightRules().getRules();
- this.$addRules(jsRules, "js-");
+ this.addRules(jsRules, "js-");
this.$rules["js-start"].unshift({
token: "text",
regex: "<\\/(?=script)",
@@ -122,31 +122,11 @@ ace.mode.HtmlHighlightRules = function() {
});
var cssRules = new ace.mode.CssHighlightRules().getRules();
- this.$addRules(cssRules, "css-");
+ this.addRules(cssRules, "css-");
this.$rules["css-start"].unshift({
token: "text",
regex: "<\\/(?=style)",
next: "tag"
});
};
-
-(function() {
-
- this.$addRules = function(rules, prefix) {
- for (var key in rules) {
- var state = rules[key];
- for (var i=0; i the first match is used
-
this.$rules = {
"start" : [ {
token : "comment",
regex : "\\/\\/.*$"
- }, {
- token : "doc-comment", // doc comment
- regex : "\\/\\*\\*",
- next : "doc-comment"
- }, {
+ },
+ docComment.getStartRule("doc-start"),
+ {
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
@@ -83,23 +82,6 @@ ace.mode.JavaScriptHighlightRules = function() {
token : "text",
regex : "\\s+"
} ],
- "doc-comment" : [ {
- token : "doc-comment", // closing comment
- regex : "\\*\\/",
- next : "start"
- }, {
- token : "doc-comment-tag",
- regex : "@[\\w\\d_]+"
- }, {
- token : "doc-comment",
- regex : "\s+"
- }, {
- token : "doc-comment",
- regex : "[^@\\*]+"
- }, {
- token : "doc-comment",
- regex : "."
- }],
"comment" : [ {
token : "comment", // closing comment
regex : ".*?\\*\\/",
@@ -125,12 +107,8 @@ ace.mode.JavaScriptHighlightRules = function() {
regex : '.+'
} ]
};
+
+ this.addRules(docComment.getRules(), "doc-");
+ this.$rules["doc-start"][0].next = "start";
};
-
-(function() {
-
- this.getRules = function() {
- return this.$rules;
- };
-
-}).call(ace.mode.JavaScriptHighlightRules.prototype);
\ No newline at end of file
+ace.inherits(ace.mode.JavaScriptHighlightRules, ace.mode.TextHighlightRules);
\ No newline at end of file
diff --git a/src/ace/mode/Text.js b/src/ace/mode/Text.js
index 874048e9..013d24b5 100644
--- a/src/ace/mode/Text.js
+++ b/src/ace/mode/Text.js
@@ -1,13 +1,7 @@
ace.provide("ace.mode.Text");
ace.mode.Text = function() {
- var rules = {
- "start" : [ {
- token : "text",
- regex : ".+"
- } ]
- };
- this.$tokenizer = new ace.Tokenizer(rules);
+ this.$tokenizer = new ace.Tokenizer(new ace.mode.TextHighlightRules().getRules());
};
(function() {
diff --git a/src/ace/mode/TextHighlightRules.js b/src/ace/mode/TextHighlightRules.js
new file mode 100644
index 00000000..81e0e130
--- /dev/null
+++ b/src/ace/mode/TextHighlightRules.js
@@ -0,0 +1,37 @@
+ace.provide("ace.mode.TextHighlightRules");
+
+ace.mode.TextHighlightRules = function() {
+
+ // regexp must not have capturing parentheses
+ // regexps are ordered -> the first match is used
+
+ this.$rules = {
+ "start" : [ {
+ token : "text",
+ regex : ".+"
+ } ]
+ };
+};
+
+(function() {
+
+ this.addRules = function(rules, prefix) {
+ for (var key in rules) {
+ var state = rules[key];
+ for (var i=0; i