michael@0: (function(mod) { michael@0: if (typeof exports == "object" && typeof module == "object") // CommonJS michael@0: mod(require("../../lib/codemirror")); michael@0: else if (typeof define == "function" && define.amd) // AMD michael@0: define(["../../lib/codemirror"], mod); michael@0: else // Plain browser env michael@0: mod(CodeMirror); michael@0: })(function(CodeMirror) { michael@0: "use strict"; michael@0: michael@0: CodeMirror.defineMode("css", function(config, parserConfig) { michael@0: if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css"); michael@0: michael@0: var indentUnit = config.indentUnit, michael@0: tokenHooks = parserConfig.tokenHooks, michael@0: mediaTypes = parserConfig.mediaTypes || {}, michael@0: mediaFeatures = parserConfig.mediaFeatures || {}, michael@0: propertyKeywords = parserConfig.propertyKeywords || {}, michael@0: colorKeywords = parserConfig.colorKeywords || {}, michael@0: valueKeywords = parserConfig.valueKeywords || {}, michael@0: fontProperties = parserConfig.fontProperties || {}, michael@0: allowNested = parserConfig.allowNested; michael@0: michael@0: var type, override; michael@0: function ret(style, tp) { type = tp; return style; } michael@0: michael@0: // Tokenizers michael@0: michael@0: function tokenBase(stream, state) { michael@0: var ch = stream.next(); michael@0: if (tokenHooks[ch]) { michael@0: var result = tokenHooks[ch](stream, state); michael@0: if (result !== false) return result; michael@0: } michael@0: if (ch == "@") { michael@0: stream.eatWhile(/[\w\\\-]/); michael@0: return ret("def", stream.current()); michael@0: } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) { michael@0: return ret(null, "compare"); michael@0: } else if (ch == "\"" || ch == "'") { michael@0: state.tokenize = tokenString(ch); michael@0: return state.tokenize(stream, state); michael@0: } else if (ch == "#") { michael@0: stream.eatWhile(/[\w\\\-]/); michael@0: return ret("atom", "hash"); michael@0: } else if (ch == "!") { michael@0: stream.match(/^\s*\w*/); michael@0: return ret("keyword", "important"); michael@0: } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) { michael@0: stream.eatWhile(/[\w.%]/); michael@0: return ret("number", "unit"); michael@0: } else if (ch === "-") { michael@0: if (/[\d.]/.test(stream.peek())) { michael@0: stream.eatWhile(/[\w.%]/); michael@0: return ret("number", "unit"); michael@0: } else if (stream.match(/^[^-]+-/)) { michael@0: return ret("meta", "meta"); michael@0: } michael@0: } else if (/[,+>*\/]/.test(ch)) { michael@0: return ret(null, "select-op"); michael@0: } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) { michael@0: return ret("qualifier", "qualifier"); michael@0: } else if (/[:;{}\[\]\(\)]/.test(ch)) { michael@0: return ret(null, ch); michael@0: } else if (ch == "u" && stream.match("rl(")) { michael@0: stream.backUp(1); michael@0: state.tokenize = tokenParenthesized; michael@0: return ret("property", "word"); michael@0: } else if (/[\w\\\-]/.test(ch)) { michael@0: stream.eatWhile(/[\w\\\-]/); michael@0: return ret("property", "word"); michael@0: } else { michael@0: return ret(null, null); michael@0: } michael@0: } michael@0: michael@0: function tokenString(quote) { michael@0: return function(stream, state) { michael@0: var escaped = false, ch; michael@0: while ((ch = stream.next()) != null) { michael@0: if (ch == quote && !escaped) { michael@0: if (quote == ")") stream.backUp(1); michael@0: break; michael@0: } michael@0: escaped = !escaped && ch == "\\"; michael@0: } michael@0: if (ch == quote || !escaped && quote != ")") state.tokenize = null; michael@0: return ret("string", "string"); michael@0: }; michael@0: } michael@0: michael@0: function tokenParenthesized(stream, state) { michael@0: stream.next(); // Must be '(' michael@0: if (!stream.match(/\s*[\"\']/, false)) michael@0: state.tokenize = tokenString(")"); michael@0: else michael@0: state.tokenize = null; michael@0: return ret(null, "("); michael@0: } michael@0: michael@0: // Context management michael@0: michael@0: function Context(type, indent, prev) { michael@0: this.type = type; michael@0: this.indent = indent; michael@0: this.prev = prev; michael@0: } michael@0: michael@0: function pushContext(state, stream, type) { michael@0: state.context = new Context(type, stream.indentation() + indentUnit, state.context); michael@0: return type; michael@0: } michael@0: michael@0: function popContext(state) { michael@0: state.context = state.context.prev; michael@0: return state.context.type; michael@0: } michael@0: michael@0: function pass(type, stream, state) { michael@0: return states[state.context.type](type, stream, state); michael@0: } michael@0: function popAndPass(type, stream, state, n) { michael@0: for (var i = n || 1; i > 0; i--) michael@0: state.context = state.context.prev; michael@0: return pass(type, stream, state); michael@0: } michael@0: michael@0: // Parser michael@0: michael@0: function wordAsValue(stream) { michael@0: var word = stream.current().toLowerCase(); michael@0: if (valueKeywords.hasOwnProperty(word)) michael@0: override = "atom"; michael@0: else if (colorKeywords.hasOwnProperty(word)) michael@0: override = "keyword"; michael@0: else michael@0: override = "variable"; michael@0: } michael@0: michael@0: var states = {}; michael@0: michael@0: states.top = function(type, stream, state) { michael@0: if (type == "{") { michael@0: return pushContext(state, stream, "block"); michael@0: } else if (type == "}" && state.context.prev) { michael@0: return popContext(state); michael@0: } else if (type == "@media") { michael@0: return pushContext(state, stream, "media"); michael@0: } else if (type == "@font-face") { michael@0: return "font_face_before"; michael@0: } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) { michael@0: return "keyframes"; michael@0: } else if (type && type.charAt(0) == "@") { michael@0: return pushContext(state, stream, "at"); michael@0: } else if (type == "hash") { michael@0: override = "builtin"; michael@0: } else if (type == "word") { michael@0: override = "tag"; michael@0: } else if (type == "variable-definition") { michael@0: return "maybeprop"; michael@0: } else if (type == "interpolation") { michael@0: return pushContext(state, stream, "interpolation"); michael@0: } else if (type == ":") { michael@0: return "pseudo"; michael@0: } else if (allowNested && type == "(") { michael@0: return pushContext(state, stream, "params"); michael@0: } michael@0: return state.context.type; michael@0: }; michael@0: michael@0: states.block = function(type, stream, state) { michael@0: if (type == "word") { michael@0: if (propertyKeywords.hasOwnProperty(stream.current().toLowerCase())) { michael@0: override = "property"; michael@0: return "maybeprop"; michael@0: } else if (allowNested) { michael@0: override = stream.match(/^\s*:/, false) ? "property" : "tag"; michael@0: return "block"; michael@0: } else { michael@0: override += " error"; michael@0: return "maybeprop"; michael@0: } michael@0: } else if (type == "meta") { michael@0: return "block"; michael@0: } else if (!allowNested && (type == "hash" || type == "qualifier")) { michael@0: override = "error"; michael@0: return "block"; michael@0: } else { michael@0: return states.top(type, stream, state); michael@0: } michael@0: }; michael@0: michael@0: states.maybeprop = function(type, stream, state) { michael@0: if (type == ":") return pushContext(state, stream, "prop"); michael@0: return pass(type, stream, state); michael@0: }; michael@0: michael@0: states.prop = function(type, stream, state) { michael@0: if (type == ";") return popContext(state); michael@0: if (type == "{" && allowNested) return pushContext(state, stream, "propBlock"); michael@0: if (type == "}" || type == "{") return popAndPass(type, stream, state); michael@0: if (type == "(") return pushContext(state, stream, "parens"); michael@0: michael@0: if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) { michael@0: override += " error"; michael@0: } else if (type == "word") { michael@0: wordAsValue(stream); michael@0: } else if (type == "interpolation") { michael@0: return pushContext(state, stream, "interpolation"); michael@0: } michael@0: return "prop"; michael@0: }; michael@0: michael@0: states.propBlock = function(type, _stream, state) { michael@0: if (type == "}") return popContext(state); michael@0: if (type == "word") { override = "property"; return "maybeprop"; } michael@0: return state.context.type; michael@0: }; michael@0: michael@0: states.parens = function(type, stream, state) { michael@0: if (type == "{" || type == "}") return popAndPass(type, stream, state); michael@0: if (type == ")") return popContext(state); michael@0: return "parens"; michael@0: }; michael@0: michael@0: states.pseudo = function(type, stream, state) { michael@0: if (type == "word") { michael@0: override = "variable-3"; michael@0: return state.context.type; michael@0: } michael@0: return pass(type, stream, state); michael@0: }; michael@0: michael@0: states.media = function(type, stream, state) { michael@0: if (type == "(") return pushContext(state, stream, "media_parens"); michael@0: if (type == "}") return popAndPass(type, stream, state); michael@0: if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top"); michael@0: michael@0: if (type == "word") { michael@0: var word = stream.current().toLowerCase(); michael@0: if (word == "only" || word == "not" || word == "and") michael@0: override = "keyword"; michael@0: else if (mediaTypes.hasOwnProperty(word)) michael@0: override = "attribute"; michael@0: else if (mediaFeatures.hasOwnProperty(word)) michael@0: override = "property"; michael@0: else michael@0: override = "error"; michael@0: } michael@0: return state.context.type; michael@0: }; michael@0: michael@0: states.media_parens = function(type, stream, state) { michael@0: if (type == ")") return popContext(state); michael@0: if (type == "{" || type == "}") return popAndPass(type, stream, state, 2); michael@0: return states.media(type, stream, state); michael@0: }; michael@0: michael@0: states.font_face_before = function(type, stream, state) { michael@0: if (type == "{") michael@0: return pushContext(state, stream, "font_face"); michael@0: return pass(type, stream, state); michael@0: }; michael@0: michael@0: states.font_face = function(type, stream, state) { michael@0: if (type == "}") return popContext(state); michael@0: if (type == "word") { michael@0: if (!fontProperties.hasOwnProperty(stream.current().toLowerCase())) michael@0: override = "error"; michael@0: else michael@0: override = "property"; michael@0: return "maybeprop"; michael@0: } michael@0: return "font_face"; michael@0: }; michael@0: michael@0: states.keyframes = function(type, stream, state) { michael@0: if (type == "word") { override = "variable"; return "keyframes"; } michael@0: if (type == "{") return pushContext(state, stream, "top"); michael@0: return pass(type, stream, state); michael@0: }; michael@0: michael@0: states.at = function(type, stream, state) { michael@0: if (type == ";") return popContext(state); michael@0: if (type == "{" || type == "}") return popAndPass(type, stream, state); michael@0: if (type == "word") override = "tag"; michael@0: else if (type == "hash") override = "builtin"; michael@0: return "at"; michael@0: }; michael@0: michael@0: states.interpolation = function(type, stream, state) { michael@0: if (type == "}") return popContext(state); michael@0: if (type == "{" || type == ";") return popAndPass(type, stream, state); michael@0: if (type != "variable") override = "error"; michael@0: return "interpolation"; michael@0: }; michael@0: michael@0: states.params = function(type, stream, state) { michael@0: if (type == ")") return popContext(state); michael@0: if (type == "{" || type == "}") return popAndPass(type, stream, state); michael@0: if (type == "word") wordAsValue(stream); michael@0: return "params"; michael@0: }; michael@0: michael@0: return { michael@0: startState: function(base) { michael@0: return {tokenize: null, michael@0: state: "top", michael@0: context: new Context("top", base || 0, null)}; michael@0: }, michael@0: michael@0: token: function(stream, state) { michael@0: if (!state.tokenize && stream.eatSpace()) return null; michael@0: var style = (state.tokenize || tokenBase)(stream, state); michael@0: if (style && typeof style == "object") { michael@0: type = style[1]; michael@0: style = style[0]; michael@0: } michael@0: override = style; michael@0: state.state = states[state.state](type, stream, state); michael@0: return override; michael@0: }, michael@0: michael@0: indent: function(state, textAfter) { michael@0: var cx = state.context, ch = textAfter && textAfter.charAt(0); michael@0: var indent = cx.indent; michael@0: if (cx.type == "prop" && ch == "}") cx = cx.prev; michael@0: if (cx.prev && michael@0: (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") || michael@0: ch == ")" && (cx.type == "parens" || cx.type == "params" || cx.type == "media_parens") || michael@0: ch == "{" && (cx.type == "at" || cx.type == "media"))) { michael@0: indent = cx.indent - indentUnit; michael@0: cx = cx.prev; michael@0: } michael@0: return indent; michael@0: }, michael@0: michael@0: electricChars: "}", michael@0: blockCommentStart: "/*", michael@0: blockCommentEnd: "*/", michael@0: fold: "brace" michael@0: }; michael@0: }); michael@0: michael@0: function keySet(array) { michael@0: var keys = {}; michael@0: for (var i = 0; i < array.length; ++i) { michael@0: keys[array[i]] = true; michael@0: } michael@0: return keys; michael@0: } michael@0: michael@0: var mediaTypes_ = [ michael@0: "all", "aural", "braille", "handheld", "print", "projection", "screen", michael@0: "tty", "tv", "embossed" michael@0: ], mediaTypes = keySet(mediaTypes_); michael@0: michael@0: var mediaFeatures_ = [ michael@0: "width", "min-width", "max-width", "height", "min-height", "max-height", michael@0: "device-width", "min-device-width", "max-device-width", "device-height", michael@0: "min-device-height", "max-device-height", "aspect-ratio", michael@0: "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio", michael@0: "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color", michael@0: "max-color", "color-index", "min-color-index", "max-color-index", michael@0: "monochrome", "min-monochrome", "max-monochrome", "resolution", michael@0: "min-resolution", "max-resolution", "scan", "grid" michael@0: ], mediaFeatures = keySet(mediaFeatures_); michael@0: michael@0: var propertyKeywords_ = [ michael@0: "align-content", "align-items", "align-self", "alignment-adjust", michael@0: "alignment-baseline", "anchor-point", "animation", "animation-delay", michael@0: "animation-direction", "animation-duration", "animation-fill-mode", michael@0: "animation-iteration-count", "animation-name", "animation-play-state", michael@0: "animation-timing-function", "appearance", "azimuth", "backface-visibility", michael@0: "background", "background-attachment", "background-clip", "background-color", michael@0: "background-image", "background-origin", "background-position", michael@0: "background-repeat", "background-size", "baseline-shift", "binding", michael@0: "bleed", "bookmark-label", "bookmark-level", "bookmark-state", michael@0: "bookmark-target", "border", "border-bottom", "border-bottom-color", michael@0: "border-bottom-left-radius", "border-bottom-right-radius", michael@0: "border-bottom-style", "border-bottom-width", "border-collapse", michael@0: "border-color", "border-image", "border-image-outset", michael@0: "border-image-repeat", "border-image-slice", "border-image-source", michael@0: "border-image-width", "border-left", "border-left-color", michael@0: "border-left-style", "border-left-width", "border-radius", "border-right", michael@0: "border-right-color", "border-right-style", "border-right-width", michael@0: "border-spacing", "border-style", "border-top", "border-top-color", michael@0: "border-top-left-radius", "border-top-right-radius", "border-top-style", michael@0: "border-top-width", "border-width", "bottom", "box-decoration-break", michael@0: "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", michael@0: "caption-side", "clear", "clip", "color", "color-profile", "column-count", michael@0: "column-fill", "column-gap", "column-rule", "column-rule-color", michael@0: "column-rule-style", "column-rule-width", "column-span", "column-width", michael@0: "columns", "content", "counter-increment", "counter-reset", "crop", "cue", michael@0: "cue-after", "cue-before", "cursor", "direction", "display", michael@0: "dominant-baseline", "drop-initial-after-adjust", michael@0: "drop-initial-after-align", "drop-initial-before-adjust", michael@0: "drop-initial-before-align", "drop-initial-size", "drop-initial-value", michael@0: "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis", michael@0: "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", michael@0: "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings", michael@0: "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust", michael@0: "font-stretch", "font-style", "font-synthesis", "font-variant", michael@0: "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", michael@0: "font-variant-ligatures", "font-variant-numeric", "font-variant-position", michael@0: "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow", michael@0: "grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end", michael@0: "grid-column-start", "grid-row", "grid-row-end", "grid-row-start", michael@0: "grid-template", "grid-template-areas", "grid-template-columns", michael@0: "grid-template-rows", "hanging-punctuation", "height", "hyphens", michael@0: "icon", "image-orientation", "image-rendering", "image-resolution", michael@0: "inline-box-align", "justify-content", "left", "letter-spacing", michael@0: "line-break", "line-height", "line-stacking", "line-stacking-ruby", michael@0: "line-stacking-shift", "line-stacking-strategy", "list-style", michael@0: "list-style-image", "list-style-position", "list-style-type", "margin", michael@0: "margin-bottom", "margin-left", "margin-right", "margin-top", michael@0: "marker-offset", "marks", "marquee-direction", "marquee-loop", michael@0: "marquee-play-count", "marquee-speed", "marquee-style", "max-height", michael@0: "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", michael@0: "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline", michael@0: "outline-color", "outline-offset", "outline-style", "outline-width", michael@0: "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y", michael@0: "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", michael@0: "page", "page-break-after", "page-break-before", "page-break-inside", michael@0: "page-policy", "pause", "pause-after", "pause-before", "perspective", michael@0: "perspective-origin", "pitch", "pitch-range", "play-during", "position", michael@0: "presentation-level", "punctuation-trim", "quotes", "region-break-after", michael@0: "region-break-before", "region-break-inside", "region-fragment", michael@0: "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", michael@0: "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang", michael@0: "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size", michael@0: "speak", "speak-as", "speak-header", michael@0: "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", michael@0: "tab-size", "table-layout", "target", "target-name", "target-new", michael@0: "target-position", "text-align", "text-align-last", "text-decoration", michael@0: "text-decoration-color", "text-decoration-line", "text-decoration-skip", michael@0: "text-decoration-style", "text-emphasis", "text-emphasis-color", michael@0: "text-emphasis-position", "text-emphasis-style", "text-height", michael@0: "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow", michael@0: "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position", michael@0: "text-wrap", "top", "transform", "transform-origin", "transform-style", michael@0: "transition", "transition-delay", "transition-duration", michael@0: "transition-property", "transition-timing-function", "unicode-bidi", michael@0: "vertical-align", "visibility", "voice-balance", "voice-duration", michael@0: "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", michael@0: "voice-volume", "volume", "white-space", "widows", "width", "word-break", michael@0: "word-spacing", "word-wrap", "z-index", "zoom", michael@0: // SVG-specific michael@0: "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", michael@0: "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", michael@0: "color-interpolation", "color-interpolation-filters", "color-profile", michael@0: "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", michael@0: "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke", michael@0: "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", michael@0: "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering", michael@0: "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", michael@0: "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode" michael@0: ], propertyKeywords = keySet(propertyKeywords_); michael@0: michael@0: var colorKeywords_ = [ michael@0: "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", michael@0: "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", michael@0: "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", michael@0: "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", michael@0: "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", michael@0: "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", michael@0: "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", michael@0: "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", michael@0: "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", michael@0: "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", michael@0: "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", michael@0: "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", michael@0: "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", michael@0: "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", michael@0: "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", michael@0: "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", michael@0: "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", michael@0: "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", michael@0: "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", michael@0: "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", michael@0: "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", michael@0: "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", michael@0: "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", michael@0: "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", michael@0: "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", michael@0: "whitesmoke", "yellow", "yellowgreen" michael@0: ], colorKeywords = keySet(colorKeywords_); michael@0: michael@0: var valueKeywords_ = [ michael@0: "above", "absolute", "activeborder", "activecaption", "afar", michael@0: "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate", michael@0: "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", michael@0: "arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page", michael@0: "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary", michael@0: "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", michael@0: "both", "bottom", "break", "break-all", "break-word", "button", "button-bevel", michael@0: "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian", michael@0: "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", michael@0: "cell", "center", "checkbox", "circle", "cjk-earthly-branch", michael@0: "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", michael@0: "col-resize", "collapse", "column", "compact", "condensed", "contain", "content", michael@0: "content-box", "context-menu", "continuous", "copy", "cover", "crop", michael@0: "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal", michael@0: "decimal-leading-zero", "default", "default-button", "destination-atop", michael@0: "destination-in", "destination-out", "destination-over", "devanagari", michael@0: "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted", michael@0: "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out", michael@0: "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", michael@0: "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er", michael@0: "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er", michael@0: "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et", michael@0: "ethiopic-halehame-gez", "ethiopic-halehame-om-et", michael@0: "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et", michael@0: "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", michael@0: "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed", michael@0: "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes", michael@0: "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove", michael@0: "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew", michael@0: "help", "hidden", "hide", "higher", "highlight", "highlighttext", michael@0: "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore", michael@0: "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", michael@0: "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis", michael@0: "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert", michael@0: "italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer", michael@0: "landscape", "lao", "large", "larger", "left", "level", "lighter", michael@0: "line-through", "linear", "lines", "list-item", "listbox", "listitem", michael@0: "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", michael@0: "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian", michael@0: "lower-roman", "lowercase", "ltr", "malayalam", "match", michael@0: "media-controls-background", "media-current-time-display", michael@0: "media-fullscreen-button", "media-mute-button", "media-play-button", michael@0: "media-return-to-realtime-button", "media-rewind-button", michael@0: "media-seek-back-button", "media-seek-forward-button", "media-slider", michael@0: "media-sliderthumb", "media-time-remaining-display", "media-volume-slider", michael@0: "media-volume-slider-container", "media-volume-sliderthumb", "medium", michael@0: "menu", "menulist", "menulist-button", "menulist-text", michael@0: "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", michael@0: "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize", michael@0: "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", michael@0: "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", michael@0: "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote", michael@0: "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", michael@0: "outside", "outside-shape", "overlay", "overline", "padding", "padding-box", michael@0: "painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer", michael@0: "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", michael@0: "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", michael@0: "relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba", michael@0: "ridge", "right", "round", "row-resize", "rtl", "run-in", "running", michael@0: "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield", michael@0: "searchfield-cancel-button", "searchfield-decoration", michael@0: "searchfield-results-button", "searchfield-results-decoration", michael@0: "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama", michael@0: "single", "skip-white-space", "slide", "slider-horizontal", michael@0: "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", michael@0: "small", "small-caps", "small-caption", "smaller", "solid", "somali", michael@0: "source-atop", "source-in", "source-out", "source-over", "space", "square", michael@0: "square-button", "start", "static", "status-bar", "stretch", "stroke", michael@0: "sub", "subpixel-antialiased", "super", "sw-resize", "table", michael@0: "table-caption", "table-cell", "table-column", "table-column-group", michael@0: "table-footer-group", "table-header-group", "table-row", "table-row-group", michael@0: "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai", michael@0: "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight", michael@0: "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", michael@0: "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", michael@0: "transparent", "ultra-condensed", "ultra-expanded", "underline", "up", michael@0: "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", michael@0: "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", michael@0: "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", michael@0: "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", michael@0: "window", "windowframe", "windowtext", "x-large", "x-small", "xor", michael@0: "xx-large", "xx-small" michael@0: ], valueKeywords = keySet(valueKeywords_); michael@0: michael@0: var fontProperties_ = [ michael@0: "font-family", "src", "unicode-range", "font-variant", "font-feature-settings", michael@0: "font-stretch", "font-weight", "font-style" michael@0: ], fontProperties = keySet(fontProperties_); michael@0: michael@0: var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_).concat(colorKeywords_).concat(valueKeywords_); michael@0: CodeMirror.registerHelper("hintWords", "css", allWords); michael@0: michael@0: function tokenCComment(stream, state) { michael@0: var maybeEnd = false, ch; michael@0: while ((ch = stream.next()) != null) { michael@0: if (maybeEnd && ch == "/") { michael@0: state.tokenize = null; michael@0: break; michael@0: } michael@0: maybeEnd = (ch == "*"); michael@0: } michael@0: return ["comment", "comment"]; michael@0: } michael@0: michael@0: function tokenSGMLComment(stream, state) { michael@0: if (stream.skipTo("-->")) { michael@0: stream.match("-->"); michael@0: state.tokenize = null; michael@0: } else { michael@0: stream.skipToEnd(); michael@0: } michael@0: return ["comment", "comment"]; michael@0: } michael@0: michael@0: CodeMirror.defineMIME("text/css", { michael@0: mediaTypes: mediaTypes, michael@0: mediaFeatures: mediaFeatures, michael@0: propertyKeywords: propertyKeywords, michael@0: colorKeywords: colorKeywords, michael@0: valueKeywords: valueKeywords, michael@0: fontProperties: fontProperties, michael@0: tokenHooks: { michael@0: "<": function(stream, state) { michael@0: if (!stream.match("!--")) return false; michael@0: state.tokenize = tokenSGMLComment; michael@0: return tokenSGMLComment(stream, state); michael@0: }, michael@0: "/": function(stream, state) { michael@0: if (!stream.eat("*")) return false; michael@0: state.tokenize = tokenCComment; michael@0: return tokenCComment(stream, state); michael@0: } michael@0: }, michael@0: name: "css" michael@0: }); michael@0: michael@0: CodeMirror.defineMIME("text/x-scss", { michael@0: mediaTypes: mediaTypes, michael@0: mediaFeatures: mediaFeatures, michael@0: propertyKeywords: propertyKeywords, michael@0: colorKeywords: colorKeywords, michael@0: valueKeywords: valueKeywords, michael@0: fontProperties: fontProperties, michael@0: allowNested: true, michael@0: tokenHooks: { michael@0: "/": function(stream, state) { michael@0: if (stream.eat("/")) { michael@0: stream.skipToEnd(); michael@0: return ["comment", "comment"]; michael@0: } else if (stream.eat("*")) { michael@0: state.tokenize = tokenCComment; michael@0: return tokenCComment(stream, state); michael@0: } else { michael@0: return ["operator", "operator"]; michael@0: } michael@0: }, michael@0: ":": function(stream) { michael@0: if (stream.match(/\s*{/)) michael@0: return [null, "{"]; michael@0: return false; michael@0: }, michael@0: "$": function(stream) { michael@0: stream.match(/^[\w-]+/); michael@0: if (stream.match(/^\s*:/, false)) michael@0: return ["variable-2", "variable-definition"]; michael@0: return ["variable-2", "variable"]; michael@0: }, michael@0: "#": function(stream) { michael@0: if (!stream.eat("{")) return false; michael@0: return [null, "interpolation"]; michael@0: } michael@0: }, michael@0: name: "css", michael@0: helperType: "scss" michael@0: }); michael@0: michael@0: CodeMirror.defineMIME("text/x-less", { michael@0: mediaTypes: mediaTypes, michael@0: mediaFeatures: mediaFeatures, michael@0: propertyKeywords: propertyKeywords, michael@0: colorKeywords: colorKeywords, michael@0: valueKeywords: valueKeywords, michael@0: fontProperties: fontProperties, michael@0: allowNested: true, michael@0: tokenHooks: { michael@0: "/": function(stream, state) { michael@0: if (stream.eat("/")) { michael@0: stream.skipToEnd(); michael@0: return ["comment", "comment"]; michael@0: } else if (stream.eat("*")) { michael@0: state.tokenize = tokenCComment; michael@0: return tokenCComment(stream, state); michael@0: } else { michael@0: return ["operator", "operator"]; michael@0: } michael@0: }, michael@0: "@": function(stream) { michael@0: if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false; michael@0: stream.eatWhile(/[\w\\\-]/); michael@0: if (stream.match(/^\s*:/, false)) michael@0: return ["variable-2", "variable-definition"]; michael@0: return ["variable-2", "variable"]; michael@0: }, michael@0: "&": function() { michael@0: return ["atom", "atom"]; michael@0: } michael@0: }, michael@0: name: "css", michael@0: helperType: "less" michael@0: }); michael@0: michael@0: });