codemirror-rails 3.02 → 3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/codemirror-rails.gemspec +1 -0
- data/doc/CodeMirror-LICENSE +5 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/dialog}/dialog.js +4 -0
- data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +54 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +54 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/closetag.js +9 -8
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/continuecomment.js +12 -4
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +25 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/matchbrackets.js +30 -11
- data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +31 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +32 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +11 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +64 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +582 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/javascript-hint.js +15 -11
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/pig-hint.js +19 -19
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/python-hint.js +2 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +180 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/xml-hint.js +5 -18
- data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +127 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +14 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +197 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/loadmode.js +0 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/multiplex.js +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/overlay.js +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/colorize.js +0 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode-standalone.js +2 -3
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode.js +0 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +89 -0
- data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +60 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/search}/search.js +5 -5
- data/vendor/assets/javascripts/codemirror/{utils → addons/search}/searchcursor.js +37 -30
- data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +39 -0
- data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +34 -0
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +721 -188
- data/vendor/assets/javascripts/codemirror/modes/asterisk.js +6 -6
- data/vendor/assets/javascripts/codemirror/modes/clike.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +23 -7
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/css.js +337 -235
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +12 -12
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/gas.js +326 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -0
- data/vendor/assets/javascripts/codemirror/modes/haskell.js +26 -26
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +17 -17
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +6 -6
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +43 -23
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +78 -33
- data/vendor/assets/javascripts/codemirror/modes/jinja2.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/less.js +38 -38
- data/vendor/assets/javascripts/codemirror/modes/livescript.js +267 -0
- data/vendor/assets/javascripts/codemirror/modes/lua.js +7 -7
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +108 -57
- data/vendor/assets/javascripts/codemirror/modes/mirc.js +177 -0
- data/vendor/assets/javascripts/codemirror/modes/ntriples.js +22 -22
- data/vendor/assets/javascripts/codemirror/modes/ocaml.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/perl.js +791 -791
- data/vendor/assets/javascripts/codemirror/modes/php.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/pig.js +163 -163
- data/vendor/assets/javascripts/codemirror/modes/python.js +31 -31
- data/vendor/assets/javascripts/codemirror/modes/q.js +124 -0
- data/vendor/assets/javascripts/codemirror/modes/rst.js +486 -250
- data/vendor/assets/javascripts/codemirror/modes/sass.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/scss_test.js +80 -0
- data/vendor/assets/javascripts/codemirror/modes/shell.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/sieve.js +10 -10
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +129 -129
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/sparql.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sql.js +23 -23
- data/vendor/assets/javascripts/codemirror/modes/stex.js +192 -121
- data/vendor/assets/javascripts/codemirror/modes/tcl.js +131 -0
- data/vendor/assets/javascripts/codemirror/modes/test.js +64 -0
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +345 -345
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +297 -298
- data/vendor/assets/javascripts/codemirror/modes/turtle.js +145 -0
- data/vendor/assets/javascripts/codemirror/modes/vb.js +31 -32
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +4 -4
- data/vendor/assets/javascripts/codemirror/modes/xml.js +10 -6
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +55 -55
- data/vendor/assets/javascripts/codemirror/modes/yaml.js +90 -90
- data/vendor/assets/javascripts/codemirror/modes/z80.js +82 -110
- data/vendor/assets/javascripts/codemirror.js +1914 -1115
- data/vendor/assets/stylesheets/codemirror/{utils → addons/dialog}/dialog.css +0 -0
- data/vendor/assets/stylesheets/codemirror/addons/hint/show-hint.css +38 -0
- data/vendor/assets/stylesheets/codemirror/addons/lint/lint.css +96 -0
- data/vendor/assets/stylesheets/codemirror/modes/tiki.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/ambiance-mobile.css +0 -1
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +0 -1
- data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +5 -5
- data/vendor/assets/stylesheets/codemirror/themes/midnight.css +52 -0
- data/vendor/assets/stylesheets/codemirror/themes/xq-light.css +43 -0
- data/vendor/assets/stylesheets/codemirror.css +16 -10
- metadata +60 -52
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +0 -203
- data/vendor/assets/javascripts/codemirror/modes/plsql.js +0 -216
- data/vendor/assets/javascripts/codemirror/utils/collapserange.js +0 -68
- data/vendor/assets/javascripts/codemirror/utils/continuelist.js +0 -28
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +0 -183
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +0 -114
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +0 -46
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +0 -102
- data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +0 -16
@@ -3,95 +3,93 @@
|
|
3
3
|
* Licence: MIT
|
4
4
|
*/
|
5
5
|
|
6
|
-
CodeMirror.defineMode("stex", function()
|
7
|
-
|
6
|
+
CodeMirror.defineMode("stex", function() {
|
7
|
+
"use strict";
|
8
|
+
|
8
9
|
function pushCommand(state, command) {
|
9
|
-
|
10
|
+
state.cmdState.push(command);
|
10
11
|
}
|
11
12
|
|
12
|
-
function peekCommand(state) {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
function peekCommand(state) {
|
14
|
+
if (state.cmdState.length > 0) {
|
15
|
+
return state.cmdState[state.cmdState.length - 1];
|
16
|
+
} else {
|
17
|
+
return null;
|
18
|
+
}
|
17
19
|
}
|
18
20
|
|
19
21
|
function popCommand(state) {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
var plug = state.cmdState.pop();
|
23
|
+
if (plug) {
|
24
|
+
plug.closeBracket();
|
25
|
+
}
|
24
26
|
}
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
// returns the non-default plugin closest to the end of the list
|
29
|
+
function getMostPowerful(state) {
|
30
|
+
var context = state.cmdState;
|
31
|
+
for (var i = context.length - 1; i >= 0; i--) {
|
32
|
+
var plug = context[i];
|
33
|
+
if (plug.name == "DEFAULT") {
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
return plug;
|
37
|
+
}
|
38
|
+
return { styleIdentifier: function() { return null; } };
|
35
39
|
}
|
36
40
|
|
37
|
-
function addPluginPattern(pluginName, cmdStyle,
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
};
|
55
|
-
this.closeBracket = function() {};
|
56
|
-
};
|
41
|
+
function addPluginPattern(pluginName, cmdStyle, styles) {
|
42
|
+
return function () {
|
43
|
+
this.name = pluginName;
|
44
|
+
this.bracketNo = 0;
|
45
|
+
this.style = cmdStyle;
|
46
|
+
this.styles = styles;
|
47
|
+
this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin
|
48
|
+
|
49
|
+
this.styleIdentifier = function() {
|
50
|
+
return this.styles[this.bracketNo - 1] || null;
|
51
|
+
};
|
52
|
+
this.openBracket = function() {
|
53
|
+
this.bracketNo++;
|
54
|
+
return "bracket";
|
55
|
+
};
|
56
|
+
this.closeBracket = function() {};
|
57
|
+
};
|
57
58
|
}
|
58
59
|
|
59
|
-
var plugins =
|
60
|
-
|
61
|
-
plugins["importmodule"] = addPluginPattern("importmodule", "tag",
|
62
|
-
plugins["documentclass"] = addPluginPattern("documentclass", "tag",
|
63
|
-
plugins["usepackage"] = addPluginPattern("
|
64
|
-
plugins["begin"] = addPluginPattern("
|
65
|
-
plugins["end"] = addPluginPattern("
|
60
|
+
var plugins = {};
|
61
|
+
|
62
|
+
plugins["importmodule"] = addPluginPattern("importmodule", "tag", ["string", "builtin"]);
|
63
|
+
plugins["documentclass"] = addPluginPattern("documentclass", "tag", ["", "atom"]);
|
64
|
+
plugins["usepackage"] = addPluginPattern("usepackage", "tag", ["atom"]);
|
65
|
+
plugins["begin"] = addPluginPattern("begin", "tag", ["atom"]);
|
66
|
+
plugins["end"] = addPluginPattern("end", "tag", ["atom"]);
|
66
67
|
|
67
68
|
plugins["DEFAULT"] = function () {
|
68
|
-
|
69
|
-
|
69
|
+
this.name = "DEFAULT";
|
70
|
+
this.style = "tag";
|
70
71
|
|
71
|
-
|
72
|
+
this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
|
72
73
|
};
|
73
74
|
|
74
75
|
function setState(state, f) {
|
75
|
-
|
76
|
+
state.f = f;
|
76
77
|
}
|
77
78
|
|
79
|
+
// called when in a normal (no environment) context
|
78
80
|
function normal(source, state) {
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
var
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
pushCommand(state, plug);
|
90
|
-
setState(state, beginParams);
|
91
|
-
return plug.style;
|
92
|
-
}
|
81
|
+
var plug;
|
82
|
+
// Do we look like '\command' ? If so, attempt to apply the plugin 'command'
|
83
|
+
if (source.match(/^\\[a-zA-Z@]+/)) {
|
84
|
+
var cmdName = source.current().slice(1);
|
85
|
+
plug = plugins[cmdName] || plugins["DEFAULT"];
|
86
|
+
plug = new plug();
|
87
|
+
pushCommand(state, plug);
|
88
|
+
setState(state, beginParams);
|
89
|
+
return plug.style;
|
90
|
+
}
|
93
91
|
|
94
|
-
// escape characters
|
92
|
+
// escape characters
|
95
93
|
if (source.match(/^\\[$&%#{}_]/)) {
|
96
94
|
return "tag";
|
97
95
|
}
|
@@ -101,74 +99,147 @@ CodeMirror.defineMode("stex", function()
|
|
101
99
|
return "tag";
|
102
100
|
}
|
103
101
|
|
104
|
-
|
105
|
-
|
102
|
+
// find if we're starting various math modes
|
103
|
+
if (source.match("\\[")) {
|
104
|
+
setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
|
105
|
+
return "keyword";
|
106
|
+
}
|
107
|
+
if (source.match("$$")) {
|
108
|
+
setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
|
109
|
+
return "keyword";
|
110
|
+
}
|
111
|
+
if (source.match("$")) {
|
112
|
+
setState(state, function(source, state){ return inMathMode(source, state, "$"); });
|
113
|
+
return "keyword";
|
114
|
+
}
|
115
|
+
|
116
|
+
var ch = source.next();
|
117
|
+
if (ch == "%") {
|
106
118
|
// special case: % at end of its own line; stay in same state
|
107
119
|
if (!source.eol()) {
|
108
120
|
setState(state, inCComment);
|
109
121
|
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
122
|
+
return "comment";
|
123
|
+
}
|
124
|
+
else if (ch == '}' || ch == ']') {
|
125
|
+
plug = peekCommand(state);
|
126
|
+
if (plug) {
|
127
|
+
plug.closeBracket(ch);
|
128
|
+
setState(state, beginParams);
|
129
|
+
} else {
|
130
|
+
return "error";
|
131
|
+
}
|
132
|
+
return "bracket";
|
133
|
+
} else if (ch == '{' || ch == '[') {
|
134
|
+
plug = plugins["DEFAULT"];
|
135
|
+
plug = new plug();
|
136
|
+
pushCommand(state, plug);
|
137
|
+
return "bracket";
|
138
|
+
}
|
139
|
+
else if (/\d/.test(ch)) {
|
140
|
+
source.eatWhile(/[\w.%]/);
|
141
|
+
return "atom";
|
142
|
+
}
|
143
|
+
else {
|
144
|
+
source.eatWhile(/[\w\-_]/);
|
145
|
+
plug = getMostPowerful(state);
|
146
|
+
if (plug.name == 'begin') {
|
147
|
+
plug.argument = source.current();
|
148
|
+
}
|
149
|
+
return plug.styleIdentifier();
|
150
|
+
}
|
134
151
|
}
|
135
152
|
|
136
153
|
function inCComment(source, state) {
|
137
|
-
|
138
|
-
|
139
|
-
|
154
|
+
source.skipToEnd();
|
155
|
+
setState(state, normal);
|
156
|
+
return "comment";
|
157
|
+
}
|
158
|
+
|
159
|
+
function inMathMode(source, state, endModeSeq) {
|
160
|
+
if (source.eatSpace()) {
|
161
|
+
return null;
|
162
|
+
}
|
163
|
+
if (source.match(endModeSeq)) {
|
164
|
+
setState(state, normal);
|
165
|
+
return "keyword";
|
166
|
+
}
|
167
|
+
if (source.match(/^\\[a-zA-Z@]+/)) {
|
168
|
+
return "tag";
|
169
|
+
}
|
170
|
+
if (source.match(/^[a-zA-Z]+/)) {
|
171
|
+
return "variable-2";
|
172
|
+
}
|
173
|
+
// escape characters
|
174
|
+
if (source.match(/^\\[$&%#{}_]/)) {
|
175
|
+
return "tag";
|
176
|
+
}
|
177
|
+
// white space control characters
|
178
|
+
if (source.match(/^\\[,;!\/]/)) {
|
179
|
+
return "tag";
|
180
|
+
}
|
181
|
+
// special math-mode characters
|
182
|
+
if (source.match(/^[\^_&]/)) {
|
183
|
+
return "tag";
|
184
|
+
}
|
185
|
+
// non-special characters
|
186
|
+
if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
|
187
|
+
return null;
|
188
|
+
}
|
189
|
+
if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
|
190
|
+
return "number";
|
191
|
+
}
|
192
|
+
var ch = source.next();
|
193
|
+
if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
|
194
|
+
return "bracket";
|
195
|
+
}
|
196
|
+
|
197
|
+
// eat comments here, because inCComment returns us to normal state!
|
198
|
+
if (ch == "%") {
|
199
|
+
if (!source.eol()) {
|
200
|
+
source.skipToEnd();
|
201
|
+
}
|
202
|
+
return "comment";
|
203
|
+
}
|
204
|
+
return "error";
|
140
205
|
}
|
141
206
|
|
142
207
|
function beginParams(source, state) {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
popCommand(state);
|
159
|
-
}
|
208
|
+
var ch = source.peek(), lastPlug;
|
209
|
+
if (ch == '{' || ch == '[') {
|
210
|
+
lastPlug = peekCommand(state);
|
211
|
+
lastPlug.openBracket(ch);
|
212
|
+
source.eat(ch);
|
213
|
+
setState(state, normal);
|
214
|
+
return "bracket";
|
215
|
+
}
|
216
|
+
if (/[ \t\r]/.test(ch)) {
|
217
|
+
source.eat(ch);
|
218
|
+
return null;
|
219
|
+
}
|
220
|
+
setState(state, normal);
|
221
|
+
popCommand(state);
|
222
|
+
|
160
223
|
return normal(source, state);
|
161
224
|
}
|
162
225
|
|
163
226
|
return {
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
227
|
+
startState: function() {
|
228
|
+
return {
|
229
|
+
cmdState: [],
|
230
|
+
f: normal
|
231
|
+
};
|
232
|
+
},
|
233
|
+
copyState: function(s) {
|
234
|
+
return {
|
235
|
+
cmdState: s.cmdState.slice(),
|
236
|
+
f: s.f
|
237
|
+
};
|
238
|
+
},
|
239
|
+
token: function(stream, state) {
|
240
|
+
return state.f(stream, state);
|
241
|
+
}
|
242
|
+
};
|
172
243
|
});
|
173
244
|
|
174
245
|
CodeMirror.defineMIME("text/x-stex", "stex");
|
@@ -0,0 +1,131 @@
|
|
1
|
+
//tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
|
2
|
+
CodeMirror.defineMode("tcl", function() {
|
3
|
+
function parseWords(str) {
|
4
|
+
var obj = {}, words = str.split(" ");
|
5
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
6
|
+
return obj;
|
7
|
+
}
|
8
|
+
var keywords = parseWords("Tcl safe after append array auto_execok auto_import auto_load " +
|
9
|
+
"auto_mkindex auto_mkindex_old auto_qualify auto_reset bgerror " +
|
10
|
+
"binary break catch cd close concat continue dde eof encoding error " +
|
11
|
+
"eval exec exit expr fblocked fconfigure fcopy file fileevent filename " +
|
12
|
+
"filename flush for foreach format gets glob global history http if " +
|
13
|
+
"incr info interp join lappend lindex linsert list llength load lrange " +
|
14
|
+
"lreplace lsearch lset lsort memory msgcat namespace open package parray " +
|
15
|
+
"pid pkg::create pkg_mkIndex proc puts pwd re_syntax read regex regexp " +
|
16
|
+
"registry regsub rename resource return scan seek set socket source split " +
|
17
|
+
"string subst switch tcl_endOfWord tcl_findLibrary tcl_startOfNextWord " +
|
18
|
+
"tcl_wordBreakAfter tcl_startOfPreviousWord tcl_wordBreakBefore tcltest " +
|
19
|
+
"tclvars tell time trace unknown unset update uplevel upvar variable " +
|
20
|
+
"vwait");
|
21
|
+
var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch");
|
22
|
+
var isOperatorChar = /[+\-*&%=<>!?^\/\|]/;
|
23
|
+
function chain(stream, state, f) {
|
24
|
+
state.tokenize = f;
|
25
|
+
return f(stream, state);
|
26
|
+
}
|
27
|
+
function tokenBase(stream, state) {
|
28
|
+
var beforeParams = state.beforeParams;
|
29
|
+
state.beforeParams = false;
|
30
|
+
var ch = stream.next();
|
31
|
+
if ((ch == '"' || ch == "'") && state.inParams)
|
32
|
+
return chain(stream, state, tokenString(ch));
|
33
|
+
else if (/[\[\]{}\(\),;\.]/.test(ch)) {
|
34
|
+
if (ch == "(" && beforeParams) state.inParams = true;
|
35
|
+
else if (ch == ")") state.inParams = false;
|
36
|
+
return null;
|
37
|
+
}
|
38
|
+
else if (/\d/.test(ch)) {
|
39
|
+
stream.eatWhile(/[\w\.]/);
|
40
|
+
return "number";
|
41
|
+
}
|
42
|
+
else if (ch == "#" && stream.eat("*")) {
|
43
|
+
return chain(stream, state, tokenComment);
|
44
|
+
}
|
45
|
+
else if (ch == "#" && stream.match(/ *\[ *\[/)) {
|
46
|
+
return chain(stream, state, tokenUnparsed);
|
47
|
+
}
|
48
|
+
else if (ch == "#" && stream.eat("#")) {
|
49
|
+
stream.skipToEnd();
|
50
|
+
return "comment";
|
51
|
+
}
|
52
|
+
else if (ch == '"') {
|
53
|
+
stream.skipTo(/"/);
|
54
|
+
return "comment";
|
55
|
+
}
|
56
|
+
else if (ch == "$") {
|
57
|
+
stream.eatWhile(/[$_a-z0-9A-Z\.{:]/);
|
58
|
+
stream.eatWhile(/}/);
|
59
|
+
state.beforeParams = true;
|
60
|
+
return "builtin";
|
61
|
+
}
|
62
|
+
else if (isOperatorChar.test(ch)) {
|
63
|
+
stream.eatWhile(isOperatorChar);
|
64
|
+
return "comment";
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
stream.eatWhile(/[\w\$_{}]/);
|
68
|
+
var word = stream.current().toLowerCase();
|
69
|
+
if (keywords && keywords.propertyIsEnumerable(word))
|
70
|
+
return "keyword";
|
71
|
+
if (functions && functions.propertyIsEnumerable(word)) {
|
72
|
+
state.beforeParams = true;
|
73
|
+
return "keyword";
|
74
|
+
}
|
75
|
+
return null;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
function tokenString(quote) {
|
79
|
+
return function(stream, state) {
|
80
|
+
var escaped = false, next, end = false;
|
81
|
+
while ((next = stream.next()) != null) {
|
82
|
+
if (next == quote && !escaped) {
|
83
|
+
end = true;
|
84
|
+
break;
|
85
|
+
}
|
86
|
+
escaped = !escaped && next == "\\";
|
87
|
+
}
|
88
|
+
if (end) state.tokenize = tokenBase;
|
89
|
+
return "string";
|
90
|
+
};
|
91
|
+
}
|
92
|
+
function tokenComment(stream, state) {
|
93
|
+
var maybeEnd = false, ch;
|
94
|
+
while (ch = stream.next()) {
|
95
|
+
if (ch == "#" && maybeEnd) {
|
96
|
+
state.tokenize = tokenBase;
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
maybeEnd = (ch == "*");
|
100
|
+
}
|
101
|
+
return "comment";
|
102
|
+
}
|
103
|
+
function tokenUnparsed(stream, state) {
|
104
|
+
var maybeEnd = 0, ch;
|
105
|
+
while (ch = stream.next()) {
|
106
|
+
if (ch == "#" && maybeEnd == 2) {
|
107
|
+
state.tokenize = tokenBase;
|
108
|
+
break;
|
109
|
+
}
|
110
|
+
if (ch == "]")
|
111
|
+
maybeEnd++;
|
112
|
+
else if (ch != " ")
|
113
|
+
maybeEnd = 0;
|
114
|
+
}
|
115
|
+
return "meta";
|
116
|
+
}
|
117
|
+
return {
|
118
|
+
startState: function() {
|
119
|
+
return {
|
120
|
+
tokenize: tokenBase,
|
121
|
+
beforeParams: false,
|
122
|
+
inParams: false
|
123
|
+
};
|
124
|
+
},
|
125
|
+
token: function(stream, state) {
|
126
|
+
if (stream.eatSpace()) return null;
|
127
|
+
return state.tokenize(stream, state);
|
128
|
+
}
|
129
|
+
};
|
130
|
+
});
|
131
|
+
CodeMirror.defineMIME("text/x-tcl", "tcl");
|
@@ -0,0 +1,64 @@
|
|
1
|
+
// Don't take these too seriously -- the expected results appear to be
|
2
|
+
// based on the results of actual runs without any serious manual
|
3
|
+
// verification. If a change you made causes them to fail, the test is
|
4
|
+
// as likely to wrong as the code.
|
5
|
+
|
6
|
+
(function() {
|
7
|
+
var mode = CodeMirror.getMode({tabSize: 4}, "xquery");
|
8
|
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
9
|
+
|
10
|
+
MT("eviltest",
|
11
|
+
"[keyword xquery] [keyword version] [variable "1][keyword .][atom 0][keyword -][variable ml"][def&variable ;] [comment (: this is : a \"comment\" :)]",
|
12
|
+
" [keyword let] [variable $let] [keyword :=] [variable <x] [variable attr][keyword =][variable "value">"test"<func>][def&variable ;function]() [variable $var] {[keyword function]()} {[variable $var]}[variable <][keyword /][variable func><][keyword /][variable x>]",
|
13
|
+
" [keyword let] [variable $joe][keyword :=][atom 1]",
|
14
|
+
" [keyword return] [keyword element] [variable element] {",
|
15
|
+
" [keyword attribute] [variable attribute] { [atom 1] },",
|
16
|
+
" [keyword element] [variable test] { [variable 'a'] }, [keyword attribute] [variable foo] { [variable "bar"] },",
|
17
|
+
" [def&variable fn:doc]()[[ [variable foo][keyword /][variable @bar] [keyword eq] [variable $let] ]],",
|
18
|
+
" [keyword //][variable x] } [comment (: a more 'evil' test :)]",
|
19
|
+
" [comment (: Modified Blakeley example (: with nested comment :) ... :)]",
|
20
|
+
" [keyword declare] [keyword private] [keyword function] [def&variable local:declare]() {()}[variable ;]",
|
21
|
+
" [keyword declare] [keyword private] [keyword function] [def&variable local:private]() {()}[variable ;]",
|
22
|
+
" [keyword declare] [keyword private] [keyword function] [def&variable local:function]() {()}[variable ;]",
|
23
|
+
" [keyword declare] [keyword private] [keyword function] [def&variable local:local]() {()}[variable ;]",
|
24
|
+
" [keyword let] [variable $let] [keyword :=] [variable <let>let] [variable $let] [keyword :=] [variable "let"<][keyword /let][variable >]",
|
25
|
+
" [keyword return] [keyword element] [variable element] {",
|
26
|
+
" [keyword attribute] [variable attribute] { [keyword try] { [def&variable xdmp:version]() } [keyword catch]([variable $e]) { [def&variable xdmp:log]([variable $e]) } },",
|
27
|
+
" [keyword attribute] [variable fn:doc] { [variable "bar"] [variable castable] [keyword as] [atom xs:string] },",
|
28
|
+
" [keyword element] [variable text] { [keyword text] { [variable "text"] } },",
|
29
|
+
" [def&variable fn:doc]()[[ [qualifier child::][variable eq][keyword /]([variable @bar] [keyword |] [qualifier attribute::][variable attribute]) [keyword eq] [variable $let] ]],",
|
30
|
+
" [keyword //][variable fn:doc]",
|
31
|
+
" }");
|
32
|
+
|
33
|
+
MT("testEmptySequenceKeyword",
|
34
|
+
"[string \"foo\"] [keyword instance] [keyword of] [keyword empty-sequence]()");
|
35
|
+
|
36
|
+
MT("testMultiAttr",
|
37
|
+
"[tag <p ][attribute a1]=[string \"foo\"] [attribute a2]=[string \"bar\"][tag >][variable hello] [variable world][tag </p>]");
|
38
|
+
|
39
|
+
MT("test namespaced variable",
|
40
|
+
"[keyword declare] [keyword namespace] [variable e] [keyword =] [string \"http://example.com/ANamespace\"][variable ;declare] [keyword variable] [variable $e:exampleComThisVarIsNotRecognized] [keyword as] [keyword element]([keyword *]) [variable external;]");
|
41
|
+
|
42
|
+
MT("test EQName variable",
|
43
|
+
"[keyword declare] [keyword variable] [variable $\"http://www.example.com/ns/my\":var] [keyword :=] [atom 12][variable ;]",
|
44
|
+
"[tag <out>]{[variable $\"http://www.example.com/ns/my\":var]}[tag </out>]");
|
45
|
+
|
46
|
+
MT("test EQName function",
|
47
|
+
"[keyword declare] [keyword function] [def&variable \"http://www.example.com/ns/my\":fn] ([variable $a] [keyword as] [atom xs:integer]) [keyword as] [atom xs:integer] {",
|
48
|
+
" [variable $a] [keyword +] [atom 2]",
|
49
|
+
"}[variable ;]",
|
50
|
+
"[tag <out>]{[def&variable \"http://www.example.com/ns/my\":fn]([atom 12])}[tag </out>]");
|
51
|
+
|
52
|
+
MT("test EQName function with single quotes",
|
53
|
+
"[keyword declare] [keyword function] [def&variable 'http://www.example.com/ns/my':fn] ([variable $a] [keyword as] [atom xs:integer]) [keyword as] [atom xs:integer] {",
|
54
|
+
" [variable $a] [keyword +] [atom 2]",
|
55
|
+
"}[variable ;]",
|
56
|
+
"[tag <out>]{[def&variable 'http://www.example.com/ns/my':fn]([atom 12])}[tag </out>]");
|
57
|
+
|
58
|
+
MT("testProcessingInstructions",
|
59
|
+
"[def&variable data]([comment&meta <?target content?>]) [keyword instance] [keyword of] [atom xs:string]");
|
60
|
+
|
61
|
+
MT("testQuoteEscapeDouble",
|
62
|
+
"[keyword let] [variable $rootfolder] [keyword :=] [string \"c:\\builds\\winnt\\HEAD\\qa\\scripts\\\"]",
|
63
|
+
"[keyword let] [variable $keysfolder] [keyword :=] [def&variable concat]([variable $rootfolder], [string \"keys\\\"])");
|
64
|
+
})();
|