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