less.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. define('vs/basic-languages/less/less',["require", "exports"], function (require, exports) {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.language = exports.conf = void 0;
  9. exports.conf = {
  10. wordPattern: /(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,
  11. comments: {
  12. blockComment: ['/*', '*/'],
  13. lineComment: '//'
  14. },
  15. brackets: [
  16. ['{', '}'],
  17. ['[', ']'],
  18. ['(', ')']
  19. ],
  20. autoClosingPairs: [
  21. { open: '{', close: '}', notIn: ['string', 'comment'] },
  22. { open: '[', close: ']', notIn: ['string', 'comment'] },
  23. { open: '(', close: ')', notIn: ['string', 'comment'] },
  24. { open: '"', close: '"', notIn: ['string', 'comment'] },
  25. { open: "'", close: "'", notIn: ['string', 'comment'] }
  26. ],
  27. surroundingPairs: [
  28. { open: '{', close: '}' },
  29. { open: '[', close: ']' },
  30. { open: '(', close: ')' },
  31. { open: '"', close: '"' },
  32. { open: "'", close: "'" }
  33. ],
  34. folding: {
  35. markers: {
  36. start: new RegExp('^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/'),
  37. end: new RegExp('^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/')
  38. }
  39. }
  40. };
  41. exports.language = {
  42. defaultToken: '',
  43. tokenPostfix: '.less',
  44. 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])))*',
  45. 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])))*',
  46. brackets: [
  47. { open: '{', close: '}', token: 'delimiter.curly' },
  48. { open: '[', close: ']', token: 'delimiter.bracket' },
  49. { open: '(', close: ')', token: 'delimiter.parenthesis' },
  50. { open: '<', close: '>', token: 'delimiter.angle' }
  51. ],
  52. tokenizer: {
  53. root: [
  54. { include: '@nestedJSBegin' },
  55. ['[ \\t\\r\\n]+', ''],
  56. { include: '@comments' },
  57. { include: '@keyword' },
  58. { include: '@strings' },
  59. { include: '@numbers' },
  60. ['[*_]?[a-zA-Z\\-\\s]+(?=:.*(;|(\\\\$)))', 'attribute.name', '@attribute'],
  61. ['url(\\-prefix)?\\(', { token: 'tag', next: '@urldeclaration' }],
  62. ['[{}()\\[\\]]', '@brackets'],
  63. ['[,:;]', 'delimiter'],
  64. ['#@identifierPlus', 'tag.id'],
  65. ['&', 'tag'],
  66. ['\\.@identifierPlus(?=\\()', 'tag.class', '@attribute'],
  67. ['\\.@identifierPlus', 'tag.class'],
  68. ['@identifierPlus', 'tag'],
  69. { include: '@operators' },
  70. ['@(@identifier(?=[:,\\)]))', 'variable', '@attribute'],
  71. ['@(@identifier)', 'variable'],
  72. ['@', 'key', '@atRules']
  73. ],
  74. nestedJSBegin: [
  75. ['``', 'delimiter.backtick'],
  76. [
  77. '`',
  78. {
  79. token: 'delimiter.backtick',
  80. next: '@nestedJSEnd',
  81. nextEmbedded: 'text/javascript'
  82. }
  83. ]
  84. ],
  85. nestedJSEnd: [
  86. [
  87. '`',
  88. {
  89. token: 'delimiter.backtick',
  90. next: '@pop',
  91. nextEmbedded: '@pop'
  92. }
  93. ]
  94. ],
  95. operators: [['[<>=\\+\\-\\*\\/\\^\\|\\~]', 'operator']],
  96. keyword: [
  97. [
  98. '(@[\\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',
  99. 'keyword'
  100. ]
  101. ],
  102. urldeclaration: [
  103. { include: '@strings' },
  104. ['[^)\r\n]+', 'string'],
  105. ['\\)', { token: 'tag', next: '@pop' }]
  106. ],
  107. attribute: [
  108. { include: '@nestedJSBegin' },
  109. { include: '@comments' },
  110. { include: '@strings' },
  111. { include: '@numbers' },
  112. { include: '@keyword' },
  113. ['[a-zA-Z\\-]+(?=\\()', 'attribute.value', '@attribute'],
  114. ['>', 'operator', '@pop'],
  115. ['@identifier', 'attribute.value'],
  116. { include: '@operators' },
  117. ['@(@identifier)', 'variable'],
  118. ['[)\\}]', '@brackets', '@pop'],
  119. ['[{}()\\[\\]>]', '@brackets'],
  120. ['[;]', 'delimiter', '@pop'],
  121. ['[,=:]', 'delimiter'],
  122. ['\\s', ''],
  123. ['.', 'attribute.value']
  124. ],
  125. comments: [
  126. ['\\/\\*', 'comment', '@comment'],
  127. ['\\/\\/+.*', 'comment']
  128. ],
  129. comment: [
  130. ['\\*\\/', 'comment', '@pop'],
  131. ['.', 'comment']
  132. ],
  133. numbers: [
  134. [
  135. '(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?',
  136. { token: 'attribute.value.number', next: '@units' }
  137. ],
  138. ['#[0-9a-fA-F_]+(?!\\w)', 'attribute.value.hex']
  139. ],
  140. units: [
  141. [
  142. '(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?',
  143. 'attribute.value.unit',
  144. '@pop'
  145. ]
  146. ],
  147. strings: [
  148. ['~?"', { token: 'string.delimiter', next: '@stringsEndDoubleQuote' }],
  149. ["~?'", { token: 'string.delimiter', next: '@stringsEndQuote' }]
  150. ],
  151. stringsEndDoubleQuote: [
  152. ['\\\\"', 'string'],
  153. ['"', { token: 'string.delimiter', next: '@popall' }],
  154. ['.', 'string']
  155. ],
  156. stringsEndQuote: [
  157. ["\\\\'", 'string'],
  158. ["'", { token: 'string.delimiter', next: '@popall' }],
  159. ['.', 'string']
  160. ],
  161. atRules: [
  162. { include: '@comments' },
  163. { include: '@strings' },
  164. ['[()]', 'delimiter'],
  165. ['[\\{;]', 'delimiter', '@pop'],
  166. ['.', 'key']
  167. ]
  168. }
  169. };
  170. });