css.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. CodeMirror.defineMode("css", function(config, parserConfig) {
  2. "use strict";
  3. if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
  4. var indentUnit = config.indentUnit,
  5. hooks = parserConfig.hooks || {},
  6. atMediaTypes = parserConfig.atMediaTypes || {},
  7. atMediaFeatures = parserConfig.atMediaFeatures || {},
  8. propertyKeywords = parserConfig.propertyKeywords || {},
  9. colorKeywords = parserConfig.colorKeywords || {},
  10. valueKeywords = parserConfig.valueKeywords || {},
  11. allowNested = !!parserConfig.allowNested,
  12. type = null;
  13. function ret(style, tp) { type = tp; return style; }
  14. function tokenBase(stream, state) {
  15. var ch = stream.next();
  16. if (hooks[ch]) {
  17. // result[0] is style and result[1] is type
  18. var result = hooks[ch](stream, state);
  19. if (result !== false) return result;
  20. }
  21. if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current());}
  22. else if (ch == "=") ret(null, "compare");
  23. else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
  24. else if (ch == "\"" || ch == "'") {
  25. state.tokenize = tokenString(ch);
  26. return state.tokenize(stream, state);
  27. }
  28. else if (ch == "#") {
  29. stream.eatWhile(/[\w\\\-]/);
  30. return ret("atom", "hash");
  31. }
  32. else if (ch == "!") {
  33. stream.match(/^\s*\w*/);
  34. return ret("keyword", "important");
  35. }
  36. else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
  37. stream.eatWhile(/[\w.%]/);
  38. return ret("number", "unit");
  39. }
  40. else if (ch === "-") {
  41. if (/\d/.test(stream.peek())) {
  42. stream.eatWhile(/[\w.%]/);
  43. return ret("number", "unit");
  44. } else if (stream.match(/^[^-]+-/)) {
  45. return ret("meta", "meta");
  46. }
  47. }
  48. else if (/[,+>*\/]/.test(ch)) {
  49. return ret(null, "select-op");
  50. }
  51. else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
  52. return ret("qualifier", "qualifier");
  53. }
  54. else if (ch == ":") {
  55. return ret("operator", ch);
  56. }
  57. else if (/[;{}\[\]\(\)]/.test(ch)) {
  58. return ret(null, ch);
  59. }
  60. else if (ch == "u" && stream.match("rl(")) {
  61. stream.backUp(1);
  62. state.tokenize = tokenParenthesized;
  63. return ret("property", "variable");
  64. }
  65. else {
  66. stream.eatWhile(/[\w\\\-]/);
  67. return ret("property", "variable");
  68. }
  69. }
  70. function tokenString(quote, nonInclusive) {
  71. return function(stream, state) {
  72. var escaped = false, ch;
  73. while ((ch = stream.next()) != null) {
  74. if (ch == quote && !escaped)
  75. break;
  76. escaped = !escaped && ch == "\\";
  77. }
  78. if (!escaped) {
  79. if (nonInclusive) stream.backUp(1);
  80. state.tokenize = tokenBase;
  81. }
  82. return ret("string", "string");
  83. };
  84. }
  85. function tokenParenthesized(stream, state) {
  86. stream.next(); // Must be '('
  87. if (!stream.match(/\s*[\"\']/, false))
  88. state.tokenize = tokenString(")", true);
  89. else
  90. state.tokenize = tokenBase;
  91. return ret(null, "(");
  92. }
  93. return {
  94. startState: function(base) {
  95. return {tokenize: tokenBase,
  96. baseIndent: base || 0,
  97. stack: [],
  98. lastToken: null};
  99. },
  100. token: function(stream, state) {
  101. // Use these terms when applicable (see http://www.xanthir.com/blog/b4E50)
  102. //
  103. // rule** or **ruleset:
  104. // A selector + braces combo, or an at-rule.
  105. //
  106. // declaration block:
  107. // A sequence of declarations.
  108. //
  109. // declaration:
  110. // A property + colon + value combo.
  111. //
  112. // property value:
  113. // The entire value of a property.
  114. //
  115. // component value:
  116. // A single piece of a property value. Like the 5px in
  117. // text-shadow: 0 0 5px blue;. Can also refer to things that are
  118. // multiple terms, like the 1-4 terms that make up the background-size
  119. // portion of the background shorthand.
  120. //
  121. // term:
  122. // The basic unit of author-facing CSS, like a single number (5),
  123. // dimension (5px), string ("foo"), or function. Officially defined
  124. // by the CSS 2.1 grammar (look for the 'term' production)
  125. //
  126. //
  127. // simple selector:
  128. // A single atomic selector, like a type selector, an attr selector, a
  129. // class selector, etc.
  130. //
  131. // compound selector:
  132. // One or more simple selectors without a combinator. div.example is
  133. // compound, div > .example is not.
  134. //
  135. // complex selector:
  136. // One or more compound selectors chained with combinators.
  137. //
  138. // combinator:
  139. // The parts of selectors that express relationships. There are four
  140. // currently - the space (descendant combinator), the greater-than
  141. // bracket (child combinator), the plus sign (next sibling combinator),
  142. // and the tilda (following sibling combinator).
  143. //
  144. // sequence of selectors:
  145. // One or more of the named type of selector chained with commas.
  146. state.tokenize = state.tokenize || tokenBase;
  147. if (state.tokenize == tokenBase && stream.eatSpace()) return null;
  148. var style = state.tokenize(stream, state);
  149. if (style && typeof style != "string") style = ret(style[0], style[1]);
  150. // Changing style returned based on context
  151. var context = state.stack[state.stack.length-1];
  152. if (style == "variable") {
  153. if (type == "variable-definition") state.stack.push("propertyValue");
  154. return state.lastToken = "variable-2";
  155. } else if (style == "property") {
  156. var word = stream.current().toLowerCase();
  157. if (context == "propertyValue") {
  158. if (valueKeywords.hasOwnProperty(word)) {
  159. style = "string-2";
  160. } else if (colorKeywords.hasOwnProperty(word)) {
  161. style = "keyword";
  162. } else {
  163. style = "variable-2";
  164. }
  165. } else if (context == "rule") {
  166. if (!propertyKeywords.hasOwnProperty(word)) {
  167. style += " error";
  168. }
  169. } else if (context == "block") {
  170. // if a value is present in both property, value, or color, the order
  171. // of preference is property -> color -> value
  172. if (propertyKeywords.hasOwnProperty(word)) {
  173. style = "property";
  174. } else if (colorKeywords.hasOwnProperty(word)) {
  175. style = "keyword";
  176. } else if (valueKeywords.hasOwnProperty(word)) {
  177. style = "string-2";
  178. } else {
  179. style = "tag";
  180. }
  181. } else if (!context || context == "@media{") {
  182. style = "tag";
  183. } else if (context == "@media") {
  184. if (atMediaTypes[stream.current()]) {
  185. style = "attribute"; // Known attribute
  186. } else if (/^(only|not)$/.test(word)) {
  187. style = "keyword";
  188. } else if (word == "and") {
  189. style = "error"; // "and" is only allowed in @mediaType
  190. } else if (atMediaFeatures.hasOwnProperty(word)) {
  191. style = "error"; // Known property, should be in @mediaType(
  192. } else {
  193. // Unknown, expecting keyword or attribute, assuming attribute
  194. style = "attribute error";
  195. }
  196. } else if (context == "@mediaType") {
  197. if (atMediaTypes.hasOwnProperty(word)) {
  198. style = "attribute";
  199. } else if (word == "and") {
  200. style = "operator";
  201. } else if (/^(only|not)$/.test(word)) {
  202. style = "error"; // Only allowed in @media
  203. } else {
  204. // Unknown attribute or property, but expecting property (preceded
  205. // by "and"). Should be in parentheses
  206. style = "error";
  207. }
  208. } else if (context == "@mediaType(") {
  209. if (propertyKeywords.hasOwnProperty(word)) {
  210. // do nothing, remains "property"
  211. } else if (atMediaTypes.hasOwnProperty(word)) {
  212. style = "error"; // Known property, should be in parentheses
  213. } else if (word == "and") {
  214. style = "operator";
  215. } else if (/^(only|not)$/.test(word)) {
  216. style = "error"; // Only allowed in @media
  217. } else {
  218. style += " error";
  219. }
  220. } else if (context == "@import") {
  221. style = "tag";
  222. } else {
  223. style = "error";
  224. }
  225. } else if (style == "atom") {
  226. if(!context || context == "@media{" || context == "block") {
  227. style = "builtin";
  228. } else if (context == "propertyValue") {
  229. if (!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
  230. style += " error";
  231. }
  232. } else {
  233. style = "error";
  234. }
  235. } else if (context == "@media" && type == "{") {
  236. style = "error";
  237. }
  238. // Push/pop context stack
  239. if (type == "{") {
  240. if (context == "@media" || context == "@mediaType") {
  241. state.stack[state.stack.length-1] = "@media{";
  242. }
  243. else {
  244. var newContext = allowNested ? "block" : "rule";
  245. state.stack.push(newContext);
  246. }
  247. }
  248. else if (type == "}") {
  249. if (context == "interpolation") style = "operator";
  250. state.stack.pop();
  251. if (context == "propertyValue") state.stack.pop();
  252. }
  253. else if (type == "interpolation") state.stack.push("interpolation");
  254. else if (type == "@media") state.stack.push("@media");
  255. else if (type == "@import") state.stack.push("@import");
  256. else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
  257. state.stack[state.stack.length-1] = "@mediaType";
  258. else if (context == "@mediaType" && stream.current() == ",")
  259. state.stack[state.stack.length-1] = "@media";
  260. else if (type == "(") {
  261. if (context == "@media" || context == "@mediaType") {
  262. // Make sure @mediaType is used to avoid error on {
  263. state.stack[state.stack.length-1] = "@mediaType";
  264. state.stack.push("@mediaType(");
  265. }
  266. else state.stack.push("(");
  267. }
  268. else if (type == ")") {
  269. if (context == "propertyValue") {
  270. // In @mediaType( without closing ; after propertyValue
  271. state.stack.pop();
  272. }
  273. state.stack.pop();
  274. }
  275. else if (type == ":" && state.lastToken == "property") state.stack.push("propertyValue");
  276. else if (context == "propertyValue" && type == ";") state.stack.pop();
  277. else if (context == "@import" && type == ";") state.stack.pop();
  278. return state.lastToken = style;
  279. },
  280. indent: function(state, textAfter) {
  281. var n = state.stack.length;
  282. if (/^\}/.test(textAfter))
  283. n -= state.stack[n-1] == "propertyValue" ? 2 : 1;
  284. return state.baseIndent + n * indentUnit;
  285. },
  286. electricChars: "}",
  287. blockCommentStart: "/*",
  288. blockCommentEnd: "*/",
  289. fold: "brace"
  290. };
  291. });
  292. (function() {
  293. function keySet(array) {
  294. var keys = {};
  295. for (var i = 0; i < array.length; ++i) {
  296. keys[array[i]] = true;
  297. }
  298. return keys;
  299. }
  300. var atMediaTypes = keySet([
  301. "all", "aural", "braille", "handheld", "print", "projection", "screen",
  302. "tty", "tv", "embossed"
  303. ]);
  304. var atMediaFeatures = keySet([
  305. "width", "min-width", "max-width", "height", "min-height", "max-height",
  306. "device-width", "min-device-width", "max-device-width", "device-height",
  307. "min-device-height", "max-device-height", "aspect-ratio",
  308. "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
  309. "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
  310. "max-color", "color-index", "min-color-index", "max-color-index",
  311. "monochrome", "min-monochrome", "max-monochrome", "resolution",
  312. "min-resolution", "max-resolution", "scan", "grid"
  313. ]);
  314. var propertyKeywords = keySet([
  315. "align-content", "align-items", "align-self", "alignment-adjust",
  316. "alignment-baseline", "anchor-point", "animation", "animation-delay",
  317. "animation-direction", "animation-duration", "animation-iteration-count",
  318. "animation-name", "animation-play-state", "animation-timing-function",
  319. "appearance", "azimuth", "backface-visibility", "background",
  320. "background-attachment", "background-clip", "background-color",
  321. "background-image", "background-origin", "background-position",
  322. "background-repeat", "background-size", "baseline-shift", "binding",
  323. "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
  324. "bookmark-target", "border", "border-bottom", "border-bottom-color",
  325. "border-bottom-left-radius", "border-bottom-right-radius",
  326. "border-bottom-style", "border-bottom-width", "border-collapse",
  327. "border-color", "border-image", "border-image-outset",
  328. "border-image-repeat", "border-image-slice", "border-image-source",
  329. "border-image-width", "border-left", "border-left-color",
  330. "border-left-style", "border-left-width", "border-radius", "border-right",
  331. "border-right-color", "border-right-style", "border-right-width",
  332. "border-spacing", "border-style", "border-top", "border-top-color",
  333. "border-top-left-radius", "border-top-right-radius", "border-top-style",
  334. "border-top-width", "border-width", "bottom", "box-decoration-break",
  335. "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
  336. "caption-side", "clear", "clip", "color", "color-profile", "column-count",
  337. "column-fill", "column-gap", "column-rule", "column-rule-color",
  338. "column-rule-style", "column-rule-width", "column-span", "column-width",
  339. "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
  340. "cue-after", "cue-before", "cursor", "direction", "display",
  341. "dominant-baseline", "drop-initial-after-adjust",
  342. "drop-initial-after-align", "drop-initial-before-adjust",
  343. "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
  344. "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
  345. "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
  346. "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
  347. "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
  348. "font-stretch", "font-style", "font-synthesis", "font-variant",
  349. "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
  350. "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
  351. "font-weight", "grid-cell", "grid-column", "grid-column-align",
  352. "grid-column-sizing", "grid-column-span", "grid-columns", "grid-flow",
  353. "grid-row", "grid-row-align", "grid-row-sizing", "grid-row-span",
  354. "grid-rows", "grid-template", "hanging-punctuation", "height", "hyphens",
  355. "icon", "image-orientation", "image-rendering", "image-resolution",
  356. "inline-box-align", "justify-content", "left", "letter-spacing",
  357. "line-break", "line-height", "line-stacking", "line-stacking-ruby",
  358. "line-stacking-shift", "line-stacking-strategy", "list-style",
  359. "list-style-image", "list-style-position", "list-style-type", "margin",
  360. "margin-bottom", "margin-left", "margin-right", "margin-top",
  361. "marker-offset", "marks", "marquee-direction", "marquee-loop",
  362. "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
  363. "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
  364. "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline",
  365. "outline-color", "outline-offset", "outline-style", "outline-width",
  366. "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
  367. "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
  368. "page", "page-break-after", "page-break-before", "page-break-inside",
  369. "page-policy", "pause", "pause-after", "pause-before", "perspective",
  370. "perspective-origin", "pitch", "pitch-range", "play-during", "position",
  371. "presentation-level", "punctuation-trim", "quotes", "region-break-after",
  372. "region-break-before", "region-break-inside", "region-fragment",
  373. "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
  374. "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
  375. "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size",
  376. "speak", "speak-as", "speak-header",
  377. "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
  378. "tab-size", "table-layout", "target", "target-name", "target-new",
  379. "target-position", "text-align", "text-align-last", "text-decoration",
  380. "text-decoration-color", "text-decoration-line", "text-decoration-skip",
  381. "text-decoration-style", "text-emphasis", "text-emphasis-color",
  382. "text-emphasis-position", "text-emphasis-style", "text-height",
  383. "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
  384. "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
  385. "text-wrap", "top", "transform", "transform-origin", "transform-style",
  386. "transition", "transition-delay", "transition-duration",
  387. "transition-property", "transition-timing-function", "unicode-bidi",
  388. "vertical-align", "visibility", "voice-balance", "voice-duration",
  389. "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
  390. "voice-volume", "volume", "white-space", "widows", "width", "word-break",
  391. "word-spacing", "word-wrap", "z-index", "zoom",
  392. // SVG-specific
  393. "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
  394. "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
  395. "color-interpolation", "color-interpolation-filters", "color-profile",
  396. "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
  397. "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
  398. "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
  399. "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
  400. "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
  401. "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode"
  402. ]);
  403. var colorKeywords = keySet([
  404. "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
  405. "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
  406. "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
  407. "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
  408. "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
  409. "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
  410. "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
  411. "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
  412. "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
  413. "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
  414. "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
  415. "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
  416. "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
  417. "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
  418. "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
  419. "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
  420. "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
  421. "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
  422. "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
  423. "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
  424. "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
  425. "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon",
  426. "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
  427. "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
  428. "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
  429. "whitesmoke", "yellow", "yellowgreen"
  430. ]);
  431. var valueKeywords = keySet([
  432. "above", "absolute", "activeborder", "activecaption", "afar",
  433. "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
  434. "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
  435. "arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
  436. "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
  437. "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
  438. "both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
  439. "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
  440. "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
  441. "cell", "center", "checkbox", "circle", "cjk-earthly-branch",
  442. "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
  443. "col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
  444. "content-box", "context-menu", "continuous", "copy", "cover", "crop",
  445. "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
  446. "decimal-leading-zero", "default", "default-button", "destination-atop",
  447. "destination-in", "destination-out", "destination-over", "devanagari",
  448. "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
  449. "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
  450. "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
  451. "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
  452. "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
  453. "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
  454. "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
  455. "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
  456. "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
  457. "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
  458. "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
  459. "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
  460. "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
  461. "help", "hidden", "hide", "higher", "highlight", "highlighttext",
  462. "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
  463. "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
  464. "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
  465. "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
  466. "italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
  467. "landscape", "lao", "large", "larger", "left", "level", "lighter",
  468. "line-through", "linear", "lines", "list-item", "listbox", "listitem",
  469. "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
  470. "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
  471. "lower-roman", "lowercase", "ltr", "malayalam", "match",
  472. "media-controls-background", "media-current-time-display",
  473. "media-fullscreen-button", "media-mute-button", "media-play-button",
  474. "media-return-to-realtime-button", "media-rewind-button",
  475. "media-seek-back-button", "media-seek-forward-button", "media-slider",
  476. "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
  477. "media-volume-slider-container", "media-volume-sliderthumb", "medium",
  478. "menu", "menulist", "menulist-button", "menulist-text",
  479. "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
  480. "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
  481. "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
  482. "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
  483. "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
  484. "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
  485. "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
  486. "painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer",
  487. "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
  488. "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
  489. "relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
  490. "ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
  491. "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
  492. "searchfield-cancel-button", "searchfield-decoration",
  493. "searchfield-results-button", "searchfield-results-decoration",
  494. "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
  495. "single", "skip-white-space", "slide", "slider-horizontal",
  496. "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
  497. "small", "small-caps", "small-caption", "smaller", "solid", "somali",
  498. "source-atop", "source-in", "source-out", "source-over", "space", "square",
  499. "square-button", "start", "static", "status-bar", "stretch", "stroke",
  500. "sub", "subpixel-antialiased", "super", "sw-resize", "table",
  501. "table-caption", "table-cell", "table-column", "table-column-group",
  502. "table-footer-group", "table-header-group", "table-row", "table-row-group",
  503. "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
  504. "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
  505. "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
  506. "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
  507. "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
  508. "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
  509. "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
  510. "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
  511. "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
  512. "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
  513. "xx-large", "xx-small"
  514. ]);
  515. function tokenCComment(stream, state) {
  516. var maybeEnd = false, ch;
  517. while ((ch = stream.next()) != null) {
  518. if (maybeEnd && ch == "/") {
  519. state.tokenize = null;
  520. break;
  521. }
  522. maybeEnd = (ch == "*");
  523. }
  524. return ["comment", "comment"];
  525. }
  526. CodeMirror.defineMIME("text/css", {
  527. atMediaTypes: atMediaTypes,
  528. atMediaFeatures: atMediaFeatures,
  529. propertyKeywords: propertyKeywords,
  530. colorKeywords: colorKeywords,
  531. valueKeywords: valueKeywords,
  532. hooks: {
  533. "<": function(stream, state) {
  534. function tokenSGMLComment(stream, state) {
  535. var dashes = 0, ch;
  536. while ((ch = stream.next()) != null) {
  537. if (dashes >= 2 && ch == ">") {
  538. state.tokenize = null;
  539. break;
  540. }
  541. dashes = (ch == "-") ? dashes + 1 : 0;
  542. }
  543. return ["comment", "comment"];
  544. }
  545. if (stream.eat("!")) {
  546. state.tokenize = tokenSGMLComment;
  547. return tokenSGMLComment(stream, state);
  548. }
  549. },
  550. "/": function(stream, state) {
  551. if (stream.eat("*")) {
  552. state.tokenize = tokenCComment;
  553. return tokenCComment(stream, state);
  554. }
  555. return false;
  556. }
  557. },
  558. name: "css"
  559. });
  560. CodeMirror.defineMIME("text/x-scss", {
  561. atMediaTypes: atMediaTypes,
  562. atMediaFeatures: atMediaFeatures,
  563. propertyKeywords: propertyKeywords,
  564. colorKeywords: colorKeywords,
  565. valueKeywords: valueKeywords,
  566. allowNested: true,
  567. hooks: {
  568. ":": function(stream) {
  569. if (stream.match(/\s*{/)) {
  570. return [null, "{"];
  571. }
  572. return false;
  573. },
  574. "$": function(stream) {
  575. stream.match(/^[\w-]+/);
  576. if (stream.peek() == ":") {
  577. return ["variable", "variable-definition"];
  578. }
  579. return ["variable", "variable"];
  580. },
  581. "/": function(stream, state) {
  582. if (stream.eat("/")) {
  583. stream.skipToEnd();
  584. return ["comment", "comment"];
  585. } else if (stream.eat("*")) {
  586. state.tokenize = tokenCComment;
  587. return tokenCComment(stream, state);
  588. } else {
  589. return ["operator", "operator"];
  590. }
  591. },
  592. "#": function(stream) {
  593. if (stream.eat("{")) {
  594. return ["operator", "interpolation"];
  595. } else {
  596. stream.eatWhile(/[\w\\\-]/);
  597. return ["atom", "hash"];
  598. }
  599. }
  600. },
  601. name: "css"
  602. });
  603. })();