codemirror-rails 3.02 → 3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -1
  3. data/LICENSE +1 -1
  4. data/codemirror-rails.gemspec +1 -0
  5. data/doc/CodeMirror-LICENSE +5 -1
  6. data/lib/codemirror/rails/version.rb +2 -2
  7. data/vendor/assets/javascripts/codemirror/{utils → addons/dialog}/dialog.js +4 -0
  8. data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +54 -0
  9. data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +54 -0
  10. data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/closetag.js +9 -8
  11. data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/continuecomment.js +12 -4
  12. data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +25 -0
  13. data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/matchbrackets.js +30 -11
  14. data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +31 -0
  15. data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +32 -0
  16. data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +11 -0
  17. data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +64 -0
  18. data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +582 -0
  19. data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/javascript-hint.js +15 -11
  20. data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/pig-hint.js +19 -19
  21. data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/python-hint.js +2 -2
  22. data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +180 -0
  23. data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/xml-hint.js +5 -18
  24. data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +127 -0
  25. data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +14 -0
  26. data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +197 -0
  27. data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/loadmode.js +0 -0
  28. data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/multiplex.js +2 -2
  29. data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/overlay.js +2 -2
  30. data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/colorize.js +0 -0
  31. data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode-standalone.js +2 -3
  32. data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode.js +0 -0
  33. data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +89 -0
  34. data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +60 -0
  35. data/vendor/assets/javascripts/codemirror/{utils → addons/search}/search.js +5 -5
  36. data/vendor/assets/javascripts/codemirror/{utils → addons/search}/searchcursor.js +37 -30
  37. data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +39 -0
  38. data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +34 -0
  39. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +721 -188
  40. data/vendor/assets/javascripts/codemirror/modes/asterisk.js +6 -6
  41. data/vendor/assets/javascripts/codemirror/modes/clike.js +14 -14
  42. data/vendor/assets/javascripts/codemirror/modes/clojure.js +23 -7
  43. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +2 -2
  44. data/vendor/assets/javascripts/codemirror/modes/css.js +337 -235
  45. data/vendor/assets/javascripts/codemirror/modes/ecl.js +12 -12
  46. data/vendor/assets/javascripts/codemirror/modes/erlang.js +1 -1
  47. data/vendor/assets/javascripts/codemirror/modes/gas.js +326 -0
  48. data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -0
  49. data/vendor/assets/javascripts/codemirror/modes/haskell.js +26 -26
  50. data/vendor/assets/javascripts/codemirror/modes/haxe.js +17 -17
  51. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +6 -6
  52. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +43 -23
  53. data/vendor/assets/javascripts/codemirror/modes/javascript.js +78 -33
  54. data/vendor/assets/javascripts/codemirror/modes/jinja2.js +2 -2
  55. data/vendor/assets/javascripts/codemirror/modes/less.js +38 -38
  56. data/vendor/assets/javascripts/codemirror/modes/livescript.js +267 -0
  57. data/vendor/assets/javascripts/codemirror/modes/lua.js +7 -7
  58. data/vendor/assets/javascripts/codemirror/modes/markdown.js +108 -57
  59. data/vendor/assets/javascripts/codemirror/modes/mirc.js +177 -0
  60. data/vendor/assets/javascripts/codemirror/modes/ntriples.js +22 -22
  61. data/vendor/assets/javascripts/codemirror/modes/ocaml.js +1 -1
  62. data/vendor/assets/javascripts/codemirror/modes/perl.js +791 -791
  63. data/vendor/assets/javascripts/codemirror/modes/php.js +1 -1
  64. data/vendor/assets/javascripts/codemirror/modes/pig.js +163 -163
  65. data/vendor/assets/javascripts/codemirror/modes/python.js +31 -31
  66. data/vendor/assets/javascripts/codemirror/modes/q.js +124 -0
  67. data/vendor/assets/javascripts/codemirror/modes/rst.js +486 -250
  68. data/vendor/assets/javascripts/codemirror/modes/sass.js +3 -3
  69. data/vendor/assets/javascripts/codemirror/modes/scss_test.js +80 -0
  70. data/vendor/assets/javascripts/codemirror/modes/shell.js +2 -2
  71. data/vendor/assets/javascripts/codemirror/modes/sieve.js +10 -10
  72. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +129 -129
  73. data/vendor/assets/javascripts/codemirror/modes/smarty.js +3 -3
  74. data/vendor/assets/javascripts/codemirror/modes/sparql.js +1 -1
  75. data/vendor/assets/javascripts/codemirror/modes/sql.js +23 -23
  76. data/vendor/assets/javascripts/codemirror/modes/stex.js +192 -121
  77. data/vendor/assets/javascripts/codemirror/modes/tcl.js +131 -0
  78. data/vendor/assets/javascripts/codemirror/modes/test.js +64 -0
  79. data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +345 -345
  80. data/vendor/assets/javascripts/codemirror/modes/tiki.js +297 -298
  81. data/vendor/assets/javascripts/codemirror/modes/turtle.js +145 -0
  82. data/vendor/assets/javascripts/codemirror/modes/vb.js +31 -32
  83. data/vendor/assets/javascripts/codemirror/modes/vbscript.js +4 -4
  84. data/vendor/assets/javascripts/codemirror/modes/xml.js +10 -6
  85. data/vendor/assets/javascripts/codemirror/modes/xquery.js +55 -55
  86. data/vendor/assets/javascripts/codemirror/modes/yaml.js +90 -90
  87. data/vendor/assets/javascripts/codemirror/modes/z80.js +82 -110
  88. data/vendor/assets/javascripts/codemirror.js +1914 -1115
  89. data/vendor/assets/stylesheets/codemirror/{utils → addons/dialog}/dialog.css +0 -0
  90. data/vendor/assets/stylesheets/codemirror/addons/hint/show-hint.css +38 -0
  91. data/vendor/assets/stylesheets/codemirror/addons/lint/lint.css +96 -0
  92. data/vendor/assets/stylesheets/codemirror/modes/tiki.css +2 -2
  93. data/vendor/assets/stylesheets/codemirror/themes/ambiance-mobile.css +0 -1
  94. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +0 -1
  95. data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +2 -2
  96. data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +5 -5
  97. data/vendor/assets/stylesheets/codemirror/themes/midnight.css +52 -0
  98. data/vendor/assets/stylesheets/codemirror/themes/xq-light.css +43 -0
  99. data/vendor/assets/stylesheets/codemirror.css +16 -10
  100. metadata +60 -52
  101. data/vendor/assets/javascripts/codemirror/modes/mysql.js +0 -203
  102. data/vendor/assets/javascripts/codemirror/modes/plsql.js +0 -216
  103. data/vendor/assets/javascripts/codemirror/utils/collapserange.js +0 -68
  104. data/vendor/assets/javascripts/codemirror/utils/continuelist.js +0 -28
  105. data/vendor/assets/javascripts/codemirror/utils/foldcode.js +0 -183
  106. data/vendor/assets/javascripts/codemirror/utils/formatting.js +0 -114
  107. data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +0 -46
  108. data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +0 -102
  109. data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +0 -16
