css.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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/css/css',["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. },
  14. brackets: [
  15. ['{', '}'],
  16. ['[', ']'],
  17. ['(', ')']
  18. ],
  19. autoClosingPairs: [
  20. { open: '{', close: '}', notIn: ['string', 'comment'] },
  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. ],
  26. surroundingPairs: [
  27. { open: '{', close: '}' },
  28. { open: '[', close: ']' },
  29. { open: '(', close: ')' },
  30. { open: '"', close: '"' },
  31. { open: "'", close: "'" }
  32. ],
  33. folding: {
  34. markers: {
  35. start: new RegExp('^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/'),
  36. end: new RegExp('^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/')
  37. }
  38. }
  39. };
  40. exports.language = {
  41. defaultToken: '',
  42. tokenPostfix: '.css',
  43. ws: '[ \t\n\r\f]*',
  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. brackets: [
  46. { open: '{', close: '}', token: 'delimiter.bracket' },
  47. { open: '[', close: ']', token: 'delimiter.bracket' },
  48. { open: '(', close: ')', token: 'delimiter.parenthesis' },
  49. { open: '<', close: '>', token: 'delimiter.angle' }
  50. ],
  51. tokenizer: {
  52. root: [{ include: '@selector' }],
  53. selector: [
  54. { include: '@comments' },
  55. { include: '@import' },
  56. { include: '@strings' },
  57. [
  58. '[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)',
  59. { token: 'keyword', next: '@keyframedeclaration' }
  60. ],
  61. ['[@](page|content|font-face|-moz-document)', { token: 'keyword' }],
  62. ['[@](charset|namespace)', { token: 'keyword', next: '@declarationbody' }],
  63. [
  64. '(url-prefix)(\\()',
  65. ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]
  66. ],
  67. [
  68. '(url)(\\()',
  69. ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]
  70. ],
  71. { include: '@selectorname' },
  72. ['[\\*]', 'tag'],
  73. ['[>\\+,]', 'delimiter'],
  74. ['\\[', { token: 'delimiter.bracket', next: '@selectorattribute' }],
  75. ['{', { token: 'delimiter.bracket', next: '@selectorbody' }]
  76. ],
  77. selectorbody: [
  78. { include: '@comments' },
  79. ['[*_]?@identifier@ws:(?=(\\s|\\d|[^{;}]*[;}]))', 'attribute.name', '@rulevalue'],
  80. ['}', { token: 'delimiter.bracket', next: '@pop' }]
  81. ],
  82. selectorname: [
  83. ['(\\.|#(?=[^{])|%|(@identifier)|:)+', 'tag'] // selector (.foo, div, ...)
  84. ],
  85. selectorattribute: [
  86. { include: '@term' },
  87. [']', { token: 'delimiter.bracket', next: '@pop' }]
  88. ],
  89. term: [
  90. { include: '@comments' },
  91. [
  92. '(url-prefix)(\\()',
  93. ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]
  94. ],
  95. [
  96. '(url)(\\()',
  97. ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]
  98. ],
  99. { include: '@functioninvocation' },
  100. { include: '@numbers' },
  101. { include: '@name' },
  102. { include: '@strings' },
  103. ['([<>=\\+\\-\\*\\/\\^\\|\\~,])', 'delimiter'],
  104. [',', 'delimiter']
  105. ],
  106. rulevalue: [
  107. { include: '@comments' },
  108. { include: '@strings' },
  109. { include: '@term' },
  110. ['!important', 'keyword'],
  111. [';', 'delimiter', '@pop'],
  112. ['(?=})', { token: '', next: '@pop' }] // missing semicolon
  113. ],
  114. warndebug: [['[@](warn|debug)', { token: 'keyword', next: '@declarationbody' }]],
  115. import: [['[@](import)', { token: 'keyword', next: '@declarationbody' }]],
  116. urldeclaration: [
  117. { include: '@strings' },
  118. ['[^)\r\n]+', 'string'],
  119. ['\\)', { token: 'delimiter.parenthesis', next: '@pop' }]
  120. ],
  121. parenthizedterm: [
  122. { include: '@term' },
  123. ['\\)', { token: 'delimiter.parenthesis', next: '@pop' }]
  124. ],
  125. declarationbody: [
  126. { include: '@term' },
  127. [';', 'delimiter', '@pop'],
  128. ['(?=})', { token: '', next: '@pop' }] // missing semicolon
  129. ],
  130. comments: [
  131. ['\\/\\*', 'comment', '@comment'],
  132. ['\\/\\/+.*', 'comment']
  133. ],
  134. comment: [
  135. ['\\*\\/', 'comment', '@pop'],
  136. [/[^*/]+/, 'comment'],
  137. [/./, 'comment']
  138. ],
  139. name: [['@identifier', 'attribute.value']],
  140. numbers: [
  141. [
  142. '-?(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?',
  143. { token: 'attribute.value.number', next: '@units' }
  144. ],
  145. ['#[0-9a-fA-F_]+(?!\\w)', 'attribute.value.hex']
  146. ],
  147. units: [
  148. [
  149. '(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?',
  150. 'attribute.value.unit',
  151. '@pop'
  152. ]
  153. ],
  154. keyframedeclaration: [
  155. ['@identifier', 'attribute.value'],
  156. ['{', { token: 'delimiter.bracket', switchTo: '@keyframebody' }]
  157. ],
  158. keyframebody: [
  159. { include: '@term' },
  160. ['{', { token: 'delimiter.bracket', next: '@selectorbody' }],
  161. ['}', { token: 'delimiter.bracket', next: '@pop' }]
  162. ],
  163. functioninvocation: [
  164. ['@identifier\\(', { token: 'attribute.value', next: '@functionarguments' }]
  165. ],
  166. functionarguments: [
  167. ['\\$@identifier@ws:', 'attribute.name'],
  168. ['[,]', 'delimiter'],
  169. { include: '@term' },
  170. ['\\)', { token: 'attribute.value', next: '@pop' }]
  171. ],
  172. strings: [
  173. ['~?"', { token: 'string', next: '@stringenddoublequote' }],
  174. ["~?'", { token: 'string', next: '@stringendquote' }]
  175. ],
  176. stringenddoublequote: [
  177. ['\\\\.', 'string'],
  178. ['"', { token: 'string', next: '@pop' }],
  179. [/[^\\"]+/, 'string'],
  180. ['.', 'string']
  181. ],
  182. stringendquote: [
  183. ['\\\\.', 'string'],
  184. ["'", { token: 'string', next: '@pop' }],
  185. [/[^\\']+/, 'string'],
  186. ['.', 'string']
  187. ]
  188. }
  189. };
  190. });