less.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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/less/less",[],()=>{
  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/less/less.ts
  17. var less_exports = {};
  18. __export(less_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: ".less",
  57. 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])))*",
  58. identifierPlus: "-?-?([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: [
  67. { include: "@nestedJSBegin" },
  68. ["[ \\t\\r\\n]+", ""],
  69. { include: "@comments" },
  70. { include: "@keyword" },
  71. { include: "@strings" },
  72. { include: "@numbers" },
  73. ["[*_]?[a-zA-Z\\-\\s]+(?=:.*(;|(\\\\$)))", "attribute.name", "@attribute"],
  74. ["url(\\-prefix)?\\(", { token: "tag", next: "@urldeclaration" }],
  75. ["[{}()\\[\\]]", "@brackets"],
  76. ["[,:;]", "delimiter"],
  77. ["#@identifierPlus", "tag.id"],
  78. ["&", "tag"],
  79. ["\\.@identifierPlus(?=\\()", "tag.class", "@attribute"],
  80. ["\\.@identifierPlus", "tag.class"],
  81. ["@identifierPlus", "tag"],
  82. { include: "@operators" },
  83. ["@(@identifier(?=[:,\\)]))", "variable", "@attribute"],
  84. ["@(@identifier)", "variable"],
  85. ["@", "key", "@atRules"]
  86. ],
  87. nestedJSBegin: [
  88. ["``", "delimiter.backtick"],
  89. [
  90. "`",
  91. {
  92. token: "delimiter.backtick",
  93. next: "@nestedJSEnd",
  94. nextEmbedded: "text/javascript"
  95. }
  96. ]
  97. ],
  98. nestedJSEnd: [
  99. [
  100. "`",
  101. {
  102. token: "delimiter.backtick",
  103. next: "@pop",
  104. nextEmbedded: "@pop"
  105. }
  106. ]
  107. ],
  108. operators: [["[<>=\\+\\-\\*\\/\\^\\|\\~]", "operator"]],
  109. keyword: [
  110. [
  111. "(@[\\s]*import|![\\s]*important|true|false|when|iscolor|isnumber|isstring|iskeyword|isurl|ispixel|ispercentage|isem|hue|saturation|lightness|alpha|lighten|darken|saturate|desaturate|fadein|fadeout|fade|spin|mix|round|ceil|floor|percentage)\\b",
  112. "keyword"
  113. ]
  114. ],
  115. urldeclaration: [
  116. { include: "@strings" },
  117. ["[^)\r\n]+", "string"],
  118. ["\\)", { token: "tag", next: "@pop" }]
  119. ],
  120. attribute: [
  121. { include: "@nestedJSBegin" },
  122. { include: "@comments" },
  123. { include: "@strings" },
  124. { include: "@numbers" },
  125. { include: "@keyword" },
  126. ["[a-zA-Z\\-]+(?=\\()", "attribute.value", "@attribute"],
  127. [">", "operator", "@pop"],
  128. ["@identifier", "attribute.value"],
  129. { include: "@operators" },
  130. ["@(@identifier)", "variable"],
  131. ["[)\\}]", "@brackets", "@pop"],
  132. ["[{}()\\[\\]>]", "@brackets"],
  133. ["[;]", "delimiter", "@pop"],
  134. ["[,=:]", "delimiter"],
  135. ["\\s", ""],
  136. [".", "attribute.value"]
  137. ],
  138. comments: [
  139. ["\\/\\*", "comment", "@comment"],
  140. ["\\/\\/+.*", "comment"]
  141. ],
  142. comment: [
  143. ["\\*\\/", "comment", "@pop"],
  144. [".", "comment"]
  145. ],
  146. numbers: [
  147. ["(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?", { token: "attribute.value.number", next: "@units" }],
  148. ["#[0-9a-fA-F_]+(?!\\w)", "attribute.value.hex"]
  149. ],
  150. units: [
  151. [
  152. "(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?",
  153. "attribute.value.unit",
  154. "@pop"
  155. ]
  156. ],
  157. strings: [
  158. ['~?"', { token: "string.delimiter", next: "@stringsEndDoubleQuote" }],
  159. ["~?'", { token: "string.delimiter", next: "@stringsEndQuote" }]
  160. ],
  161. stringsEndDoubleQuote: [
  162. ['\\\\"', "string"],
  163. ['"', { token: "string.delimiter", next: "@popall" }],
  164. [".", "string"]
  165. ],
  166. stringsEndQuote: [
  167. ["\\\\'", "string"],
  168. ["'", { token: "string.delimiter", next: "@popall" }],
  169. [".", "string"]
  170. ],
  171. atRules: [
  172. { include: "@comments" },
  173. { include: "@strings" },
  174. ["[()]", "delimiter"],
  175. ["[\\{;]", "delimiter", "@pop"],
  176. [".", "key"]
  177. ]
  178. }
  179. };
  180. return less_exports;
  181. })();
  182. return moduleExports;
  183. });