@@ -1,309 +1,308 @@
1
1
  CodeMirror.defineMode('tiki', function(config) {
2
- function inBlock(style, terminator, returnTokenizer) {
3
- return function(stream, state) {
4
- while (!stream.eol()) {
5
- if (stream.match(terminator)) {
6
- state.tokenize = inText;
7
- break;
8
- }
9
- stream.next();
10
- }
11
-
12
- if (returnTokenizer) state.tokenize = returnTokenizer;
13
-
14
- return style;
15
- };
16
- }
17
-
18
- function inLine(style) {
19
- return function(stream, state) {
20
- while(!stream.eol()) {
21
- stream.next();
22
- }
23
- state.tokenize = inText;
24
- return style;
25
- };
26
- }
27
-
28
- function inText(stream, state) {
29
- function chain(parser) {
30
- state.tokenize = parser;
31
- return parser(stream, state);
32
- }
33
-
34
- var sol = stream.sol();
35
- var ch = stream.next();
36
-
37
- //non start of line
38
- switch (ch) { //switch is generally much faster than if, so it is used here
39
- case "{": //plugin
40
- stream.eat("/");
41
- stream.eatSpace();
42
- var tagName = "";
43
- var c;
44
- while ((c = stream.eat(/[^\s\u00a0=\"\'\/?(}]/))) tagName += c;
45
- state.tokenize = inPlugin;
46
- return "tag";
47
- break;
48
- case "_": //bold
49
- if (stream.eat("_")) {
50
- return chain(inBlock("strong", "__", inText));
51
- }
52
- break;
53
- case "'": //italics
54
- if (stream.eat("'")) {
55
- // Italic text
56
- return chain(inBlock("em", "''", inText));
57
- }
58
- break;
59
- case "(":// Wiki Link
60
- if (stream.eat("(")) {
61
- return chain(inBlock("variable-2", "))", inText));
62
- }
63
- break;
64
- case "[":// Weblink
65
- return chain(inBlock("variable-3", "]", inText));
66
- break;
67
- case "|": //table
68
- if (stream.eat("|")) {
69
- return chain(inBlock("comment", "||"));
70
- }
71
- break;
72
- case "-":
73
- if (stream.eat("=")) {//titleBar
74
- return chain(inBlock("header string", "=-", inText));
75
- } else if (stream.eat("-")) {//deleted
76
- return chain(inBlock("error tw-deleted", "--", inText));
77
- }
78
- break;
79
- case "=": //underline
80
- if (stream.match("==")) {
81
- return chain(inBlock("tw-underline", "===", inText));
82
- }
83
- break;
84
- case ":":
85
- if (stream.eat(":")) {
86
- return chain(inBlock("comment", "::"));
87
- }
88
- break;
89
- case "^": //box
90
- return chain(inBlock("tw-box", "^"));
91
- break;
92
- case "~": //np
93
- if (stream.match("np~")) {
94
- return chain(inBlock("meta", "~/np~"));
95
- }
96
- break;
97
- }
98
-
99
- //start of line types
100
- if (sol) {
101
- switch (ch) {
102
- case "!": //header at start of line
103
- if (stream.match('!!!!!')) {
104
- return chain(inLine("header string"));
105
- } else if (stream.match('!!!!')) {
106
- return chain(inLine("header string"));
107
- } else if (stream.match('!!!')) {
108
- return chain(inLine("header string"));
109
- } else if (stream.match('!!')) {
110
- return chain(inLine("header string"));
111
- } else {
112
- return chain(inLine("header string"));
113
- }
114
- break;
115
- case "*": //unordered list line item, or <li /> at start of line
116
- case "#": //ordered list line item, or <li /> at start of line
117
- case "+": //ordered list line item, or <li /> at start of line
118
- return chain(inLine("tw-listitem bracket"));
119
- break;
120
- }
121
- }
122
-
123
- //stream.eatWhile(/[&{]/); was eating up plugins, turned off to act less like html and more like tiki
124
- return null;
125
- }
126
-
127
- var indentUnit = config.indentUnit;
2
+ function inBlock(style, terminator, returnTokenizer) {
3
+ return function(stream, state) {
4
+ while (!stream.eol()) {
5
+ if (stream.match(terminator)) {
6
+ state.tokenize = inText;
7
+ break;
8
+ }
9
+ stream.next();
10
+ }
128
11
 
129
- // Return variables for tokenizers
130
- var pluginName, type;
131
- function inPlugin(stream, state) {
132
- var ch = stream.next();
133
- var peek = stream.peek();
134
-
135
- if (ch == "}") {
136
- state.tokenize = inText;
137
- //type = ch == ")" ? "endPlugin" : "selfclosePlugin"; inPlugin
138
- return "tag";
139
- } else if (ch == "(" || ch == ")") {
140
- return "bracket";
141
- } else if (ch == "=") {
142
- type = "equals";
143
-
144
- if (peek == ">") {
145
- ch = stream.next();
146
- peek = stream.peek();
147
- }
148
-
149
- //here we detect values directly after equal character with no quotes
150
- if (!/[\'\"]/.test(peek)) {
151
- state.tokenize = inAttributeNoQuote();
152
- }
153
- //end detect values
154
-
155
- return "operator";
156
- } else if (/[\'\"]/.test(ch)) {
157
- state.tokenize = inAttribute(ch);
158
- return state.tokenize(stream, state);
159
- } else {
160
- stream.eatWhile(/[^\s\u00a0=\"\'\/?]/);
161
- return "keyword";
162
- }
163
- }
12
+ if (returnTokenizer) state.tokenize = returnTokenizer;
164
13
 
165
- function inAttribute(quote) {
166
- return function(stream, state) {
167
- while (!stream.eol()) {
168
- if (stream.next() == quote) {
169
- state.tokenize = inPlugin;
170
- break;
171
- }
172
- }
173
- return "string";
174
- };
175
- }
176
-
177
- function inAttributeNoQuote() {
178
- return function(stream, state) {
179
- while (!stream.eol()) {
180
- var ch = stream.next();
181
- var peek = stream.peek();
182
- if (ch == " " || ch == "," || /[ )}]/.test(peek)) {
183
- state.tokenize = inPlugin;
184
- break;
185
- }
186
- }
187
- return "string";
188
- };
189
- }
14
+ return style;
15
+ };
16
+ }
190
17
 
191
- var curState, setStyle;
192
- function pass() {
193
- for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
194
- }
195
-
196
- function cont() {
197
- pass.apply(null, arguments);
198
- return true;
199
- }
18
+ function inLine(style) {
19
+ return function(stream, state) {
20
+ while(!stream.eol()) {
21
+ stream.next();
22
+ }
23
+ state.tokenize = inText;
24
+ return style;
25
+ };
26
+ }
200
27
 
201
- function pushContext(pluginName, startOfLine) {
202
- var noIndent = curState.context && curState.context.noIndent;
203
- curState.context = {
204
- prev: curState.context,
205
- pluginName: pluginName,
206
- indent: curState.indented,
207
- startOfLine: startOfLine,
208
- noIndent: noIndent
209
- };
210
- }
211
-
212
- function popContext() {
213
- if (curState.context) curState.context = curState.context.prev;
214
- }
28
+ function inText(stream, state) {
29
+ function chain(parser) {
30
+ state.tokenize = parser;
31
+ return parser(stream, state);
32
+ }
215
33
 
216
- function element(type) {
217
- if (type == "openPlugin") {curState.pluginName = pluginName; return cont(attributes, endplugin(curState.startOfLine));}
218
- else if (type == "closePlugin") {
219
- var err = false;
220
- if (curState.context) {
221
- err = curState.context.pluginName != pluginName;
222
- popContext();
223
- } else {
224
- err = true;
225
- }
226
- if (err) setStyle = "error";
227
- return cont(endcloseplugin(err));
228
- }
229
- else if (type == "string") {
230
- if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata");
231
- if (curState.tokenize == inText) popContext();
232
- return cont();
233
- }
234
- else return cont();
235
- }
236
-
237
- function endplugin(startOfLine) {
238
- return function(type) {
239
- if (
240
- type == "selfclosePlugin" ||
241
- type == "endPlugin"
242
- )
243
- return cont();
244
- if (type == "endPlugin") {pushContext(curState.pluginName, startOfLine); return cont();}
245
- return cont();
246
- };
247
- }
248
-
249
- function endcloseplugin(err) {
250
- return function(type) {
251
- if (err) setStyle = "error";
252
- if (type == "endPlugin") return cont();
253
- return pass();
254
- };
255
- }
34
+ var sol = stream.sol();
35
+ var ch = stream.next();
256
36
 
257
- function attributes(type) {
258
- if (type == "keyword") {setStyle = "attribute"; return cont(attributes);}
259
- if (type == "equals") return cont(attvalue, attributes);
260
- return pass();
261
- }
262
- function attvalue(type) {
263
- if (type == "keyword") {setStyle = "string"; return cont();}
264
- if (type == "string") return cont(attvaluemaybe);
265
- return pass();
266
- }
267
- function attvaluemaybe(type) {
268
- if (type == "string") return cont(attvaluemaybe);
269
- else return pass();
270
- }
271
- return {
272
- startState: function() {
273
- return {tokenize: inText, cc: [], indented: 0, startOfLine: true, pluginName: null, context: null};
274
- },
275
- token: function(stream, state) {
276
- if (stream.sol()) {
277
- state.startOfLine = true;
278
- state.indented = stream.indentation();
279
- }
280
- if (stream.eatSpace()) return null;
37
+ //non start of line
38
+ switch (ch) { //switch is generally much faster than if, so it is used here
39
+ case "{": //plugin
40
+ stream.eat("/");
41
+ stream.eatSpace();
42
+ var tagName = "";
43
+ var c;
44
+ while ((c = stream.eat(/[^\s\u00a0=\"\'\/?(}]/))) tagName += c;
45
+ state.tokenize = inPlugin;
46
+ return "tag";
47
+ break;
48
+ case "_": //bold
49
+ if (stream.eat("_")) {
50
+ return chain(inBlock("strong", "__", inText));
51
+ }
52
+ break;
53
+ case "'": //italics
54
+ if (stream.eat("'")) {
55
+ // Italic text
56
+ return chain(inBlock("em", "''", inText));
57
+ }
58
+ break;
59
+ case "(":// Wiki Link
60
+ if (stream.eat("(")) {
61
+ return chain(inBlock("variable-2", "))", inText));
62
+ }
63
+ break;
64
+ case "[":// Weblink
65
+ return chain(inBlock("variable-3", "]", inText));
66
+ break;
67
+ case "|": //table
68
+ if (stream.eat("|")) {
69
+ return chain(inBlock("comment", "||"));
70
+ }
71
+ break;
72
+ case "-":
73
+ if (stream.eat("=")) {//titleBar
74
+ return chain(inBlock("header string", "=-", inText));
75
+ } else if (stream.eat("-")) {//deleted
76
+ return chain(inBlock("error tw-deleted", "--", inText));
77
+ }
78
+ break;
79
+ case "=": //underline
80
+ if (stream.match("==")) {
81
+ return chain(inBlock("tw-underline", "===", inText));
82
+ }
83
+ break;
84
+ case ":":
85
+ if (stream.eat(":")) {
86
+ return chain(inBlock("comment", "::"));
87
+ }
88
+ break;
89
+ case "^": //box
90
+ return chain(inBlock("tw-box", "^"));
91
+ break;
92
+ case "~": //np
93
+ if (stream.match("np~")) {
94
+ return chain(inBlock("meta", "~/np~"));
95
+ }
96
+ break;
97
+ }
281
98
 
282
- setStyle = type = pluginName = null;
283
- var style = state.tokenize(stream, state);
284
- if ((style || type) && style != "comment") {
285
- curState = state;
286
- while (true) {
287
- var comb = state.cc.pop() || element;
288
- if (comb(type || style)) break;
289
- }
290
- }
291
- state.startOfLine = false;
292
- return setStyle || style;
293
- },
294
- indent: function(state, textAfter) {
295
- var context = state.context;
296
- if (context && context.noIndent) return 0;
297
- if (context && /^{\//.test(textAfter))
298
- context = context.prev;
299
- while (context && !context.startOfLine)
300
- context = context.prev;
301
- if (context) return context.indent + indentUnit;
302
- else return 0;
303
- },
304
- electricChars: "/"
305
- };
99
+ //start of line types
100
+ if (sol) {
101
+ switch (ch) {
102
+ case "!": //header at start of line
103
+ if (stream.match('!!!!!')) {
104
+ return chain(inLine("header string"));
105
+ } else if (stream.match('!!!!')) {
106
+ return chain(inLine("header string"));
107
+ } else if (stream.match('!!!')) {
108
+ return chain(inLine("header string"));
109
+ } else if (stream.match('!!')) {
110
+ return chain(inLine("header string"));
111
+ } else {
112
+ return chain(inLine("header string"));
113
+ }
114
+ break;
115
+ case "*": //unordered list line item, or <li /> at start of line
116
+ case "#": //ordered list line item, or <li /> at start of line
117
+ case "+": //ordered list line item, or <li /> at start of line
118
+ return chain(inLine("tw-listitem bracket"));
119
+ break;
120
+ }
121
+ }
122
+
123
+ //stream.eatWhile(/[&{]/); was eating up plugins, turned off to act less like html and more like tiki
124
+ return null;
125
+ }
126
+
127
+ var indentUnit = config.indentUnit;
128
+
129
+ // Return variables for tokenizers
130
+ var pluginName, type;
131
+ function inPlugin(stream, state) {
132
+ var ch = stream.next();
133
+ var peek = stream.peek();
134
+
135
+ if (ch == "}") {
136
+ state.tokenize = inText;
137
+ //type = ch == ")" ? "endPlugin" : "selfclosePlugin"; inPlugin
138
+ return "tag";
139
+ } else if (ch == "(" || ch == ")") {
140
+ return "bracket";
141
+ } else if (ch == "=") {
142
+ type = "equals";
143
+
144
+ if (peek == ">") {
145
+ ch = stream.next();
146
+ peek = stream.peek();
147
+ }
148
+
149
+ //here we detect values directly after equal character with no quotes
150
+ if (!/[\'\"]/.test(peek)) {
151
+ state.tokenize = inAttributeNoQuote();
152
+ }
153
+ //end detect values
154
+
155
+ return "operator";
156
+ } else if (/[\'\"]/.test(ch)) {
157
+ state.tokenize = inAttribute(ch);
158
+ return state.tokenize(stream, state);
159
+ } else {
160
+ stream.eatWhile(/[^\s\u00a0=\"\'\/?]/);
161
+ return "keyword";
162
+ }
163
+ }
164
+
165
+ function inAttribute(quote) {
166
+ return function(stream, state) {
167
+ while (!stream.eol()) {
168
+ if (stream.next() == quote) {
169
+ state.tokenize = inPlugin;
170
+ break;
171
+ }
172
+ }
173
+ return "string";
174
+ };
175
+ }
176
+
177
+ function inAttributeNoQuote() {
178
+ return function(stream, state) {
179
+ while (!stream.eol()) {
180
+ var ch = stream.next();
181
+ var peek = stream.peek();
182
+ if (ch == " " || ch == "," || /[ )}]/.test(peek)) {
183
+ state.tokenize = inPlugin;
184
+ break;
185
+ }
186
+ }
187
+ return "string";
188
+ };
189
+ }
190
+
191
+ var curState, setStyle;
192
+ function pass() {
193
+ for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
194
+ }
195
+
196
+ function cont() {
197
+ pass.apply(null, arguments);
198
+ return true;
199
+ }
200
+
201
+ function pushContext(pluginName, startOfLine) {
202
+ var noIndent = curState.context && curState.context.noIndent;
203
+ curState.context = {
204
+ prev: curState.context,
205
+ pluginName: pluginName,
206
+ indent: curState.indented,
207
+ startOfLine: startOfLine,
208
+ noIndent: noIndent
209
+ };
210
+ }
211
+
212
+ function popContext() {
213
+ if (curState.context) curState.context = curState.context.prev;
214
+ }
215
+
216
+ function element(type) {
217
+ if (type == "openPlugin") {curState.pluginName = pluginName; return cont(attributes, endplugin(curState.startOfLine));}
218
+ else if (type == "closePlugin") {
219
+ var err = false;
220
+ if (curState.context) {
221
+ err = curState.context.pluginName != pluginName;
222
+ popContext();
223
+ } else {
224
+ err = true;
225
+ }
226
+ if (err) setStyle = "error";
227
+ return cont(endcloseplugin(err));
228
+ }
229
+ else if (type == "string") {
230
+ if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata");
231
+ if (curState.tokenize == inText) popContext();
232
+ return cont();
233
+ }
234
+ else return cont();
235
+ }
236
+
237
+ function endplugin(startOfLine) {
238
+ return function(type) {
239
+ if (
240
+ type == "selfclosePlugin" ||
241
+ type == "endPlugin"
242
+ )
243
+ return cont();
244
+ if (type == "endPlugin") {pushContext(curState.pluginName, startOfLine); return cont();}
245
+ return cont();
246
+ };
247
+ }
248
+
249
+ function endcloseplugin(err) {
250
+ return function(type) {
251
+ if (err) setStyle = "error";
252
+ if (type == "endPlugin") return cont();
253
+ return pass();
254
+ };
255
+ }
256
+
257
+ function attributes(type) {
258
+ if (type == "keyword") {setStyle = "attribute"; return cont(attributes);}
259
+ if (type == "equals") return cont(attvalue, attributes);
260
+ return pass();
261
+ }
262
+ function attvalue(type) {
263
+ if (type == "keyword") {setStyle = "string"; return cont();}
264
+ if (type == "string") return cont(attvaluemaybe);
265
+ return pass();
266
+ }
267
+ function attvaluemaybe(type) {
268
+ if (type == "string") return cont(attvaluemaybe);
269
+ else return pass();
270
+ }
271
+ return {
272
+ startState: function() {
273
+ return {tokenize: inText, cc: [], indented: 0, startOfLine: true, pluginName: null, context: null};
274
+ },
275
+ token: function(stream, state) {
276
+ if (stream.sol()) {
277
+ state.startOfLine = true;
278
+ state.indented = stream.indentation();
279
+ }
280
+ if (stream.eatSpace()) return null;
281
+
282
+ setStyle = type = pluginName = null;
283
+ var style = state.tokenize(stream, state);
284
+ if ((style || type) && style != "comment") {
285
+ curState = state;
286
+ while (true) {
287
+ var comb = state.cc.pop() || element;
288
+ if (comb(type || style)) break;
289
+ }
290
+ }
291
+ state.startOfLine = false;
292
+ return setStyle || style;
293
+ },
294
+ indent: function(state, textAfter) {
295
+ var context = state.context;
296
+ if (context && context.noIndent) return 0;
297
+ if (context && /^{\//.test(textAfter))
298
+ context = context.prev;
299
+ while (context && !context.startOfLine)
300
+ context = context.prev;
301
+ if (context) return context.indent + indentUnit;
302
+ else return 0;
303
+ },
304
+ electricChars: "/"
305
+ };
306
306
  });
307
307
 
308
- //I figure, why not
309
308
  CodeMirror.defineMIME("text/tiki", "tiki");