1
0

css.js 27 KB

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