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