blogelator 0.1.0 → 0.1.1

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.
@@ -0,0 +1,353 @@
1
+ /**
2
+ * Link to the project's GitHub page:
3
+ * https://github.com/pickhardt/coffeescript-codemirror-mode
4
+ */
5
+ CodeMirror.defineMode("coffeescript", function(conf) {
6
+ var ERRORCLASS = "error";
7
+
8
+ function wordRegexp(words) {
9
+ return new RegExp("^((" + words.join(")|(") + "))\\b");
10
+ }
11
+
12
+ var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?)/;
13
+ var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
14
+ var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
15
+ var properties = /^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/;
16
+
17
+ var wordOperators = wordRegexp(["and", "or", "not",
18
+ "is", "isnt", "in",
19
+ "instanceof", "typeof"]);
20
+ var indentKeywords = ["for", "while", "loop", "if", "unless", "else",
21
+ "switch", "try", "catch", "finally", "class"];
22
+ var commonKeywords = ["break", "by", "continue", "debugger", "delete",
23
+ "do", "in", "of", "new", "return", "then",
24
+ "this", "throw", "when", "until"];
25
+
26
+ var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
27
+
28
+ indentKeywords = wordRegexp(indentKeywords);
29
+
30
+
31
+ var stringPrefixes = /^('{3}|\"{3}|['\"])/;
32
+ var regexPrefixes = /^(\/{3}|\/)/;
33
+ var commonConstants = ["Infinity", "NaN", "undefined", "null", "true", "false", "on", "off", "yes", "no"];
34
+ var constants = wordRegexp(commonConstants);
35
+
36
+ // Tokenizers
37
+ function tokenBase(stream, state) {
38
+ // Handle scope changes
39
+ if (stream.sol()) {
40
+ if (state.scope.align === null) state.scope.align = false;
41
+ var scopeOffset = state.scope.offset;
42
+ if (stream.eatSpace()) {
43
+ var lineOffset = stream.indentation();
44
+ if (lineOffset > scopeOffset && state.scope.type == "coffee") {
45
+ return "indent";
46
+ } else if (lineOffset < scopeOffset) {
47
+ return "dedent";
48
+ }
49
+ return null;
50
+ } else {
51
+ if (scopeOffset > 0) {
52
+ dedent(stream, state);
53
+ }
54
+ }
55
+ }
56
+ if (stream.eatSpace()) {
57
+ return null;
58
+ }
59
+
60
+ var ch = stream.peek();
61
+
62
+ // Handle docco title comment (single line)
63
+ if (stream.match("####")) {
64
+ stream.skipToEnd();
65
+ return "comment";
66
+ }
67
+
68
+ // Handle multi line comments
69
+ if (stream.match("###")) {
70
+ state.tokenize = longComment;
71
+ return state.tokenize(stream, state);
72
+ }
73
+
74
+ // Single line comment
75
+ if (ch === "#") {
76
+ stream.skipToEnd();
77
+ return "comment";
78
+ }
79
+
80
+ // Handle number literals
81
+ if (stream.match(/^-?[0-9\.]/, false)) {
82
+ var floatLiteral = false;
83
+ // Floats
84
+ if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) {
85
+ floatLiteral = true;
86
+ }
87
+ if (stream.match(/^-?\d+\.\d*/)) {
88
+ floatLiteral = true;
89
+ }
90
+ if (stream.match(/^-?\.\d+/)) {
91
+ floatLiteral = true;
92
+ }
93
+
94
+ if (floatLiteral) {
95
+ // prevent from getting extra . on 1..
96
+ if (stream.peek() == "."){
97
+ stream.backUp(1);
98
+ }
99
+ return "number";
100
+ }
101
+ // Integers
102
+ var intLiteral = false;
103
+ // Hex
104
+ if (stream.match(/^-?0x[0-9a-f]+/i)) {
105
+ intLiteral = true;
106
+ }
107
+ // Decimal
108
+ if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) {
109
+ intLiteral = true;
110
+ }
111
+ // Zero by itself with no other piece of number.
112
+ if (stream.match(/^-?0(?![\dx])/i)) {
113
+ intLiteral = true;
114
+ }
115
+ if (intLiteral) {
116
+ return "number";
117
+ }
118
+ }
119
+
120
+ // Handle strings
121
+ if (stream.match(stringPrefixes)) {
122
+ state.tokenize = tokenFactory(stream.current(), false, "string");
123
+ return state.tokenize(stream, state);
124
+ }
125
+ // Handle regex literals
126
+ if (stream.match(regexPrefixes)) {
127
+ if (stream.current() != "/" || stream.match(/^.*\//, false)) { // prevent highlight of division
128
+ state.tokenize = tokenFactory(stream.current(), true, "string-2");
129
+ return state.tokenize(stream, state);
130
+ } else {
131
+ stream.backUp(1);
132
+ }
133
+ }
134
+
135
+ // Handle operators and delimiters
136
+ if (stream.match(operators) || stream.match(wordOperators)) {
137
+ return "operator";
138
+ }
139
+ if (stream.match(delimiters)) {
140
+ return "punctuation";
141
+ }
142
+
143
+ if (stream.match(constants)) {
144
+ return "atom";
145
+ }
146
+
147
+ if (stream.match(keywords)) {
148
+ return "keyword";
149
+ }
150
+
151
+ if (stream.match(identifiers)) {
152
+ return "variable";
153
+ }
154
+
155
+ if (stream.match(properties)) {
156
+ return "property";
157
+ }
158
+
159
+ // Handle non-detected items
160
+ stream.next();
161
+ return ERRORCLASS;
162
+ }
163
+
164
+ function tokenFactory(delimiter, singleline, outclass) {
165
+ return function(stream, state) {
166
+ while (!stream.eol()) {
167
+ stream.eatWhile(/[^'"\/\\]/);
168
+ if (stream.eat("\\")) {
169
+ stream.next();
170
+ if (singleline && stream.eol()) {
171
+ return outclass;
172
+ }
173
+ } else if (stream.match(delimiter)) {
174
+ state.tokenize = tokenBase;
175
+ return outclass;
176
+ } else {
177
+ stream.eat(/['"\/]/);
178
+ }
179
+ }
180
+ if (singleline) {
181
+ if (conf.mode.singleLineStringErrors) {
182
+ outclass = ERRORCLASS;
183
+ } else {
184
+ state.tokenize = tokenBase;
185
+ }
186
+ }
187
+ return outclass;
188
+ };
189
+ }
190
+
191
+ function longComment(stream, state) {
192
+ while (!stream.eol()) {
193
+ stream.eatWhile(/[^#]/);
194
+ if (stream.match("###")) {
195
+ state.tokenize = tokenBase;
196
+ break;
197
+ }
198
+ stream.eatWhile("#");
199
+ }
200
+ return "comment";
201
+ }
202
+
203
+ function indent(stream, state, type) {
204
+ type = type || "coffee";
205
+ var offset = 0, align = false, alignOffset = null;
206
+ for (var scope = state.scope; scope; scope = scope.prev) {
207
+ if (scope.type === "coffee") {
208
+ offset = scope.offset + conf.indentUnit;
209
+ break;
210
+ }
211
+ }
212
+ if (type !== "coffee") {
213
+ align = null;
214
+ alignOffset = stream.column() + stream.current().length;
215
+ } else if (state.scope.align) {
216
+ state.scope.align = false;
217
+ }
218
+ state.scope = {
219
+ offset: offset,
220
+ type: type,
221
+ prev: state.scope,
222
+ align: align,
223
+ alignOffset: alignOffset
224
+ };
225
+ }
226
+
227
+ function dedent(stream, state) {
228
+ if (!state.scope.prev) return;
229
+ if (state.scope.type === "coffee") {
230
+ var _indent = stream.indentation();
231
+ var matched = false;
232
+ for (var scope = state.scope; scope; scope = scope.prev) {
233
+ if (_indent === scope.offset) {
234
+ matched = true;
235
+ break;
236
+ }
237
+ }
238
+ if (!matched) {
239
+ return true;
240
+ }
241
+ while (state.scope.prev && state.scope.offset !== _indent) {
242
+ state.scope = state.scope.prev;
243
+ }
244
+ return false;
245
+ } else {
246
+ state.scope = state.scope.prev;
247
+ return false;
248
+ }
249
+ }
250
+
251
+ function tokenLexer(stream, state) {
252
+ var style = state.tokenize(stream, state);
253
+ var current = stream.current();
254
+
255
+ // Handle "." connected identifiers
256
+ if (current === ".") {
257
+ style = state.tokenize(stream, state);
258
+ current = stream.current();
259
+ if (/^\.[\w$]+$/.test(current)) {
260
+ return "variable";
261
+ } else {
262
+ return ERRORCLASS;
263
+ }
264
+ }
265
+
266
+ // Handle scope changes.
267
+ if (current === "return") {
268
+ state.dedent += 1;
269
+ }
270
+ if (((current === "->" || current === "=>") &&
271
+ !state.lambda &&
272
+ !stream.peek())
273
+ || style === "indent") {
274
+ indent(stream, state);
275
+ }
276
+ var delimiter_index = "[({".indexOf(current);
277
+ if (delimiter_index !== -1) {
278
+ indent(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
279
+ }
280
+ if (indentKeywords.exec(current)){
281
+ indent(stream, state);
282
+ }
283
+ if (current == "then"){
284
+ dedent(stream, state);
285
+ }
286
+
287
+
288
+ if (style === "dedent") {
289
+ if (dedent(stream, state)) {
290
+ return ERRORCLASS;
291
+ }
292
+ }
293
+ delimiter_index = "])}".indexOf(current);
294
+ if (delimiter_index !== -1) {
295
+ while (state.scope.type == "coffee" && state.scope.prev)
296
+ state.scope = state.scope.prev;
297
+ if (state.scope.type == current)
298
+ state.scope = state.scope.prev;
299
+ }
300
+ if (state.dedent > 0 && stream.eol() && state.scope.type == "coffee") {
301
+ if (state.scope.prev) state.scope = state.scope.prev;
302
+ state.dedent -= 1;
303
+ }
304
+
305
+ return style;
306
+ }
307
+
308
+ var external = {
309
+ startState: function(basecolumn) {
310
+ return {
311
+ tokenize: tokenBase,
312
+ scope: {offset:basecolumn || 0, type:"coffee", prev: null, align: false},
313
+ lastToken: null,
314
+ lambda: false,
315
+ dedent: 0
316
+ };
317
+ },
318
+
319
+ token: function(stream, state) {
320
+ var fillAlign = state.scope.align === null && state.scope;
321
+ if (fillAlign && stream.sol()) fillAlign.align = false;
322
+
323
+ var style = tokenLexer(stream, state);
324
+ if (fillAlign && style && style != "comment") fillAlign.align = true;
325
+
326
+ state.lastToken = {style:style, content: stream.current()};
327
+
328
+ if (stream.eol() && stream.lambda) {
329
+ state.lambda = false;
330
+ }
331
+
332
+ return style;
333
+ },
334
+
335
+ indent: function(state, text) {
336
+ if (state.tokenize != tokenBase) return 0;
337
+ var scope = state.scope;
338
+ var closer = text && "])}".indexOf(text.charAt(0)) > -1;
339
+ if (closer) while (scope.type == "coffee" && scope.prev) scope = scope.prev;
340
+ var closes = closer && scope.type === text.charAt(0);
341
+ if (scope.align)
342
+ return scope.alignOffset - (closes ? 1 : 0);
343
+ else
344
+ return (closes ? scope.prev : scope).offset;
345
+ },
346
+
347
+ lineComment: "#",
348
+ fold: "indent"
349
+ };
350
+ return external;
351
+ });
352
+
353
+ CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
@@ -0,0 +1,693 @@
1
+ CodeMirror.defineMode("css", function(config, parserConfig) {
2
+ "use strict";
3
+
4
+ if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
5
+
6
+ var indentUnit = config.indentUnit,
7
+ tokenHooks = parserConfig.tokenHooks,
8
+ mediaTypes = parserConfig.mediaTypes || {},
9
+ mediaFeatures = parserConfig.mediaFeatures || {},
10
+ propertyKeywords = parserConfig.propertyKeywords || {},
11
+ colorKeywords = parserConfig.colorKeywords || {},
12
+ valueKeywords = parserConfig.valueKeywords || {},
13
+ fontProperties = parserConfig.fontProperties || {},
14
+ allowNested = parserConfig.allowNested;
15
+
16
+ var type, override;
17
+ function ret(style, tp) { type = tp; return style; }
18
+
19
+ // Tokenizers
20
+
21
+ function tokenBase(stream, state) {
22
+ var ch = stream.next();
23
+ if (tokenHooks[ch]) {
24
+ var result = tokenHooks[ch](stream, state);
25
+ if (result !== false) return result;
26
+ }
27
+ if (ch == "@") {
28
+ stream.eatWhile(/[\w\\\-]/);
29
+ return ret("def", stream.current());
30
+ } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
31
+ return ret(null, "compare");
32
+ } else if (ch == "\"" || ch == "'") {
33
+ state.tokenize = tokenString(ch);
34
+ return state.tokenize(stream, state);
35
+ } else if (ch == "#") {
36
+ stream.eatWhile(/[\w\\\-]/);
37
+ return ret("atom", "hash");
38
+ } else if (ch == "!") {
39
+ stream.match(/^\s*\w*/);
40
+ return ret("keyword", "important");
41
+ } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
42
+ stream.eatWhile(/[\w.%]/);
43
+ return ret("number", "unit");
44
+ } else if (ch === "-") {
45
+ if (/[\d.]/.test(stream.peek())) {
46
+ stream.eatWhile(/[\w.%]/);
47
+ return ret("number", "unit");
48
+ } else if (stream.match(/^[^-]+-/)) {
49
+ return ret("meta", "meta");
50
+ }
51
+ } else if (/[,+>*\/]/.test(ch)) {
52
+ return ret(null, "select-op");
53
+ } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
54
+ return ret("qualifier", "qualifier");
55
+ } else if (/[:;{}\[\]\(\)]/.test(ch)) {
56
+ return ret(null, ch);
57
+ } else if (ch == "u" && stream.match("rl(")) {
58
+ stream.backUp(1);
59
+ state.tokenize = tokenParenthesized;
60
+ return ret("property", "word");
61
+ } else if (/[\w\\\-]/.test(ch)) {
62
+ stream.eatWhile(/[\w\\\-]/);
63
+ return ret("property", "word");
64
+ } else {
65
+ return ret(null, null);
66
+ }
67
+ }
68
+
69
+ function tokenString(quote) {
70
+ return function(stream, state) {
71
+ var escaped = false, ch;
72
+ while ((ch = stream.next()) != null) {
73
+ if (ch == quote && !escaped) {
74
+ if (quote == ")") stream.backUp(1);
75
+ break;
76
+ }
77
+ escaped = !escaped && ch == "\\";
78
+ }
79
+ if (ch == quote || !escaped && quote != ")") state.tokenize = null;
80
+ return ret("string", "string");
81
+ };
82
+ }
83
+
84
+ function tokenParenthesized(stream, state) {
85
+ stream.next(); // Must be '('
86
+ if (!stream.match(/\s*[\"\']/, false))
87
+ state.tokenize = tokenString(")");
88
+ else
89
+ state.tokenize = null;
90
+ return ret(null, "(");
91
+ }
92
+
93
+ // Context management
94
+
95
+ function Context(type, indent, prev) {
96
+ this.type = type;
97
+ this.indent = indent;
98
+ this.prev = prev;
99
+ }
100
+
101
+ function pushContext(state, stream, type) {
102
+ state.context = new Context(type, stream.indentation() + indentUnit, state.context);
103
+ return type;
104
+ }
105
+
106
+ function popContext(state) {
107
+ state.context = state.context.prev;
108
+ return state.context.type;
109
+ }
110
+
111
+ function pass(type, stream, state) {
112
+ return states[state.context.type](type, stream, state);
113
+ }
114
+ function popAndPass(type, stream, state, n) {
115
+ for (var i = n || 1; i > 0; i--)
116
+ state.context = state.context.prev;
117
+ return pass(type, stream, state);
118
+ }
119
+
120
+ // Parser
121
+
122
+ function wordAsValue(stream) {
123
+ var word = stream.current().toLowerCase();
124
+ if (valueKeywords.hasOwnProperty(word))
125
+ override = "atom";
126
+ else if (colorKeywords.hasOwnProperty(word))
127
+ override = "keyword";
128
+ else
129
+ override = "variable";
130
+ }
131
+
132
+ var states = {};
133
+
134
+ states.top = function(type, stream, state) {
135
+ if (type == "{") {
136
+ return pushContext(state, stream, "block");
137
+ } else if (type == "}" && state.context.prev) {
138
+ return popContext(state);
139
+ } else if (type == "@media") {
140
+ return pushContext(state, stream, "media");
141
+ } else if (type == "@font-face") {
142
+ return "font_face_before";
143
+ } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
144
+ return "keyframes";
145
+ } else if (type && type.charAt(0) == "@") {
146
+ return pushContext(state, stream, "at");
147
+ } else if (type == "hash") {
148
+ override = "builtin";
149
+ } else if (type == "word") {
150
+ override = "tag";
151
+ } else if (type == "variable-definition") {
152
+ return "maybeprop";
153
+ } else if (type == "interpolation") {
154
+ return pushContext(state, stream, "interpolation");
155
+ } else if (type == ":") {
156
+ return "pseudo";
157
+ } else if (allowNested && type == "(") {
158
+ return pushContext(state, stream, "params");
159
+ }
160
+ return state.context.type;
161
+ };
162
+
163
+ states.block = function(type, stream, state) {
164
+ if (type == "word") {
165
+ if (propertyKeywords.hasOwnProperty(stream.current().toLowerCase())) {
166
+ override = "property";
167
+ return "maybeprop";
168
+ } else if (allowNested) {
169
+ override = stream.match(/^\s*:/, false) ? "property" : "tag";
170
+ return "block";
171
+ } else {
172
+ override += " error";
173
+ return "maybeprop";
174
+ }
175
+ } else if (type == "meta") {
176
+ return "block";
177
+ } else if (!allowNested && (type == "hash" || type == "qualifier")) {
178
+ override = "error";
179
+ return "block";
180
+ } else {
181
+ return states.top(type, stream, state);
182
+ }
183
+ };
184
+
185
+ states.maybeprop = function(type, stream, state) {
186
+ if (type == ":") return pushContext(state, stream, "prop");
187
+ return pass(type, stream, state);
188
+ };
189
+
190
+ states.prop = function(type, stream, state) {
191
+ if (type == ";") return popContext(state);
192
+ if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
193
+ if (type == "}" || type == "{") return popAndPass(type, stream, state);
194
+ if (type == "(") return pushContext(state, stream, "parens");
195
+
196
+ if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
197
+ override += " error";
198
+ } else if (type == "word") {
199
+ wordAsValue(stream);
200
+ } else if (type == "interpolation") {
201
+ return pushContext(state, stream, "interpolation");
202
+ }
203
+ return "prop";
204
+ };
205
+
206
+ states.propBlock = function(type, _stream, state) {
207
+ if (type == "}") return popContext(state);
208
+ if (type == "word") { override = "property"; return "maybeprop"; }
209
+ return state.context.type;
210
+ };
211
+
212
+ states.parens = function(type, stream, state) {
213
+ if (type == "{" || type == "}") return popAndPass(type, stream, state);
214
+ if (type == ")") return popContext(state);
215
+ return "parens";
216
+ };
217
+
218
+ states.pseudo = function(type, stream, state) {
219
+ if (type == "word") {
220
+ override = "variable-3";
221
+ return state.context.type;
222
+ }
223
+ return pass(type, stream, state);
224
+ };
225
+
226
+ states.media = function(type, stream, state) {
227
+ if (type == "(") return pushContext(state, stream, "media_parens");
228
+ if (type == "}") return popAndPass(type, stream, state);
229
+ if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
230
+
231
+ if (type == "word") {
232
+ var word = stream.current().toLowerCase();
233
+ if (word == "only" || word == "not" || word == "and")
234
+ override = "keyword";
235
+ else if (mediaTypes.hasOwnProperty(word))
236
+ override = "attribute";
237
+ else if (mediaFeatures.hasOwnProperty(word))
238
+ override = "property";
239
+ else
240
+ override = "error";
241
+ }
242
+ return state.context.type;
243
+ };
244
+
245
+ states.media_parens = function(type, stream, state) {
246
+ if (type == ")") return popContext(state);
247
+ if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
248
+ return states.media(type, stream, state);
249
+ };
250
+
251
+ states.font_face_before = function(type, stream, state) {
252
+ if (type == "{")
253
+ return pushContext(state, stream, "font_face");
254
+ return pass(type, stream, state);
255
+ };
256
+
257
+ states.font_face = function(type, stream, state) {
258
+ if (type == "}") return popContext(state);
259
+ if (type == "word") {
260
+ if (!fontProperties.hasOwnProperty(stream.current().toLowerCase()))
261
+ override = "error";
262
+ else
263
+ override = "property";
264
+ return "maybeprop";
265
+ }
266
+ return "font_face";
267
+ };
268
+
269
+ states.keyframes = function(type, stream, state) {
270
+ if (type == "word") { override = "variable"; return "keyframes"; }
271
+ if (type == "{") return pushContext(state, stream, "top");
272
+ return pass(type, stream, state);
273
+ };
274
+
275
+ states.at = function(type, stream, state) {
276
+ if (type == ";") return popContext(state);
277
+ if (type == "{" || type == "}") return popAndPass(type, stream, state);
278
+ if (type == "word") override = "tag";
279
+ else if (type == "hash") override = "builtin";
280
+ return "at";
281
+ };
282
+
283
+ states.interpolation = function(type, stream, state) {
284
+ if (type == "}") return popContext(state);
285
+ if (type == "{" || type == ";") return popAndPass(type, stream, state);
286
+ if (type != "variable") override = "error";
287
+ return "interpolation";
288
+ };
289
+
290
+ states.params = function(type, stream, state) {
291
+ if (type == ")") return popContext(state);
292
+ if (type == "{" || type == "}") return popAndPass(type, stream, state);
293
+ if (type == "word") wordAsValue(stream);
294
+ return "params";
295
+ };
296
+
297
+ return {
298
+ startState: function(base) {
299
+ return {tokenize: null,
300
+ state: "top",
301
+ context: new Context("top", base || 0, null)};
302
+ },
303
+
304
+ token: function(stream, state) {
305
+ if (!state.tokenize && stream.eatSpace()) return null;
306
+ var style = (state.tokenize || tokenBase)(stream, state);
307
+ if (style && typeof style == "object") {
308
+ type = style[1];
309
+ style = style[0];
310
+ }
311
+ override = style;
312
+ state.state = states[state.state](type, stream, state);
313
+ return override;
314
+ },
315
+
316
+ indent: function(state, textAfter) {
317
+ var cx = state.context, ch = textAfter && textAfter.charAt(0);
318
+ var indent = cx.indent;
319
+ if (cx.type == "prop" && ch == "}") cx = cx.prev;
320
+ if (cx.prev &&
321
+ (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") ||
322
+ ch == ")" && (cx.type == "parens" || cx.type == "params" || cx.type == "media_parens") ||
323
+ ch == "{" && (cx.type == "at" || cx.type == "media"))) {
324
+ indent = cx.indent - indentUnit;
325
+ cx = cx.prev;
326
+ }
327
+ return indent;
328
+ },
329
+
330
+ electricChars: "}",
331
+ blockCommentStart: "/*",
332
+ blockCommentEnd: "*/",
333
+ fold: "brace"
334
+ };
335
+ });
336
+
337
+ (function() {
338
+ function keySet(array) {
339
+ var keys = {};
340
+ for (var i = 0; i < array.length; ++i) {
341
+ keys[array[i]] = true;
342
+ }
343
+ return keys;
344
+ }
345
+
346
+ var mediaTypes_ = [
347
+ "all", "aural", "braille", "handheld", "print", "projection", "screen",
348
+ "tty", "tv", "embossed"
349
+ ], mediaTypes = keySet(mediaTypes_);
350
+
351
+ var mediaFeatures_ = [
352
+ "width", "min-width", "max-width", "height", "min-height", "max-height",
353
+ "device-width", "min-device-width", "max-device-width", "device-height",
354
+ "min-device-height", "max-device-height", "aspect-ratio",
355
+ "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
356
+ "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
357
+ "max-color", "color-index", "min-color-index", "max-color-index",
358
+ "monochrome", "min-monochrome", "max-monochrome", "resolution",
359
+ "min-resolution", "max-resolution", "scan", "grid"
360
+ ], mediaFeatures = keySet(mediaFeatures_);
361
+
362
+ var propertyKeywords_ = [
363
+ "align-content", "align-items", "align-self", "alignment-adjust",
364
+ "alignment-baseline", "anchor-point", "animation", "animation-delay",
365
+ "animation-direction", "animation-duration", "animation-fill-mode",
366
+ "animation-iteration-count", "animation-name", "animation-play-state",
367
+ "animation-timing-function", "appearance", "azimuth", "backface-visibility",
368
+ "background", "background-attachment", "background-clip", "background-color",
369
+ "background-image", "background-origin", "background-position",
370
+ "background-repeat", "background-size", "baseline-shift", "binding",
371
+ "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
372
+ "bookmark-target", "border", "border-bottom", "border-bottom-color",
373
+ "border-bottom-left-radius", "border-bottom-right-radius",
374
+ "border-bottom-style", "border-bottom-width", "border-collapse",
375
+ "border-color", "border-image", "border-image-outset",
376
+ "border-image-repeat", "border-image-slice", "border-image-source",
377
+ "border-image-width", "border-left", "border-left-color",
378
+ "border-left-style", "border-left-width", "border-radius", "border-right",
379
+ "border-right-color", "border-right-style", "border-right-width",
380
+ "border-spacing", "border-style", "border-top", "border-top-color",
381
+ "border-top-left-radius", "border-top-right-radius", "border-top-style",
382
+ "border-top-width", "border-width", "bottom", "box-decoration-break",
383
+ "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
384
+ "caption-side", "clear", "clip", "color", "color-profile", "column-count",
385
+ "column-fill", "column-gap", "column-rule", "column-rule-color",
386
+ "column-rule-style", "column-rule-width", "column-span", "column-width",
387
+ "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
388
+ "cue-after", "cue-before", "cursor", "direction", "display",
389
+ "dominant-baseline", "drop-initial-after-adjust",
390
+ "drop-initial-after-align", "drop-initial-before-adjust",
391
+ "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
392
+ "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
393
+ "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
394
+ "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
395
+ "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
396
+ "font-stretch", "font-style", "font-synthesis", "font-variant",
397
+ "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
398
+ "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
399
+ "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
400
+ "grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
401
+ "grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
402
+ "grid-template", "grid-template-areas", "grid-template-columns",
403
+ "grid-template-rows", "hanging-punctuation", "height", "hyphens",
404
+ "icon", "image-orientation", "image-rendering", "image-resolution",
405
+ "inline-box-align", "justify-content", "left", "letter-spacing",
406
+ "line-break", "line-height", "line-stacking", "line-stacking-ruby",
407
+ "line-stacking-shift", "line-stacking-strategy", "list-style",
408
+ "list-style-image", "list-style-position", "list-style-type", "margin",
409
+ "margin-bottom", "margin-left", "margin-right", "margin-top",
410
+ "marker-offset", "marks", "marquee-direction", "marquee-loop",
411
+ "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
412
+ "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
413
+ "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline",
414
+ "outline-color", "outline-offset", "outline-style", "outline-width",
415
+ "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
416
+ "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
417
+ "page", "page-break-after", "page-break-before", "page-break-inside",
418
+ "page-policy", "pause", "pause-after", "pause-before", "perspective",
419
+ "perspective-origin", "pitch", "pitch-range", "play-during", "position",
420
+ "presentation-level", "punctuation-trim", "quotes", "region-break-after",
421
+ "region-break-before", "region-break-inside", "region-fragment",
422
+ "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
423
+ "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
424
+ "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size",
425
+ "speak", "speak-as", "speak-header",
426
+ "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
427
+ "tab-size", "table-layout", "target", "target-name", "target-new",
428
+ "target-position", "text-align", "text-align-last", "text-decoration",
429
+ "text-decoration-color", "text-decoration-line", "text-decoration-skip",
430
+ "text-decoration-style", "text-emphasis", "text-emphasis-color",
431
+ "text-emphasis-position", "text-emphasis-style", "text-height",
432
+ "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
433
+ "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
434
+ "text-wrap", "top", "transform", "transform-origin", "transform-style",
435
+ "transition", "transition-delay", "transition-duration",
436
+ "transition-property", "transition-timing-function", "unicode-bidi",
437
+ "vertical-align", "visibility", "voice-balance", "voice-duration",
438
+ "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
439
+ "voice-volume", "volume", "white-space", "widows", "width", "word-break",
440
+ "word-spacing", "word-wrap", "z-index", "zoom",
441
+ // SVG-specific
442
+ "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
443
+ "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
444
+ "color-interpolation", "color-interpolation-filters", "color-profile",
445
+ "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
446
+ "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
447
+ "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
448
+ "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
449
+ "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
450
+ "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode"
451
+ ], propertyKeywords = keySet(propertyKeywords_);
452
+
453
+ var colorKeywords_ = [
454
+ "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
455
+ "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
456
+ "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
457
+ "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
458
+ "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
459
+ "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
460
+ "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
461
+ "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
462
+ "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
463
+ "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
464
+ "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
465
+ "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
466
+ "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
467
+ "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
468
+ "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
469
+ "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
470
+ "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
471
+ "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
472
+ "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
473
+ "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
474
+ "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
475
+ "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon",
476
+ "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
477
+ "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
478
+ "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
479
+ "whitesmoke", "yellow", "yellowgreen"
480
+ ], colorKeywords = keySet(colorKeywords_);
481
+
482
+ var valueKeywords_ = [
483
+ "above", "absolute", "activeborder", "activecaption", "afar",
484
+ "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
485
+ "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
486
+ "arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
487
+ "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
488
+ "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
489
+ "both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
490
+ "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
491
+ "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
492
+ "cell", "center", "checkbox", "circle", "cjk-earthly-branch",
493
+ "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
494
+ "col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
495
+ "content-box", "context-menu", "continuous", "copy", "cover", "crop",
496
+ "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
497
+ "decimal-leading-zero", "default", "default-button", "destination-atop",
498
+ "destination-in", "destination-out", "destination-over", "devanagari",
499
+ "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
500
+ "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
501
+ "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
502
+ "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
503
+ "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
504
+ "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
505
+ "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
506
+ "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
507
+ "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
508
+ "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
509
+ "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
510
+ "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
511
+ "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
512
+ "help", "hidden", "hide", "higher", "highlight", "highlighttext",
513
+ "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
514
+ "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
515
+ "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
516
+ "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
517
+ "italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
518
+ "landscape", "lao", "large", "larger", "left", "level", "lighter",
519
+ "line-through", "linear", "lines", "list-item", "listbox", "listitem",
520
+ "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
521
+ "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
522
+ "lower-roman", "lowercase", "ltr", "malayalam", "match",
523
+ "media-controls-background", "media-current-time-display",
524
+ "media-fullscreen-button", "media-mute-button", "media-play-button",
525
+ "media-return-to-realtime-button", "media-rewind-button",
526
+ "media-seek-back-button", "media-seek-forward-button", "media-slider",
527
+ "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
528
+ "media-volume-slider-container", "media-volume-sliderthumb", "medium",
529
+ "menu", "menulist", "menulist-button", "menulist-text",
530
+ "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
531
+ "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
532
+ "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
533
+ "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
534
+ "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
535
+ "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
536
+ "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
537
+ "painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer",
538
+ "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
539
+ "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
540
+ "relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
541
+ "ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
542
+ "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
543
+ "searchfield-cancel-button", "searchfield-decoration",
544
+ "searchfield-results-button", "searchfield-results-decoration",
545
+ "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
546
+ "single", "skip-white-space", "slide", "slider-horizontal",
547
+ "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
548
+ "small", "small-caps", "small-caption", "smaller", "solid", "somali",
549
+ "source-atop", "source-in", "source-out", "source-over", "space", "square",
550
+ "square-button", "start", "static", "status-bar", "stretch", "stroke",
551
+ "sub", "subpixel-antialiased", "super", "sw-resize", "table",
552
+ "table-caption", "table-cell", "table-column", "table-column-group",
553
+ "table-footer-group", "table-header-group", "table-row", "table-row-group",
554
+ "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
555
+ "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
556
+ "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
557
+ "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
558
+ "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
559
+ "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
560
+ "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
561
+ "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
562
+ "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
563
+ "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
564
+ "xx-large", "xx-small"
565
+ ], valueKeywords = keySet(valueKeywords_);
566
+
567
+ var fontProperties_ = [
568
+ "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
569
+ "font-stretch", "font-weight", "font-style"
570
+ ], fontProperties = keySet(fontProperties_);
571
+
572
+ var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
573
+ CodeMirror.registerHelper("hintWords", "css", allWords);
574
+
575
+ function tokenCComment(stream, state) {
576
+ var maybeEnd = false, ch;
577
+ while ((ch = stream.next()) != null) {
578
+ if (maybeEnd && ch == "/") {
579
+ state.tokenize = null;
580
+ break;
581
+ }
582
+ maybeEnd = (ch == "*");
583
+ }
584
+ return ["comment", "comment"];
585
+ }
586
+
587
+ function tokenSGMLComment(stream, state) {
588
+ if (stream.skipTo("-->")) {
589
+ stream.match("-->");
590
+ state.tokenize = null;
591
+ } else {
592
+ stream.skipToEnd();
593
+ }
594
+ return ["comment", "comment"];
595
+ }
596
+
597
+ CodeMirror.defineMIME("text/css", {
598
+ mediaTypes: mediaTypes,
599
+ mediaFeatures: mediaFeatures,
600
+ propertyKeywords: propertyKeywords,
601
+ colorKeywords: colorKeywords,
602
+ valueKeywords: valueKeywords,
603
+ fontProperties: fontProperties,
604
+ tokenHooks: {
605
+ "<": function(stream, state) {
606
+ if (!stream.match("!--")) return false;
607
+ state.tokenize = tokenSGMLComment;
608
+ return tokenSGMLComment(stream, state);
609
+ },
610
+ "/": function(stream, state) {
611
+ if (!stream.eat("*")) return false;
612
+ state.tokenize = tokenCComment;
613
+ return tokenCComment(stream, state);
614
+ }
615
+ },
616
+ name: "css"
617
+ });
618
+
619
+ CodeMirror.defineMIME("text/x-scss", {
620
+ mediaTypes: mediaTypes,
621
+ mediaFeatures: mediaFeatures,
622
+ propertyKeywords: propertyKeywords,
623
+ colorKeywords: colorKeywords,
624
+ valueKeywords: valueKeywords,
625
+ fontProperties: fontProperties,
626
+ allowNested: true,
627
+ tokenHooks: {
628
+ "/": function(stream, state) {
629
+ if (stream.eat("/")) {
630
+ stream.skipToEnd();
631
+ return ["comment", "comment"];
632
+ } else if (stream.eat("*")) {
633
+ state.tokenize = tokenCComment;
634
+ return tokenCComment(stream, state);
635
+ } else {
636
+ return ["operator", "operator"];
637
+ }
638
+ },
639
+ ":": function(stream) {
640
+ if (stream.match(/\s*{/))
641
+ return [null, "{"];
642
+ return false;
643
+ },
644
+ "$": function(stream) {
645
+ stream.match(/^[\w-]+/);
646
+ if (stream.match(/^\s*:/, false))
647
+ return ["variable-2", "variable-definition"];
648
+ return ["variable-2", "variable"];
649
+ },
650
+ "#": function(stream) {
651
+ if (!stream.eat("{")) return false;
652
+ return [null, "interpolation"];
653
+ }
654
+ },
655
+ name: "css",
656
+ helperType: "scss"
657
+ });
658
+
659
+ CodeMirror.defineMIME("text/x-less", {
660
+ mediaTypes: mediaTypes,
661
+ mediaFeatures: mediaFeatures,
662
+ propertyKeywords: propertyKeywords,
663
+ colorKeywords: colorKeywords,
664
+ valueKeywords: valueKeywords,
665
+ fontProperties: fontProperties,
666
+ allowNested: true,
667
+ tokenHooks: {
668
+ "/": function(stream, state) {
669
+ if (stream.eat("/")) {
670
+ stream.skipToEnd();
671
+ return ["comment", "comment"];
672
+ } else if (stream.eat("*")) {
673
+ state.tokenize = tokenCComment;
674
+ return tokenCComment(stream, state);
675
+ } else {
676
+ return ["operator", "operator"];
677
+ }
678
+ },
679
+ "@": function(stream) {
680
+ if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
681
+ stream.eatWhile(/[\w\\\-]/);
682
+ if (stream.match(/^\s*:/, false))
683
+ return ["variable-2", "variable-definition"];
684
+ return ["variable-2", "variable"];
685
+ },
686
+ "&": function() {
687
+ return ["atom", "atom"];
688
+ }
689
+ },
690
+ name: "css",
691
+ helperType: "less"
692
+ });
693
+ })();