scss.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. define("vs/basic-languages/scss/scss",[],()=>{
  8. var moduleExports = (() => {
  9. var __defProp = Object.defineProperty;
  10. var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
  11. var __export = (target, all) => {
  12. __markAsModule(target);
  13. for (var name in all)
  14. __defProp(target, name, { get: all[name], enumerable: true });
  15. };
  16. // src/basic-languages/scss/scss.ts
  17. var scss_exports = {};
  18. __export(scss_exports, {
  19. conf: () => conf,
  20. language: () => language
  21. });
  22. var conf = {
  23. wordPattern: /(#?-?\d*\.\d\w*%?)|([@$#!.:]?[\w-?]+%?)|[@#!.]/g,
  24. comments: {
  25. blockComment: ["/*", "*/"],
  26. lineComment: "//"
  27. },
  28. brackets: [
  29. ["{", "}"],
  30. ["[", "]"],
  31. ["(", ")"]
  32. ],
  33. autoClosingPairs: [
  34. { open: "{", close: "}", notIn: ["string", "comment"] },
  35. { open: "[", close: "]", notIn: ["string", "comment"] },
  36. { open: "(", close: ")", notIn: ["string", "comment"] },
  37. { open: '"', close: '"', notIn: ["string", "comment"] },
  38. { open: "'", close: "'", notIn: ["string", "comment"] }
  39. ],
  40. surroundingPairs: [
  41. { open: "{", close: "}" },
  42. { open: "[", close: "]" },
  43. { open: "(", close: ")" },
  44. { open: '"', close: '"' },
  45. { open: "'", close: "'" }
  46. ],
  47. folding: {
  48. markers: {
  49. start: new RegExp("^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/"),
  50. end: new RegExp("^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/")
  51. }
  52. }
  53. };
  54. var language = {
  55. defaultToken: "",
  56. tokenPostfix: ".scss",
  57. ws: "[ \n\r\f]*",
  58. identifier: "-?-?([a-zA-Z]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*",
  59. brackets: [
  60. { open: "{", close: "}", token: "delimiter.curly" },
  61. { open: "[", close: "]", token: "delimiter.bracket" },
  62. { open: "(", close: ")", token: "delimiter.parenthesis" },
  63. { open: "<", close: ">", token: "delimiter.angle" }
  64. ],
  65. tokenizer: {
  66. root: [{ include: "@selector" }],
  67. selector: [
  68. { include: "@comments" },
  69. { include: "@import" },
  70. { include: "@variabledeclaration" },
  71. { include: "@warndebug" },
  72. ["[@](include)", { token: "keyword", next: "@includedeclaration" }],
  73. [
  74. "[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)",
  75. { token: "keyword", next: "@keyframedeclaration" }
  76. ],
  77. ["[@](page|content|font-face|-moz-document)", { token: "keyword" }],
  78. ["[@](charset|namespace)", { token: "keyword", next: "@declarationbody" }],
  79. ["[@](function)", { token: "keyword", next: "@functiondeclaration" }],
  80. ["[@](mixin)", { token: "keyword", next: "@mixindeclaration" }],
  81. ["url(\\-prefix)?\\(", { token: "meta", next: "@urldeclaration" }],
  82. { include: "@controlstatement" },
  83. { include: "@selectorname" },
  84. ["[&\\*]", "tag"],
  85. ["[>\\+,]", "delimiter"],
  86. ["\\[", { token: "delimiter.bracket", next: "@selectorattribute" }],
  87. ["{", { token: "delimiter.curly", next: "@selectorbody" }]
  88. ],
  89. selectorbody: [
  90. ["[*_]?@identifier@ws:(?=(\\s|\\d|[^{;}]*[;}]))", "attribute.name", "@rulevalue"],
  91. { include: "@selector" },
  92. ["[@](extend)", { token: "keyword", next: "@extendbody" }],
  93. ["[@](return)", { token: "keyword", next: "@declarationbody" }],
  94. ["}", { token: "delimiter.curly", next: "@pop" }]
  95. ],
  96. selectorname: [
  97. ["#{", { token: "meta", next: "@variableinterpolation" }],
  98. ["(\\.|#(?=[^{])|%|(@identifier)|:)+", "tag"]
  99. ],
  100. selectorattribute: [{ include: "@term" }, ["]", { token: "delimiter.bracket", next: "@pop" }]],
  101. term: [
  102. { include: "@comments" },
  103. ["url(\\-prefix)?\\(", { token: "meta", next: "@urldeclaration" }],
  104. { include: "@functioninvocation" },
  105. { include: "@numbers" },
  106. { include: "@strings" },
  107. { include: "@variablereference" },
  108. ["(and\\b|or\\b|not\\b)", "operator"],
  109. { include: "@name" },
  110. ["([<>=\\+\\-\\*\\/\\^\\|\\~,])", "operator"],
  111. [",", "delimiter"],
  112. ["!default", "literal"],
  113. ["\\(", { token: "delimiter.parenthesis", next: "@parenthizedterm" }]
  114. ],
  115. rulevalue: [
  116. { include: "@term" },
  117. ["!important", "literal"],
  118. [";", "delimiter", "@pop"],
  119. ["{", { token: "delimiter.curly", switchTo: "@nestedproperty" }],
  120. ["(?=})", { token: "", next: "@pop" }]
  121. ],
  122. nestedproperty: [
  123. ["[*_]?@identifier@ws:", "attribute.name", "@rulevalue"],
  124. { include: "@comments" },
  125. ["}", { token: "delimiter.curly", next: "@pop" }]
  126. ],
  127. warndebug: [["[@](warn|debug)", { token: "keyword", next: "@declarationbody" }]],
  128. import: [["[@](import)", { token: "keyword", next: "@declarationbody" }]],
  129. variabledeclaration: [
  130. ["\\$@identifier@ws:", "variable.decl", "@declarationbody"]
  131. ],
  132. urldeclaration: [
  133. { include: "@strings" },
  134. ["[^)\r\n]+", "string"],
  135. ["\\)", { token: "meta", next: "@pop" }]
  136. ],
  137. parenthizedterm: [
  138. { include: "@term" },
  139. ["\\)", { token: "delimiter.parenthesis", next: "@pop" }]
  140. ],
  141. declarationbody: [
  142. { include: "@term" },
  143. [";", "delimiter", "@pop"],
  144. ["(?=})", { token: "", next: "@pop" }]
  145. ],
  146. extendbody: [
  147. { include: "@selectorname" },
  148. ["!optional", "literal"],
  149. [";", "delimiter", "@pop"],
  150. ["(?=})", { token: "", next: "@pop" }]
  151. ],
  152. variablereference: [
  153. ["\\$@identifier", "variable.ref"],
  154. ["\\.\\.\\.", "operator"],
  155. ["#{", { token: "meta", next: "@variableinterpolation" }]
  156. ],
  157. variableinterpolation: [
  158. { include: "@variablereference" },
  159. ["}", { token: "meta", next: "@pop" }]
  160. ],
  161. comments: [
  162. ["\\/\\*", "comment", "@comment"],
  163. ["\\/\\/+.*", "comment"]
  164. ],
  165. comment: [
  166. ["\\*\\/", "comment", "@pop"],
  167. [".", "comment"]
  168. ],
  169. name: [["@identifier", "attribute.value"]],
  170. numbers: [
  171. ["(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?", { token: "number", next: "@units" }],
  172. ["#[0-9a-fA-F_]+(?!\\w)", "number.hex"]
  173. ],
  174. units: [
  175. [
  176. "(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?",
  177. "number",
  178. "@pop"
  179. ]
  180. ],
  181. functiondeclaration: [
  182. ["@identifier@ws\\(", { token: "meta", next: "@parameterdeclaration" }],
  183. ["{", { token: "delimiter.curly", switchTo: "@functionbody" }]
  184. ],
  185. mixindeclaration: [
  186. ["@identifier@ws\\(", { token: "meta", next: "@parameterdeclaration" }],
  187. ["@identifier", "meta"],
  188. ["{", { token: "delimiter.curly", switchTo: "@selectorbody" }]
  189. ],
  190. parameterdeclaration: [
  191. ["\\$@identifier@ws:", "variable.decl"],
  192. ["\\.\\.\\.", "operator"],
  193. [",", "delimiter"],
  194. { include: "@term" },
  195. ["\\)", { token: "meta", next: "@pop" }]
  196. ],
  197. includedeclaration: [
  198. { include: "@functioninvocation" },
  199. ["@identifier", "meta"],
  200. [";", "delimiter", "@pop"],
  201. ["(?=})", { token: "", next: "@pop" }],
  202. ["{", { token: "delimiter.curly", switchTo: "@selectorbody" }]
  203. ],
  204. keyframedeclaration: [
  205. ["@identifier", "meta"],
  206. ["{", { token: "delimiter.curly", switchTo: "@keyframebody" }]
  207. ],
  208. keyframebody: [
  209. { include: "@term" },
  210. ["{", { token: "delimiter.curly", next: "@selectorbody" }],
  211. ["}", { token: "delimiter.curly", next: "@pop" }]
  212. ],
  213. controlstatement: [
  214. [
  215. "[@](if|else|for|while|each|media)",
  216. { token: "keyword.flow", next: "@controlstatementdeclaration" }
  217. ]
  218. ],
  219. controlstatementdeclaration: [
  220. ["(in|from|through|if|to)\\b", { token: "keyword.flow" }],
  221. { include: "@term" },
  222. ["{", { token: "delimiter.curly", switchTo: "@selectorbody" }]
  223. ],
  224. functionbody: [
  225. ["[@](return)", { token: "keyword" }],
  226. { include: "@variabledeclaration" },
  227. { include: "@term" },
  228. { include: "@controlstatement" },
  229. [";", "delimiter"],
  230. ["}", { token: "delimiter.curly", next: "@pop" }]
  231. ],
  232. functioninvocation: [["@identifier\\(", { token: "meta", next: "@functionarguments" }]],
  233. functionarguments: [
  234. ["\\$@identifier@ws:", "attribute.name"],
  235. ["[,]", "delimiter"],
  236. { include: "@term" },
  237. ["\\)", { token: "meta", next: "@pop" }]
  238. ],
  239. strings: [
  240. ['~?"', { token: "string.delimiter", next: "@stringenddoublequote" }],
  241. ["~?'", { token: "string.delimiter", next: "@stringendquote" }]
  242. ],
  243. stringenddoublequote: [
  244. ["\\\\.", "string"],
  245. ['"', { token: "string.delimiter", next: "@pop" }],
  246. [".", "string"]
  247. ],
  248. stringendquote: [
  249. ["\\\\.", "string"],
  250. ["'", { token: "string.delimiter", next: "@pop" }],
  251. [".", "string"]
  252. ]
  253. }
  254. };
  255. return scss_exports;
  256. })();
  257. return moduleExports;
  258. });