You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

434 lines
18 KiB

12 months ago
  1. ace.define("ace/mode/scss_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(acequire, exports, module) {
  2. "use strict";
  3. var oop = acequire("../lib/oop");
  4. var lang = acequire("../lib/lang");
  5. var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules;
  6. var ScssHighlightRules = function() {
  7. var properties = lang.arrayToMap( (function () {
  8. var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|");
  9. var prefixProperties = ("appearance|background-clip|background-inline-policy|background-origin|" +
  10. "background-size|binding|border-bottom-colors|border-left-colors|" +
  11. "border-right-colors|border-top-colors|border-end|border-end-color|" +
  12. "border-end-style|border-end-width|border-image|border-start|" +
  13. "border-start-color|border-start-style|border-start-width|box-align|" +
  14. "box-direction|box-flex|box-flexgroup|box-ordinal-group|box-orient|" +
  15. "box-pack|box-sizing|column-count|column-gap|column-width|column-rule|" +
  16. "column-rule-width|column-rule-style|column-rule-color|float-edge|" +
  17. "font-feature-settings|font-language-override|force-broken-image-icon|" +
  18. "image-region|margin-end|margin-start|opacity|outline|outline-color|" +
  19. "outline-offset|outline-radius|outline-radius-bottomleft|" +
  20. "outline-radius-bottomright|outline-radius-topleft|outline-radius-topright|" +
  21. "outline-style|outline-width|padding-end|padding-start|stack-sizing|" +
  22. "tab-size|text-blink|text-decoration-color|text-decoration-line|" +
  23. "text-decoration-style|transform|transform-origin|transition|" +
  24. "transition-delay|transition-duration|transition-property|" +
  25. "transition-timing-function|user-focus|user-input|user-modify|user-select|" +
  26. "window-shadow|border-radius").split("|");
  27. var properties = ("azimuth|background-attachment|background-color|background-image|" +
  28. "background-position|background-repeat|background|border-bottom-color|" +
  29. "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" +
  30. "border-color|border-left-color|border-left-style|border-left-width|" +
  31. "border-left|border-right-color|border-right-style|border-right-width|" +
  32. "border-right|border-spacing|border-style|border-top-color|" +
  33. "border-top-style|border-top-width|border-top|border-width|border|bottom|" +
  34. "box-shadow|box-sizing|caption-side|clear|clip|color|content|counter-increment|" +
  35. "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" +
  36. "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" +
  37. "font-stretch|font-style|font-variant|font-weight|font|height|left|" +
  38. "letter-spacing|line-height|list-style-image|list-style-position|" +
  39. "list-style-type|list-style|margin-bottom|margin-left|margin-right|" +
  40. "margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" +
  41. "min-width|opacity|orphans|outline-color|" +
  42. "outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" +
  43. "padding-left|padding-right|padding-top|padding|page-break-after|" +
  44. "page-break-before|page-break-inside|page|pause-after|pause-before|" +
  45. "pause|pitch-range|pitch|play-during|position|quotes|richness|right|" +
  46. "size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" +
  47. "stress|table-layout|text-align|text-decoration|text-indent|" +
  48. "text-shadow|text-transform|top|unicode-bidi|vertical-align|" +
  49. "visibility|voice-family|volume|white-space|widows|width|word-spacing|" +
  50. "z-index").split("|");
  51. var ret = [];
  52. for (var i=0, ln=browserPrefix.length; i<ln; i++) {
  53. Array.prototype.push.apply(
  54. ret,
  55. (( browserPrefix[i] + prefixProperties.join("|" + browserPrefix[i]) ).split("|"))
  56. );
  57. }
  58. Array.prototype.push.apply(ret, prefixProperties);
  59. Array.prototype.push.apply(ret, properties);
  60. return ret;
  61. })() );
  62. var functions = lang.arrayToMap(
  63. ("hsl|hsla|rgb|rgba|url|attr|counter|counters|abs|adjust_color|adjust_hue|" +
  64. "alpha|join|blue|ceil|change_color|comparable|complement|darken|desaturate|" +
  65. "floor|grayscale|green|hue|if|invert|join|length|lighten|lightness|mix|" +
  66. "nth|opacify|opacity|percentage|quote|red|round|saturate|saturation|" +
  67. "scale_color|transparentize|type_of|unit|unitless|unquote").split("|")
  68. );
  69. var constants = lang.arrayToMap(
  70. ("absolute|all-scroll|always|armenian|auto|baseline|below|bidi-override|" +
  71. "block|bold|bolder|border-box|both|bottom|break-all|break-word|capitalize|center|" +
  72. "char|circle|cjk-ideographic|col-resize|collapse|content-box|crosshair|dashed|" +
  73. "decimal-leading-zero|decimal|default|disabled|disc|" +
  74. "distribute-all-lines|distribute-letter|distribute-space|" +
  75. "distribute|dotted|double|e-resize|ellipsis|fixed|georgian|groove|" +
  76. "hand|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|" +
  77. "ideograph-alpha|ideograph-numeric|ideograph-parenthesis|" +
  78. "ideograph-space|inactive|inherit|inline-block|inline|inset|inside|" +
  79. "inter-ideograph|inter-word|italic|justify|katakana-iroha|katakana|" +
  80. "keep-all|left|lighter|line-edge|line-through|line|list-item|loose|" +
  81. "lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|" +
  82. "medium|middle|move|n-resize|ne-resize|newspaper|no-drop|no-repeat|" +
  83. "nw-resize|none|normal|not-allowed|nowrap|oblique|outset|outside|" +
  84. "overline|pointer|progress|relative|repeat-x|repeat-y|repeat|right|" +
  85. "ridge|row-resize|rtl|s-resize|scroll|se-resize|separate|small-caps|" +
  86. "solid|square|static|strict|super|sw-resize|table-footer-group|" +
  87. "table-header-group|tb-rl|text-bottom|text-top|text|thick|thin|top|" +
  88. "transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|" +
  89. "vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|" +
  90. "zero").split("|")
  91. );
  92. var colors = lang.arrayToMap(
  93. ("aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|" +
  94. "blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|" +
  95. "chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|" +
  96. "darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|" +
  97. "darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|" +
  98. "darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|" +
  99. "darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|" +
  100. "dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|" +
  101. "ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|" +
  102. "hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|" +
  103. "lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|" +
  104. "lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|" +
  105. "lightsalmon|lightseagreen|lightskyblue|lightslategray|" +
  106. "lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|" +
  107. "magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|" +
  108. "mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|" +
  109. "mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|" +
  110. "moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|" +
  111. "orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|" +
  112. "papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|" +
  113. "red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|" +
  114. "seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|" +
  115. "springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|" +
  116. "wheat|white|whitesmoke|yellow|yellowgreen").split("|")
  117. );
  118. var keywords = lang.arrayToMap(
  119. ("@mixin|@extend|@include|@import|@media|@debug|@warn|@if|@for|@each|@while|@else|@font-face|@-webkit-keyframes|if|and|!default|module|def|end|declare").split("|")
  120. );
  121. var tags = lang.arrayToMap(
  122. ("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
  123. "big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
  124. "command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
  125. "figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
  126. "header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
  127. "link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
  128. "option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
  129. "small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
  130. "textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
  131. );
  132. var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
  133. this.$rules = {
  134. "start" : [
  135. {
  136. token : "comment",
  137. regex : "\\/\\/.*$"
  138. },
  139. {
  140. token : "comment", // multi line comment
  141. regex : "\\/\\*",
  142. next : "comment"
  143. }, {
  144. token : "string", // single line
  145. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  146. }, {
  147. token : "string", // multi line string start
  148. regex : '["].*\\\\$',
  149. next : "qqstring"
  150. }, {
  151. token : "string", // single line
  152. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  153. }, {
  154. token : "string", // multi line string start
  155. regex : "['].*\\\\$",
  156. next : "qstring"
  157. }, {
  158. token : "constant.numeric",
  159. regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)"
  160. }, {
  161. token : "constant.numeric", // hex6 color
  162. regex : "#[a-f0-9]{6}"
  163. }, {
  164. token : "constant.numeric", // hex3 color
  165. regex : "#[a-f0-9]{3}"
  166. }, {
  167. token : "constant.numeric",
  168. regex : numRe
  169. }, {
  170. token : ["support.function", "string", "support.function"],
  171. regex : "(url\\()(.*)(\\))"
  172. }, {
  173. token : function(value) {
  174. if (properties.hasOwnProperty(value.toLowerCase()))
  175. return "support.type";
  176. if (keywords.hasOwnProperty(value))
  177. return "keyword";
  178. else if (constants.hasOwnProperty(value))
  179. return "constant.language";
  180. else if (functions.hasOwnProperty(value))
  181. return "support.function";
  182. else if (colors.hasOwnProperty(value.toLowerCase()))
  183. return "support.constant.color";
  184. else if (tags.hasOwnProperty(value.toLowerCase()))
  185. return "variable.language";
  186. else
  187. return "text";
  188. },
  189. regex : "\\-?[@a-z_][@a-z0-9_\\-]*"
  190. }, {
  191. token : "variable",
  192. regex : "[a-z_\\-$][a-z0-9_\\-$]*\\b"
  193. }, {
  194. token: "variable.language",
  195. regex: "#[a-z0-9-_]+"
  196. }, {
  197. token: "variable.language",
  198. regex: "\\.[a-z0-9-_]+"
  199. }, {
  200. token: "variable.language",
  201. regex: ":[a-z0-9-_]+"
  202. }, {
  203. token: "constant",
  204. regex: "[a-z0-9-_]+"
  205. }, {
  206. token : "keyword.operator",
  207. regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*"
  208. }, {
  209. token : "paren.lparen",
  210. regex : "[[({]"
  211. }, {
  212. token : "paren.rparen",
  213. regex : "[\\])}]"
  214. }, {
  215. token : "text",
  216. regex : "\\s+"
  217. }, {
  218. caseInsensitive: true
  219. }
  220. ],
  221. "comment" : [
  222. {
  223. token : "comment", // closing comment
  224. regex : "\\*\\/",
  225. next : "start"
  226. }, {
  227. defaultToken : "comment"
  228. }
  229. ],
  230. "qqstring" : [
  231. {
  232. token : "string",
  233. regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
  234. next : "start"
  235. }, {
  236. token : "string",
  237. regex : '.+'
  238. }
  239. ],
  240. "qstring" : [
  241. {
  242. token : "string",
  243. regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
  244. next : "start"
  245. }, {
  246. token : "string",
  247. regex : '.+'
  248. }
  249. ]
  250. };
  251. };
  252. oop.inherits(ScssHighlightRules, TextHighlightRules);
  253. exports.ScssHighlightRules = ScssHighlightRules;
  254. });
  255. ace.define("ace/mode/sass_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/scss_highlight_rules"], function(acequire, exports, module) {
  256. "use strict";
  257. var oop = acequire("../lib/oop");
  258. var lang = acequire("../lib/lang");
  259. var ScssHighlightRules = acequire("./scss_highlight_rules").ScssHighlightRules;
  260. var SassHighlightRules = function() {
  261. ScssHighlightRules.call(this);
  262. var start = this.$rules.start;
  263. if (start[1].token == "comment") {
  264. start.splice(1, 1, {
  265. onMatch: function(value, currentState, stack) {
  266. stack.unshift(this.next, -1, value.length - 2, currentState);
  267. return "comment";
  268. },
  269. regex: /^\s*\/\*/,
  270. next: "comment"
  271. }, {
  272. token: "error.invalid",
  273. regex: "/\\*|[{;}]"
  274. }, {
  275. token: "support.type",
  276. regex: /^\s*:[\w\-]+\s/
  277. });
  278. this.$rules.comment = [
  279. {regex: /^\s*/, onMatch: function(value, currentState, stack) {
  280. if (stack[1] === -1)
  281. stack[1] = Math.max(stack[2], value.length - 1);
  282. if (value.length <= stack[1]) {stack.shift();stack.shift();stack.shift();
  283. this.next = stack.shift();
  284. return "text";
  285. } else {
  286. this.next = "";
  287. return "comment";
  288. }
  289. }, next: "start"},
  290. {defaultToken: "comment"}
  291. ];
  292. }
  293. };
  294. oop.inherits(SassHighlightRules, ScssHighlightRules);
  295. exports.SassHighlightRules = SassHighlightRules;
  296. });
  297. ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(acequire, exports, module) {
  298. "use strict";
  299. var oop = acequire("../../lib/oop");
  300. var BaseFoldMode = acequire("./fold_mode").FoldMode;
  301. var Range = acequire("../../range").Range;
  302. var FoldMode = exports.FoldMode = function() {};
  303. oop.inherits(FoldMode, BaseFoldMode);
  304. (function() {
  305. this.getFoldWidgetRange = function(session, foldStyle, row) {
  306. var range = this.indentationBlock(session, row);
  307. if (range)
  308. return range;
  309. var re = /\S/;
  310. var line = session.getLine(row);
  311. var startLevel = line.search(re);
  312. if (startLevel == -1 || line[startLevel] != "#")
  313. return;
  314. var startColumn = line.length;
  315. var maxRow = session.getLength();
  316. var startRow = row;
  317. var endRow = row;
  318. while (++row < maxRow) {
  319. line = session.getLine(row);
  320. var level = line.search(re);
  321. if (level == -1)
  322. continue;
  323. if (line[level] != "#")
  324. break;
  325. endRow = row;
  326. }
  327. if (endRow > startRow) {
  328. var endColumn = session.getLine(endRow).length;
  329. return new Range(startRow, startColumn, endRow, endColumn);
  330. }
  331. };
  332. this.getFoldWidget = function(session, foldStyle, row) {
  333. var line = session.getLine(row);
  334. var indent = line.search(/\S/);
  335. var next = session.getLine(row + 1);
  336. var prev = session.getLine(row - 1);
  337. var prevIndent = prev.search(/\S/);
  338. var nextIndent = next.search(/\S/);
  339. if (indent == -1) {
  340. session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
  341. return "";
  342. }
  343. if (prevIndent == -1) {
  344. if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
  345. session.foldWidgets[row - 1] = "";
  346. session.foldWidgets[row + 1] = "";
  347. return "start";
  348. }
  349. } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
  350. if (session.getLine(row - 2).search(/\S/) == -1) {
  351. session.foldWidgets[row - 1] = "start";
  352. session.foldWidgets[row + 1] = "";
  353. return "";
  354. }
  355. }
  356. if (prevIndent!= -1 && prevIndent < indent)
  357. session.foldWidgets[row - 1] = "start";
  358. else
  359. session.foldWidgets[row - 1] = "";
  360. if (indent < nextIndent)
  361. return "start";
  362. else
  363. return "";
  364. };
  365. }).call(FoldMode.prototype);
  366. });
  367. ace.define("ace/mode/sass",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sass_highlight_rules","ace/mode/folding/coffee"], function(acequire, exports, module) {
  368. "use strict";
  369. var oop = acequire("../lib/oop");
  370. var TextMode = acequire("./text").Mode;
  371. var SassHighlightRules = acequire("./sass_highlight_rules").SassHighlightRules;
  372. var FoldMode = acequire("./folding/coffee").FoldMode;
  373. var Mode = function() {
  374. this.HighlightRules = SassHighlightRules;
  375. this.foldingRules = new FoldMode();
  376. this.$behaviour = this.$defaultBehaviour;
  377. };
  378. oop.inherits(Mode, TextMode);
  379. (function() {
  380. this.lineCommentStart = "//";
  381. this.$id = "ace/mode/sass";
  382. }).call(Mode.prototype);
  383. exports.Mode = Mode;
  384. });