109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)CodeMirror.defineMode("css", function(config, parserConfig) {
293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  "use strict";
3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)  if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)  var indentUnit = config.indentUnit || config.tabSize || 2,
793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      hooks = parserConfig.hooks || {},
893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      atMediaTypes = parserConfig.atMediaTypes || {},
993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      atMediaFeatures = parserConfig.atMediaFeatures || {},
1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      propertyKeywords = parserConfig.propertyKeywords || {},
1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      colorKeywords = parserConfig.colorKeywords || {},
1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      valueKeywords = parserConfig.valueKeywords || {},
1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      allowNested = !!parserConfig.allowNested,
1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      type = null;
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  function ret(style, tp) { type = tp; return style; }
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)  function tokenBase(stream, state) {
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    var ch = stream.next();
2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    if (hooks[ch]) {
2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      // result[0] is style and result[1] is type
2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      var result = hooks[ch](stream, state);
2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      if (result !== false) return result;
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current());}
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    else if (ch == "=") ret(null, "compare");
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    else if (ch == "\"" || ch == "'") {
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      state.tokenize = tokenString(ch);
305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return state.tokenize(stream, state);
315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    else if (ch == "#") {
335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      stream.eatWhile(/[\w\\\-]/);
345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return ret("atom", "hash");
355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    else if (ch == "!") {
375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      stream.match(/^\s*\w*/);
385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return ret("keyword", "important");
395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
4009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      stream.eatWhile(/[\w.%]/);
425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return ret("number", "unit");
435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
44926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    else if (ch === "-") {
45926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      if (/\d/.test(stream.peek())) {
46926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        stream.eatWhile(/[\w.%]/);
47926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        return ret("number", "unit");
48926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      } else if (stream.match(/^[^-]+-/)) {
49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        return ret("meta", "meta");
50926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      }
51926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
52926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    else if (/[,+>*\/]/.test(ch)) {
535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return ret(null, "select-op");
545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
55926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
56926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      return ret("qualifier", "qualifier");
57926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
58926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    else if (ch == ":") {
59926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      return ret("operator", ch);
60926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    else if (/[;{}\[\]\(\)]/.test(ch)) {
625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return ret(null, ch);
635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
64926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    else if (ch == "u" && stream.match("rl(")) {
65926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      stream.backUp(1);
66926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      state.tokenize = tokenParenthesized;
67926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      return ret("property", "variable");
68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    else {
705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      stream.eatWhile(/[\w\\\-]/);
71926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      return ret("property", "variable");
725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)  }
745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
75926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)  function tokenString(quote, nonInclusive) {
765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return function(stream, state) {
775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      var escaped = false, ch;
785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      while ((ch = stream.next()) != null) {
795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        if (ch == quote && !escaped)
805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)          break;
815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        escaped = !escaped && ch == "\\";
825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      }
83926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      if (!escaped) {
84926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        if (nonInclusive) stream.backUp(1);
85926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        state.tokenize = tokenBase;
86926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      }
875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return ret("string", "string");
885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    };
895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)  }
905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
91926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)  function tokenParenthesized(stream, state) {
92926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    stream.next(); // Must be '('
93926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (!stream.match(/\s*[\"\']/, false))
94926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      state.tokenize = tokenString(")", true);
95926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    else
96926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      state.tokenize = tokenBase;
97926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return ret(null, "(");
98926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)  }
99926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)  return {
1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    startState: function(base) {
1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return {tokenize: tokenBase,
1035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)              baseIndent: base || 0,
104591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch              stack: [],
105591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch              lastToken: null};
1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    },
1075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    token: function(stream, state) {
10993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
110926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // Use these terms when applicable (see http://www.xanthir.com/blog/b4E50)
11193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
112926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // rule** or **ruleset:
113926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // A selector + braces combo, or an at-rule.
11493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
115926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // declaration block:
116926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // A sequence of declarations.
11793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
118926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // declaration:
119926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // A property + colon + value combo.
12093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
121926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // property value:
122926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // The entire value of a property.
12393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
124926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // component value:
125926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // A single piece of a property value. Like the 5px in
126926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // text-shadow: 0 0 5px blue;. Can also refer to things that are
127926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // multiple terms, like the 1-4 terms that make up the background-size
128926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // portion of the background shorthand.
12993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
130926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // term:
131926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // The basic unit of author-facing CSS, like a single number (5),
132926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // dimension (5px), string ("foo"), or function. Officially defined
133926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      //  by the CSS 2.1 grammar (look for the 'term' production)
13493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
13593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
136926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // simple selector:
137926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // A single atomic selector, like a type selector, an attr selector, a
138926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // class selector, etc.
13993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
140926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // compound selector:
141926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // One or more simple selectors without a combinator. div.example is
142926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // compound, div > .example is not.
14393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
144926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // complex selector:
145926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // One or more compound selectors chained with combinators.
14693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
147926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // combinator:
148926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // The parts of selectors that express relationships. There are four
149926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // currently - the space (descendant combinator), the greater-than
150926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // bracket (child combinator), the plus sign (next sibling combinator),
151926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // and the tilda (following sibling combinator).
15293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      //
153926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // sequence of selectors:
154926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // One or more of the named type of selector chained with commas.
155926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
15693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      state.tokenize = state.tokenize || tokenBase;
157926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      if (state.tokenize == tokenBase && stream.eatSpace()) return null;
1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      var style = state.tokenize(stream, state);
15993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      if (style && typeof style != "string") style = ret(style[0], style[1]);
1605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
161926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // Changing style returned based on context
1625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      var context = state.stack[state.stack.length-1];
16393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      if (style == "variable") {
16493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        if (type == "variable-definition") state.stack.push("propertyValue");
165591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch        return state.lastToken = "variable-2";
16693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      } else if (style == "property") {
16793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        var word = stream.current().toLowerCase();
16893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        if (context == "propertyValue") {
16993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          if (valueKeywords.hasOwnProperty(word)) {
170926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "string-2";
17193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (colorKeywords.hasOwnProperty(word)) {
172926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "keyword";
173926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          } else {
174926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "variable-2";
175926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          }
176926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else if (context == "rule") {
17793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          if (!propertyKeywords.hasOwnProperty(word)) {
178926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style += " error";
179926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          }
18093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        } else if (context == "block") {
18193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          // if a value is present in both property, value, or color, the order
18293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          // of preference is property -> color -> value
18393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          if (propertyKeywords.hasOwnProperty(word)) {
18493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)            style = "property";
18593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (colorKeywords.hasOwnProperty(word)) {
18693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)            style = "keyword";
18793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (valueKeywords.hasOwnProperty(word)) {
18893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)            style = "string-2";
18993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else {
19093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)            style = "tag";
19193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          }
192926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else if (!context || context == "@media{") {
193926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          style = "tag";
194926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else if (context == "@media") {
195926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          if (atMediaTypes[stream.current()]) {
196926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "attribute"; // Known attribute
19793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (/^(only|not)$/.test(word)) {
198926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "keyword";
19993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (word == "and") {
200926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "error"; // "and" is only allowed in @mediaType
20193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (atMediaFeatures.hasOwnProperty(word)) {
202926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "error"; // Known property, should be in @mediaType(
203926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          } else {
204926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            // Unknown, expecting keyword or attribute, assuming attribute
205926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "attribute error";
206926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          }
207926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else if (context == "@mediaType") {
20893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          if (atMediaTypes.hasOwnProperty(word)) {
209926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "attribute";
21093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (word == "and") {
211926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "operator";
21293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (/^(only|not)$/.test(word)) {
213926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "error"; // Only allowed in @media
214926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          } else {
215926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            // Unknown attribute or property, but expecting property (preceded
216926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            // by "and"). Should be in parentheses
217926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "error";
218926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          }
219926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else if (context == "@mediaType(") {
22093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          if (propertyKeywords.hasOwnProperty(word)) {
221926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            // do nothing, remains "property"
22293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (atMediaTypes.hasOwnProperty(word)) {
223926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "error"; // Known property, should be in parentheses
22493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (word == "and") {
225926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "operator";
22693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          } else if (/^(only|not)$/.test(word)) {
227926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style = "error"; // Only allowed in @media
228926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          } else {
229926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style += " error";
230926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          }
23193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        } else if (context == "@import") {
23293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          style = "tag";
233926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else {
234926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          style = "error";
235926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        }
236926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      } else if (style == "atom") {
23793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        if(!context || context == "@media{" || context == "block") {
238926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          style = "builtin";
239926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else if (context == "propertyValue") {
240926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          if (!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
241926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)            style += " error";
242926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          }
243926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else {
244926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          style = "error";
245926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        }
246926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      } else if (context == "@media" && type == "{") {
247926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        style = "error";
2485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      }
2495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
250926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      // Push/pop context stack
2515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      if (type == "{") {
252926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        if (context == "@media" || context == "@mediaType") {
253926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)          state.stack[state.stack.length-1] = "@media{";
254926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        }
25593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        else {
25693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          var newContext = allowNested ? "block" : "rule";
25793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          state.stack.push(newContext);
25893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        }
259926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      }
260926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      else if (type == "}") {
26109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        if (context == "interpolation") style = "operator";
26209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        // Pop off end of array until { is reached
26309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        while(state.stack.length){
26409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          var removed = state.stack.pop();
26509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          if(removed.indexOf("{") > -1 || removed == "block" || removed == "rule"){
26609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)            break;
26709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          }
26809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        }
2695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      }
27093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      else if (type == "interpolation") state.stack.push("interpolation");
2715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      else if (type == "@media") state.stack.push("@media");
27293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      else if (type == "@import") state.stack.push("@import");
273926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
27409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        state.stack[state.stack.length-1] = "@mediaType";
27509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      else if (context == "@mediaType" && stream.current() == ",")
27609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        state.stack[state.stack.length-1] = "@media";
27709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      else if (type == "(") {
27809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        if (context == "@media" || context == "@mediaType") {
27909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          // Make sure @mediaType is used to avoid error on {
28009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          state.stack[state.stack.length-1] = "@mediaType";
28109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          state.stack.push("@mediaType(");
28209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        }
28309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        else state.stack.push("(");
28409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      }
28509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      else if (type == ")") {
28609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        // Pop off end of array until ( is reached
28709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        while(state.stack.length){
28809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          var removed = state.stack.pop();
28909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          if(removed.indexOf("(") > -1){
29009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)            break;
29109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          }
29209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        }
29309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      }
294591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch      else if (type == ":" && state.lastToken == "property") state.stack.push("propertyValue");
295926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)      else if (context == "propertyValue" && type == ";") state.stack.pop();
29693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      else if (context == "@import" && type == ";") state.stack.pop();
29709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
298591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch      return state.lastToken = style;
2995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    },
3005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    indent: function(state, textAfter) {
3025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      var n = state.stack.length;
3035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      if (/^\}/.test(textAfter))
30409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        n -= state.stack[n-1] == "propertyValue" ? 2 : 1;
3055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      return state.baseIndent + n * indentUnit;
3065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    },
3075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
30893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    electricChars: "}",
30993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    blockCommentStart: "/*",
31009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    blockCommentEnd: "*/",
31109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    fold: "brace"
3125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)  };
3135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)});
3145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
31593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)(function() {
31693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  function keySet(array) {
31793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    var keys = {};
31893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    for (var i = 0; i < array.length; ++i) {
31993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      keys[array[i]] = true;
32093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
32193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    return keys;
32293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  }
32393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
32493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  var atMediaTypes = keySet([
32593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "all", "aural", "braille", "handheld", "print", "projection", "screen",
32693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "tty", "tv", "embossed"
32793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  ]);
32893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
32993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  var atMediaFeatures = keySet([
33093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "width", "min-width", "max-width", "height", "min-height", "max-height",
33193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "device-width", "min-device-width", "max-device-width", "device-height",
33293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "min-device-height", "max-device-height", "aspect-ratio",
33393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
33493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
33593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "max-color", "color-index", "min-color-index", "max-color-index",
33693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "monochrome", "min-monochrome", "max-monochrome", "resolution",
33793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "min-resolution", "max-resolution", "scan", "grid"
33893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  ]);
33993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
34093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  var propertyKeywords = keySet([
34193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "align-content", "align-items", "align-self", "alignment-adjust",
34293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "alignment-baseline", "anchor-point", "animation", "animation-delay",
34393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "animation-direction", "animation-duration", "animation-iteration-count",
34493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "animation-name", "animation-play-state", "animation-timing-function",
34593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "appearance", "azimuth", "backface-visibility", "background",
34693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "background-attachment", "background-clip", "background-color",
34793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "background-image", "background-origin", "background-position",
34893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "background-repeat", "background-size", "baseline-shift", "binding",
34993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
35093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "bookmark-target", "border", "border-bottom", "border-bottom-color",
35193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-bottom-left-radius", "border-bottom-right-radius",
35293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-bottom-style", "border-bottom-width", "border-collapse",
35393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-color", "border-image", "border-image-outset",
35493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-image-repeat", "border-image-slice", "border-image-source",
35593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-image-width", "border-left", "border-left-color",
35693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-left-style", "border-left-width", "border-radius", "border-right",
35793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-right-color", "border-right-style", "border-right-width",
35893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-spacing", "border-style", "border-top", "border-top-color",
35993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-top-left-radius", "border-top-right-radius", "border-top-style",
36093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "border-top-width", "border-width", "bottom", "box-decoration-break",
36193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
36293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "caption-side", "clear", "clip", "color", "color-profile", "column-count",
36393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "column-fill", "column-gap", "column-rule", "column-rule-color",
36493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "column-rule-style", "column-rule-width", "column-span", "column-width",
36593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
36693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "cue-after", "cue-before", "cursor", "direction", "display",
36793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "dominant-baseline", "drop-initial-after-adjust",
36893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "drop-initial-after-align", "drop-initial-before-adjust",
36993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
37093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
37193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
37209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
37309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
37493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "font-stretch", "font-style", "font-synthesis", "font-variant",
37593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
37693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
37793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "font-weight", "grid-cell", "grid-column", "grid-column-align",
37893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "grid-column-sizing", "grid-column-span", "grid-columns", "grid-flow",
37993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "grid-row", "grid-row-align", "grid-row-sizing", "grid-row-span",
38093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "grid-rows", "grid-template", "hanging-punctuation", "height", "hyphens",
38193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "icon", "image-orientation", "image-rendering", "image-resolution",
38293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "inline-box-align", "justify-content", "left", "letter-spacing",
38393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "line-break", "line-height", "line-stacking", "line-stacking-ruby",
38493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "line-stacking-shift", "line-stacking-strategy", "list-style",
38593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "list-style-image", "list-style-position", "list-style-type", "margin",
38693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "margin-bottom", "margin-left", "margin-right", "margin-top",
38793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "marker-offset", "marks", "marquee-direction", "marquee-loop",
38893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
38993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
39093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline",
39193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "outline-color", "outline-offset", "outline-style", "outline-width",
39293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
39393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
39493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "page", "page-break-after", "page-break-before", "page-break-inside",
39593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "page-policy", "pause", "pause-after", "pause-before", "perspective",
39693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "perspective-origin", "pitch", "pitch-range", "play-during", "position",
39709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "presentation-level", "punctuation-trim", "quotes", "region-break-after",
39809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "region-break-before", "region-break-inside", "region-fragment",
39909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
40009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
40109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size",
40209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "speak", "speak-as", "speak-header",
40393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
40493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "tab-size", "table-layout", "target", "target-name", "target-new",
40593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "target-position", "text-align", "text-align-last", "text-decoration",
40693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "text-decoration-color", "text-decoration-line", "text-decoration-skip",
40793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "text-decoration-style", "text-emphasis", "text-emphasis-color",
40893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "text-emphasis-position", "text-emphasis-style", "text-height",
40909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
41009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
41193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "text-wrap", "top", "transform", "transform-origin", "transform-style",
41293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "transition", "transition-delay", "transition-duration",
41393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "transition-property", "transition-timing-function", "unicode-bidi",
41493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "vertical-align", "visibility", "voice-balance", "voice-duration",
41593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
41693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "voice-volume", "volume", "white-space", "widows", "width", "word-break",
41709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "word-spacing", "word-wrap", "z-index", "zoom",
41893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // SVG-specific
41993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
42093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
42193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "color-interpolation", "color-interpolation-filters", "color-profile",
42293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
42393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
42493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
42593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
42693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
42793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode"
42893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  ]);
42993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
43093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  var colorKeywords = keySet([
431591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
432591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
433591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
434591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
435591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
436591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
437591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
438591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
439591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
44009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
441591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
442591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
443591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
444591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
445591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
446591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
447591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
448591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
449591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
450591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
451591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
452591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon",
453591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
454591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
455591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
456591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "whitesmoke", "yellow", "yellowgreen"
45793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  ]);
45893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
45993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  var valueKeywords = keySet([
46093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "above", "absolute", "activeborder", "activecaption", "afar",
46193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
46293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
46309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
46409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
46509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
46609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
46793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
46893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
46993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "cell", "center", "checkbox", "circle", "cjk-earthly-branch",
47093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
47109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
47293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "content-box", "context-menu", "continuous", "copy", "cover", "crop",
47393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
47493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "decimal-leading-zero", "default", "default-button", "destination-atop",
47593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "destination-in", "destination-out", "destination-over", "devanagari",
47693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
47793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
47809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
47993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
48093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
48193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
48293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
48393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
48493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
48593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
48693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
48793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
48893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
48993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "help", "hidden", "hide", "higher", "highlight", "highlighttext",
49093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
49193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
49293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
49393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
49409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
49593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "landscape", "lao", "large", "larger", "left", "level", "lighter",
49693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "line-through", "linear", "lines", "list-item", "listbox", "listitem",
49793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
49893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
49993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "lower-roman", "lowercase", "ltr", "malayalam", "match",
50093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "media-controls-background", "media-current-time-display",
50193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "media-fullscreen-button", "media-mute-button", "media-play-button",
50293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "media-return-to-realtime-button", "media-rewind-button",
50393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "media-seek-back-button", "media-seek-forward-button", "media-slider",
50493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
50593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "media-volume-slider-container", "media-volume-sliderthumb", "medium",
50693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "menu", "menulist", "menulist-button", "menulist-text",
50793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
50893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
50993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
51093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
51193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
51293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
51309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
51409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer",
51509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
51609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
51709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    "relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
51893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
51993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
52093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "searchfield-cancel-button", "searchfield-decoration",
52193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "searchfield-results-button", "searchfield-results-decoration",
52293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
52393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "single", "skip-white-space", "slide", "slider-horizontal",
52493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
52593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "small", "small-caps", "small-caption", "smaller", "solid", "somali",
52693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "source-atop", "source-in", "source-out", "source-over", "space", "square",
52793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "square-button", "start", "static", "status-bar", "stretch", "stroke",
52893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "sub", "subpixel-antialiased", "super", "sw-resize", "table",
52993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "table-caption", "table-cell", "table-column", "table-column-group",
53093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "table-footer-group", "table-header-group", "table-row", "table-row-group",
53193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
53293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
53393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
53493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
53593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
53693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
53793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
53893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
539591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
54093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
54193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    "xx-large", "xx-small"
54293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  ]);
54393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
54493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  function tokenCComment(stream, state) {
54593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    var maybeEnd = false, ch;
54693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    while ((ch = stream.next()) != null) {
54793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      if (maybeEnd && ch == "/") {
54893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        state.tokenize = null;
54993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        break;
55093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      }
55193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      maybeEnd = (ch == "*");
55293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
55393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    return ["comment", "comment"];
55493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  }
55593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
55693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  CodeMirror.defineMIME("text/css", {
55793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    atMediaTypes: atMediaTypes,
55893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    atMediaFeatures: atMediaFeatures,
55993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    propertyKeywords: propertyKeywords,
56093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    colorKeywords: colorKeywords,
56193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    valueKeywords: valueKeywords,
56293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    hooks: {
56393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      "<": function(stream, state) {
56493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        function tokenSGMLComment(stream, state) {
56593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          var dashes = 0, ch;
56693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          while ((ch = stream.next()) != null) {
56793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)            if (dashes >= 2 && ch == ">") {
56893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)              state.tokenize = null;
56993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)              break;
57093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)            }
57193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)            dashes = (ch == "-") ? dashes + 1 : 0;
57293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          }
57393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return ["comment", "comment"];
57493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        }
57593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        if (stream.eat("!")) {
57693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          state.tokenize = tokenSGMLComment;
57793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return tokenSGMLComment(stream, state);
57893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        }
57993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      },
58093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      "/": function(stream, state) {
58193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        if (stream.eat("*")) {
58293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          state.tokenize = tokenCComment;
58393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return tokenCComment(stream, state);
58493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        }
58593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return false;
58693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      }
58793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    },
58809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    name: "css"
58993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  });
59093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
59193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  CodeMirror.defineMIME("text/x-scss", {
59293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    atMediaTypes: atMediaTypes,
59393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    atMediaFeatures: atMediaFeatures,
59493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    propertyKeywords: propertyKeywords,
59593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    colorKeywords: colorKeywords,
59693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    valueKeywords: valueKeywords,
59793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    allowNested: true,
59893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    hooks: {
59909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      ":": function(stream) {
60009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        if (stream.match(/\s*{/)) {
60109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          return [null, "{"];
60209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        }
60309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        return false;
60409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      },
60593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      "$": function(stream) {
60693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        stream.match(/^[\w-]+/);
60793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        if (stream.peek() == ":") {
60893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return ["variable", "variable-definition"];
60993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        }
61093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return ["variable", "variable"];
61193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      },
61209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      ",": function(stream, state) {
61309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        if (state.stack[state.stack.length - 1] == "propertyValue" && stream.match(/^ *\$/, false)) {
61409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)          return ["operator", ";"];
61509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        }
61609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)      },
61793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      "/": function(stream, state) {
61893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        if (stream.eat("/")) {
61993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          stream.skipToEnd();
62093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return ["comment", "comment"];
62193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        } else if (stream.eat("*")) {
62293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          state.tokenize = tokenCComment;
62393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return tokenCComment(stream, state);
62493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        } else {
62593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return ["operator", "operator"];
62693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        }
62793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      },
62893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      "#": function(stream) {
62993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        if (stream.eat("{")) {
63093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return ["operator", "interpolation"];
63193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        } else {
63293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          stream.eatWhile(/[\w\\\-]/);
63393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)          return ["atom", "hash"];
63493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        }
63593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)      }
63693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    },
63709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    name: "css"
63893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)  });
63993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)})();
640