razor.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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. var __defProp = Object.defineProperty;
  8. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  9. var __getOwnPropNames = Object.getOwnPropertyNames;
  10. var __hasOwnProp = Object.prototype.hasOwnProperty;
  11. var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
  12. var __reExport = (target, module, desc) => {
  13. if (module && typeof module === "object" || typeof module === "function") {
  14. for (let key of __getOwnPropNames(module))
  15. if (!__hasOwnProp.call(target, key) && key !== "default")
  16. __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
  17. }
  18. return target;
  19. };
  20. // src/fillers/monaco-editor-core.ts
  21. var monaco_editor_core_exports = {};
  22. __markAsModule(monaco_editor_core_exports);
  23. __reExport(monaco_editor_core_exports, monaco_editor_core_star);
  24. import * as monaco_editor_core_star from "../../editor/editor.api.js";
  25. // src/basic-languages/razor/razor.ts
  26. var EMPTY_ELEMENTS = [
  27. "area",
  28. "base",
  29. "br",
  30. "col",
  31. "embed",
  32. "hr",
  33. "img",
  34. "input",
  35. "keygen",
  36. "link",
  37. "menuitem",
  38. "meta",
  39. "param",
  40. "source",
  41. "track",
  42. "wbr"
  43. ];
  44. var conf = {
  45. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
  46. comments: {
  47. blockComment: ["<!--", "-->"]
  48. },
  49. brackets: [
  50. ["<!--", "-->"],
  51. ["<", ">"],
  52. ["{", "}"],
  53. ["(", ")"]
  54. ],
  55. autoClosingPairs: [
  56. { open: "{", close: "}" },
  57. { open: "[", close: "]" },
  58. { open: "(", close: ")" },
  59. { open: '"', close: '"' },
  60. { open: "'", close: "'" }
  61. ],
  62. surroundingPairs: [
  63. { open: '"', close: '"' },
  64. { open: "'", close: "'" },
  65. { open: "<", close: ">" }
  66. ],
  67. onEnterRules: [
  68. {
  69. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  70. afterText: /^<\/(\w[\w\d]*)\s*>$/i,
  71. action: {
  72. indentAction: monaco_editor_core_exports.languages.IndentAction.IndentOutdent
  73. }
  74. },
  75. {
  76. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  77. action: { indentAction: monaco_editor_core_exports.languages.IndentAction.Indent }
  78. }
  79. ]
  80. };
  81. var language = {
  82. defaultToken: "",
  83. tokenPostfix: "",
  84. tokenizer: {
  85. root: [
  86. [/@@@@/],
  87. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.root" }],
  88. [/<!DOCTYPE/, "metatag.html", "@doctype"],
  89. [/<!--/, "comment.html", "@comment"],
  90. [/(<)([\w\-]+)(\/>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  91. [/(<)(script)/, ["delimiter.html", { token: "tag.html", next: "@script" }]],
  92. [/(<)(style)/, ["delimiter.html", { token: "tag.html", next: "@style" }]],
  93. [/(<)([:\w\-]+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  94. [/(<\/)([\w\-]+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  95. [/</, "delimiter.html"],
  96. [/[ \t\r\n]+/],
  97. [/[^<@]+/]
  98. ],
  99. doctype: [
  100. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.comment" }],
  101. [/[^>]+/, "metatag.content.html"],
  102. [/>/, "metatag.html", "@pop"]
  103. ],
  104. comment: [
  105. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.comment" }],
  106. [/-->/, "comment.html", "@pop"],
  107. [/[^-]+/, "comment.content.html"],
  108. [/./, "comment.content.html"]
  109. ],
  110. otherTag: [
  111. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.otherTag" }],
  112. [/\/?>/, "delimiter.html", "@pop"],
  113. [/"([^"]*)"/, "attribute.value"],
  114. [/'([^']*)'/, "attribute.value"],
  115. [/[\w\-]+/, "attribute.name"],
  116. [/=/, "delimiter"],
  117. [/[ \t\r\n]+/]
  118. ],
  119. script: [
  120. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.script" }],
  121. [/type/, "attribute.name", "@scriptAfterType"],
  122. [/"([^"]*)"/, "attribute.value"],
  123. [/'([^']*)'/, "attribute.value"],
  124. [/[\w\-]+/, "attribute.name"],
  125. [/=/, "delimiter"],
  126. [
  127. />/,
  128. {
  129. token: "delimiter.html",
  130. next: "@scriptEmbedded.text/javascript",
  131. nextEmbedded: "text/javascript"
  132. }
  133. ],
  134. [/[ \t\r\n]+/],
  135. [
  136. /(<\/)(script\s*)(>)/,
  137. ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]
  138. ]
  139. ],
  140. scriptAfterType: [
  141. [
  142. /@[^@]/,
  143. {
  144. token: "@rematch",
  145. switchTo: "@razorInSimpleState.scriptAfterType"
  146. }
  147. ],
  148. [/=/, "delimiter", "@scriptAfterTypeEquals"],
  149. [
  150. />/,
  151. {
  152. token: "delimiter.html",
  153. next: "@scriptEmbedded.text/javascript",
  154. nextEmbedded: "text/javascript"
  155. }
  156. ],
  157. [/[ \t\r\n]+/],
  158. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  159. ],
  160. scriptAfterTypeEquals: [
  161. [
  162. /@[^@]/,
  163. {
  164. token: "@rematch",
  165. switchTo: "@razorInSimpleState.scriptAfterTypeEquals"
  166. }
  167. ],
  168. [
  169. /"([^"]*)"/,
  170. {
  171. token: "attribute.value",
  172. switchTo: "@scriptWithCustomType.$1"
  173. }
  174. ],
  175. [
  176. /'([^']*)'/,
  177. {
  178. token: "attribute.value",
  179. switchTo: "@scriptWithCustomType.$1"
  180. }
  181. ],
  182. [
  183. />/,
  184. {
  185. token: "delimiter.html",
  186. next: "@scriptEmbedded.text/javascript",
  187. nextEmbedded: "text/javascript"
  188. }
  189. ],
  190. [/[ \t\r\n]+/],
  191. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  192. ],
  193. scriptWithCustomType: [
  194. [
  195. /@[^@]/,
  196. {
  197. token: "@rematch",
  198. switchTo: "@razorInSimpleState.scriptWithCustomType.$S2"
  199. }
  200. ],
  201. [
  202. />/,
  203. {
  204. token: "delimiter.html",
  205. next: "@scriptEmbedded.$S2",
  206. nextEmbedded: "$S2"
  207. }
  208. ],
  209. [/"([^"]*)"/, "attribute.value"],
  210. [/'([^']*)'/, "attribute.value"],
  211. [/[\w\-]+/, "attribute.name"],
  212. [/=/, "delimiter"],
  213. [/[ \t\r\n]+/],
  214. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  215. ],
  216. scriptEmbedded: [
  217. [
  218. /@[^@]/,
  219. {
  220. token: "@rematch",
  221. switchTo: "@razorInEmbeddedState.scriptEmbedded.$S2",
  222. nextEmbedded: "@pop"
  223. }
  224. ],
  225. [/<\/script/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]
  226. ],
  227. style: [
  228. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.style" }],
  229. [/type/, "attribute.name", "@styleAfterType"],
  230. [/"([^"]*)"/, "attribute.value"],
  231. [/'([^']*)'/, "attribute.value"],
  232. [/[\w\-]+/, "attribute.name"],
  233. [/=/, "delimiter"],
  234. [
  235. />/,
  236. {
  237. token: "delimiter.html",
  238. next: "@styleEmbedded.text/css",
  239. nextEmbedded: "text/css"
  240. }
  241. ],
  242. [/[ \t\r\n]+/],
  243. [
  244. /(<\/)(style\s*)(>)/,
  245. ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]
  246. ]
  247. ],
  248. styleAfterType: [
  249. [
  250. /@[^@]/,
  251. {
  252. token: "@rematch",
  253. switchTo: "@razorInSimpleState.styleAfterType"
  254. }
  255. ],
  256. [/=/, "delimiter", "@styleAfterTypeEquals"],
  257. [
  258. />/,
  259. {
  260. token: "delimiter.html",
  261. next: "@styleEmbedded.text/css",
  262. nextEmbedded: "text/css"
  263. }
  264. ],
  265. [/[ \t\r\n]+/],
  266. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  267. ],
  268. styleAfterTypeEquals: [
  269. [
  270. /@[^@]/,
  271. {
  272. token: "@rematch",
  273. switchTo: "@razorInSimpleState.styleAfterTypeEquals"
  274. }
  275. ],
  276. [
  277. /"([^"]*)"/,
  278. {
  279. token: "attribute.value",
  280. switchTo: "@styleWithCustomType.$1"
  281. }
  282. ],
  283. [
  284. /'([^']*)'/,
  285. {
  286. token: "attribute.value",
  287. switchTo: "@styleWithCustomType.$1"
  288. }
  289. ],
  290. [
  291. />/,
  292. {
  293. token: "delimiter.html",
  294. next: "@styleEmbedded.text/css",
  295. nextEmbedded: "text/css"
  296. }
  297. ],
  298. [/[ \t\r\n]+/],
  299. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  300. ],
  301. styleWithCustomType: [
  302. [
  303. /@[^@]/,
  304. {
  305. token: "@rematch",
  306. switchTo: "@razorInSimpleState.styleWithCustomType.$S2"
  307. }
  308. ],
  309. [
  310. />/,
  311. {
  312. token: "delimiter.html",
  313. next: "@styleEmbedded.$S2",
  314. nextEmbedded: "$S2"
  315. }
  316. ],
  317. [/"([^"]*)"/, "attribute.value"],
  318. [/'([^']*)'/, "attribute.value"],
  319. [/[\w\-]+/, "attribute.name"],
  320. [/=/, "delimiter"],
  321. [/[ \t\r\n]+/],
  322. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  323. ],
  324. styleEmbedded: [
  325. [
  326. /@[^@]/,
  327. {
  328. token: "@rematch",
  329. switchTo: "@razorInEmbeddedState.styleEmbedded.$S2",
  330. nextEmbedded: "@pop"
  331. }
  332. ],
  333. [/<\/style/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]
  334. ],
  335. razorInSimpleState: [
  336. [/@\*/, "comment.cs", "@razorBlockCommentTopLevel"],
  337. [/@[{(]/, "metatag.cs", "@razorRootTopLevel"],
  338. [/(@)(\s*[\w]+)/, ["metatag.cs", { token: "identifier.cs", switchTo: "@$S2.$S3" }]],
  339. [/[})]/, { token: "metatag.cs", switchTo: "@$S2.$S3" }],
  340. [/\*@/, { token: "comment.cs", switchTo: "@$S2.$S3" }]
  341. ],
  342. razorInEmbeddedState: [
  343. [/@\*/, "comment.cs", "@razorBlockCommentTopLevel"],
  344. [/@[{(]/, "metatag.cs", "@razorRootTopLevel"],
  345. [
  346. /(@)(\s*[\w]+)/,
  347. [
  348. "metatag.cs",
  349. {
  350. token: "identifier.cs",
  351. switchTo: "@$S2.$S3",
  352. nextEmbedded: "$S3"
  353. }
  354. ]
  355. ],
  356. [
  357. /[})]/,
  358. {
  359. token: "metatag.cs",
  360. switchTo: "@$S2.$S3",
  361. nextEmbedded: "$S3"
  362. }
  363. ],
  364. [
  365. /\*@/,
  366. {
  367. token: "comment.cs",
  368. switchTo: "@$S2.$S3",
  369. nextEmbedded: "$S3"
  370. }
  371. ]
  372. ],
  373. razorBlockCommentTopLevel: [
  374. [/\*@/, "@rematch", "@pop"],
  375. [/[^*]+/, "comment.cs"],
  376. [/./, "comment.cs"]
  377. ],
  378. razorBlockComment: [
  379. [/\*@/, "comment.cs", "@pop"],
  380. [/[^*]+/, "comment.cs"],
  381. [/./, "comment.cs"]
  382. ],
  383. razorRootTopLevel: [
  384. [/\{/, "delimiter.bracket.cs", "@razorRoot"],
  385. [/\(/, "delimiter.parenthesis.cs", "@razorRoot"],
  386. [/[})]/, "@rematch", "@pop"],
  387. { include: "razorCommon" }
  388. ],
  389. razorRoot: [
  390. [/\{/, "delimiter.bracket.cs", "@razorRoot"],
  391. [/\(/, "delimiter.parenthesis.cs", "@razorRoot"],
  392. [/\}/, "delimiter.bracket.cs", "@pop"],
  393. [/\)/, "delimiter.parenthesis.cs", "@pop"],
  394. { include: "razorCommon" }
  395. ],
  396. razorCommon: [
  397. [
  398. /[a-zA-Z_]\w*/,
  399. {
  400. cases: {
  401. "@razorKeywords": { token: "keyword.cs" },
  402. "@default": "identifier.cs"
  403. }
  404. }
  405. ],
  406. [/[\[\]]/, "delimiter.array.cs"],
  407. [/[ \t\r\n]+/],
  408. [/\/\/.*$/, "comment.cs"],
  409. [/@\*/, "comment.cs", "@razorBlockComment"],
  410. [/"([^"]*)"/, "string.cs"],
  411. [/'([^']*)'/, "string.cs"],
  412. [/(<)([\w\-]+)(\/>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  413. [/(<)([\w\-]+)(>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  414. [/(<\/)([\w\-]+)(>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  415. [/[\+\-\*\%\&\|\^\~\!\=\<\>\/\?\;\:\.\,]/, "delimiter.cs"],
  416. [/\d*\d+[eE]([\-+]?\d+)?/, "number.float.cs"],
  417. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float.cs"],
  418. [/0[xX][0-9a-fA-F']*[0-9a-fA-F]/, "number.hex.cs"],
  419. [/0[0-7']*[0-7]/, "number.octal.cs"],
  420. [/0[bB][0-1']*[0-1]/, "number.binary.cs"],
  421. [/\d[\d']*/, "number.cs"],
  422. [/\d/, "number.cs"]
  423. ]
  424. },
  425. razorKeywords: [
  426. "abstract",
  427. "as",
  428. "async",
  429. "await",
  430. "base",
  431. "bool",
  432. "break",
  433. "by",
  434. "byte",
  435. "case",
  436. "catch",
  437. "char",
  438. "checked",
  439. "class",
  440. "const",
  441. "continue",
  442. "decimal",
  443. "default",
  444. "delegate",
  445. "do",
  446. "double",
  447. "descending",
  448. "explicit",
  449. "event",
  450. "extern",
  451. "else",
  452. "enum",
  453. "false",
  454. "finally",
  455. "fixed",
  456. "float",
  457. "for",
  458. "foreach",
  459. "from",
  460. "goto",
  461. "group",
  462. "if",
  463. "implicit",
  464. "in",
  465. "int",
  466. "interface",
  467. "internal",
  468. "into",
  469. "is",
  470. "lock",
  471. "long",
  472. "nameof",
  473. "new",
  474. "null",
  475. "namespace",
  476. "object",
  477. "operator",
  478. "out",
  479. "override",
  480. "orderby",
  481. "params",
  482. "private",
  483. "protected",
  484. "public",
  485. "readonly",
  486. "ref",
  487. "return",
  488. "switch",
  489. "struct",
  490. "sbyte",
  491. "sealed",
  492. "short",
  493. "sizeof",
  494. "stackalloc",
  495. "static",
  496. "string",
  497. "select",
  498. "this",
  499. "throw",
  500. "true",
  501. "try",
  502. "typeof",
  503. "uint",
  504. "ulong",
  505. "unchecked",
  506. "unsafe",
  507. "ushort",
  508. "using",
  509. "var",
  510. "virtual",
  511. "volatile",
  512. "void",
  513. "when",
  514. "while",
  515. "where",
  516. "yield",
  517. "model",
  518. "inject"
  519. ],
  520. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/
  521. };
  522. export {
  523. conf,
  524. language
  525. };