handlebars.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. "use strict";
  2. /*!-----------------------------------------------------------------------------
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. * Version: 0.38.0(0e330ae453813de4e6cf272460fb79c7117073d0)
  5. * Released under the MIT license
  6. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  7. *-----------------------------------------------------------------------------*/
  8. define("vs/basic-languages/handlebars/handlebars", ["require"],(require)=>{
  9. var moduleExports = (() => {
  10. var __create = Object.create;
  11. var __defProp = Object.defineProperty;
  12. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  13. var __getOwnPropNames = Object.getOwnPropertyNames;
  14. var __getProtoOf = Object.getPrototypeOf;
  15. var __hasOwnProp = Object.prototype.hasOwnProperty;
  16. var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
  17. get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
  18. }) : x)(function(x) {
  19. if (typeof require !== "undefined")
  20. return require.apply(this, arguments);
  21. throw new Error('Dynamic require of "' + x + '" is not supported');
  22. });
  23. var __commonJS = (cb, mod) => function __require2() {
  24. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  25. };
  26. var __export = (target, all) => {
  27. for (var name in all)
  28. __defProp(target, name, { get: all[name], enumerable: true });
  29. };
  30. var __copyProps = (to, from, except, desc) => {
  31. if (from && typeof from === "object" || typeof from === "function") {
  32. for (let key of __getOwnPropNames(from))
  33. if (!__hasOwnProp.call(to, key) && key !== except)
  34. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  35. }
  36. return to;
  37. };
  38. var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
  39. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
  40. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  41. // src/fillers/monaco-editor-core-amd.ts
  42. var require_monaco_editor_core_amd = __commonJS({
  43. "src/fillers/monaco-editor-core-amd.ts"(exports, module) {
  44. var api = __toESM(__require("vs/editor/editor.api"));
  45. module.exports = api;
  46. }
  47. });
  48. // src/basic-languages/handlebars/handlebars.ts
  49. var handlebars_exports = {};
  50. __export(handlebars_exports, {
  51. conf: () => conf,
  52. language: () => language
  53. });
  54. // src/fillers/monaco-editor-core.ts
  55. var monaco_editor_core_exports = {};
  56. __reExport(monaco_editor_core_exports, __toESM(require_monaco_editor_core_amd()));
  57. // src/basic-languages/handlebars/handlebars.ts
  58. var EMPTY_ELEMENTS = [
  59. "area",
  60. "base",
  61. "br",
  62. "col",
  63. "embed",
  64. "hr",
  65. "img",
  66. "input",
  67. "keygen",
  68. "link",
  69. "menuitem",
  70. "meta",
  71. "param",
  72. "source",
  73. "track",
  74. "wbr"
  75. ];
  76. var conf = {
  77. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
  78. comments: {
  79. blockComment: ["{{!--", "--}}"]
  80. },
  81. brackets: [
  82. ["<!--", "-->"],
  83. ["<", ">"],
  84. ["{{", "}}"],
  85. ["{", "}"],
  86. ["(", ")"]
  87. ],
  88. autoClosingPairs: [
  89. { open: "{", close: "}" },
  90. { open: "[", close: "]" },
  91. { open: "(", close: ")" },
  92. { open: '"', close: '"' },
  93. { open: "'", close: "'" }
  94. ],
  95. surroundingPairs: [
  96. { open: "<", close: ">" },
  97. { open: '"', close: '"' },
  98. { open: "'", close: "'" }
  99. ],
  100. onEnterRules: [
  101. {
  102. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  103. afterText: /^<\/(\w[\w\d]*)\s*>$/i,
  104. action: {
  105. indentAction: monaco_editor_core_exports.languages.IndentAction.IndentOutdent
  106. }
  107. },
  108. {
  109. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  110. action: { indentAction: monaco_editor_core_exports.languages.IndentAction.Indent }
  111. }
  112. ]
  113. };
  114. var language = {
  115. defaultToken: "",
  116. tokenPostfix: "",
  117. tokenizer: {
  118. root: [
  119. [/\{\{!--/, "comment.block.start.handlebars", "@commentBlock"],
  120. [/\{\{!/, "comment.start.handlebars", "@comment"],
  121. [/\{\{/, { token: "@rematch", switchTo: "@handlebarsInSimpleState.root" }],
  122. [/<!DOCTYPE/, "metatag.html", "@doctype"],
  123. [/<!--/, "comment.html", "@commentHtml"],
  124. [/(<)(\w+)(\/>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  125. [/(<)(script)/, ["delimiter.html", { token: "tag.html", next: "@script" }]],
  126. [/(<)(style)/, ["delimiter.html", { token: "tag.html", next: "@style" }]],
  127. [/(<)([:\w]+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  128. [/(<\/)(\w+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  129. [/</, "delimiter.html"],
  130. [/\{/, "delimiter.html"],
  131. [/[^<{]+/]
  132. ],
  133. doctype: [
  134. [
  135. /\{\{/,
  136. {
  137. token: "@rematch",
  138. switchTo: "@handlebarsInSimpleState.comment"
  139. }
  140. ],
  141. [/[^>]+/, "metatag.content.html"],
  142. [/>/, "metatag.html", "@pop"]
  143. ],
  144. comment: [
  145. [/\}\}/, "comment.end.handlebars", "@pop"],
  146. [/./, "comment.content.handlebars"]
  147. ],
  148. commentBlock: [
  149. [/--\}\}/, "comment.block.end.handlebars", "@pop"],
  150. [/./, "comment.content.handlebars"]
  151. ],
  152. commentHtml: [
  153. [
  154. /\{\{/,
  155. {
  156. token: "@rematch",
  157. switchTo: "@handlebarsInSimpleState.comment"
  158. }
  159. ],
  160. [/-->/, "comment.html", "@pop"],
  161. [/[^-]+/, "comment.content.html"],
  162. [/./, "comment.content.html"]
  163. ],
  164. otherTag: [
  165. [
  166. /\{\{/,
  167. {
  168. token: "@rematch",
  169. switchTo: "@handlebarsInSimpleState.otherTag"
  170. }
  171. ],
  172. [/\/?>/, "delimiter.html", "@pop"],
  173. [/"([^"]*)"/, "attribute.value"],
  174. [/'([^']*)'/, "attribute.value"],
  175. [/[\w\-]+/, "attribute.name"],
  176. [/=/, "delimiter"],
  177. [/[ \t\r\n]+/]
  178. ],
  179. script: [
  180. [
  181. /\{\{/,
  182. {
  183. token: "@rematch",
  184. switchTo: "@handlebarsInSimpleState.script"
  185. }
  186. ],
  187. [/type/, "attribute.name", "@scriptAfterType"],
  188. [/"([^"]*)"/, "attribute.value"],
  189. [/'([^']*)'/, "attribute.value"],
  190. [/[\w\-]+/, "attribute.name"],
  191. [/=/, "delimiter"],
  192. [
  193. />/,
  194. {
  195. token: "delimiter.html",
  196. next: "@scriptEmbedded.text/javascript",
  197. nextEmbedded: "text/javascript"
  198. }
  199. ],
  200. [/[ \t\r\n]+/],
  201. [
  202. /(<\/)(script\s*)(>)/,
  203. ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]
  204. ]
  205. ],
  206. scriptAfterType: [
  207. [
  208. /\{\{/,
  209. {
  210. token: "@rematch",
  211. switchTo: "@handlebarsInSimpleState.scriptAfterType"
  212. }
  213. ],
  214. [/=/, "delimiter", "@scriptAfterTypeEquals"],
  215. [
  216. />/,
  217. {
  218. token: "delimiter.html",
  219. next: "@scriptEmbedded.text/javascript",
  220. nextEmbedded: "text/javascript"
  221. }
  222. ],
  223. [/[ \t\r\n]+/],
  224. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  225. ],
  226. scriptAfterTypeEquals: [
  227. [
  228. /\{\{/,
  229. {
  230. token: "@rematch",
  231. switchTo: "@handlebarsInSimpleState.scriptAfterTypeEquals"
  232. }
  233. ],
  234. [
  235. /"([^"]*)"/,
  236. {
  237. token: "attribute.value",
  238. switchTo: "@scriptWithCustomType.$1"
  239. }
  240. ],
  241. [
  242. /'([^']*)'/,
  243. {
  244. token: "attribute.value",
  245. switchTo: "@scriptWithCustomType.$1"
  246. }
  247. ],
  248. [
  249. />/,
  250. {
  251. token: "delimiter.html",
  252. next: "@scriptEmbedded.text/javascript",
  253. nextEmbedded: "text/javascript"
  254. }
  255. ],
  256. [/[ \t\r\n]+/],
  257. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  258. ],
  259. scriptWithCustomType: [
  260. [
  261. /\{\{/,
  262. {
  263. token: "@rematch",
  264. switchTo: "@handlebarsInSimpleState.scriptWithCustomType.$S2"
  265. }
  266. ],
  267. [
  268. />/,
  269. {
  270. token: "delimiter.html",
  271. next: "@scriptEmbedded.$S2",
  272. nextEmbedded: "$S2"
  273. }
  274. ],
  275. [/"([^"]*)"/, "attribute.value"],
  276. [/'([^']*)'/, "attribute.value"],
  277. [/[\w\-]+/, "attribute.name"],
  278. [/=/, "delimiter"],
  279. [/[ \t\r\n]+/],
  280. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  281. ],
  282. scriptEmbedded: [
  283. [
  284. /\{\{/,
  285. {
  286. token: "@rematch",
  287. switchTo: "@handlebarsInEmbeddedState.scriptEmbedded.$S2",
  288. nextEmbedded: "@pop"
  289. }
  290. ],
  291. [/<\/script/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]
  292. ],
  293. style: [
  294. [
  295. /\{\{/,
  296. {
  297. token: "@rematch",
  298. switchTo: "@handlebarsInSimpleState.style"
  299. }
  300. ],
  301. [/type/, "attribute.name", "@styleAfterType"],
  302. [/"([^"]*)"/, "attribute.value"],
  303. [/'([^']*)'/, "attribute.value"],
  304. [/[\w\-]+/, "attribute.name"],
  305. [/=/, "delimiter"],
  306. [
  307. />/,
  308. {
  309. token: "delimiter.html",
  310. next: "@styleEmbedded.text/css",
  311. nextEmbedded: "text/css"
  312. }
  313. ],
  314. [/[ \t\r\n]+/],
  315. [
  316. /(<\/)(style\s*)(>)/,
  317. ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]
  318. ]
  319. ],
  320. styleAfterType: [
  321. [
  322. /\{\{/,
  323. {
  324. token: "@rematch",
  325. switchTo: "@handlebarsInSimpleState.styleAfterType"
  326. }
  327. ],
  328. [/=/, "delimiter", "@styleAfterTypeEquals"],
  329. [
  330. />/,
  331. {
  332. token: "delimiter.html",
  333. next: "@styleEmbedded.text/css",
  334. nextEmbedded: "text/css"
  335. }
  336. ],
  337. [/[ \t\r\n]+/],
  338. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  339. ],
  340. styleAfterTypeEquals: [
  341. [
  342. /\{\{/,
  343. {
  344. token: "@rematch",
  345. switchTo: "@handlebarsInSimpleState.styleAfterTypeEquals"
  346. }
  347. ],
  348. [
  349. /"([^"]*)"/,
  350. {
  351. token: "attribute.value",
  352. switchTo: "@styleWithCustomType.$1"
  353. }
  354. ],
  355. [
  356. /'([^']*)'/,
  357. {
  358. token: "attribute.value",
  359. switchTo: "@styleWithCustomType.$1"
  360. }
  361. ],
  362. [
  363. />/,
  364. {
  365. token: "delimiter.html",
  366. next: "@styleEmbedded.text/css",
  367. nextEmbedded: "text/css"
  368. }
  369. ],
  370. [/[ \t\r\n]+/],
  371. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  372. ],
  373. styleWithCustomType: [
  374. [
  375. /\{\{/,
  376. {
  377. token: "@rematch",
  378. switchTo: "@handlebarsInSimpleState.styleWithCustomType.$S2"
  379. }
  380. ],
  381. [
  382. />/,
  383. {
  384. token: "delimiter.html",
  385. next: "@styleEmbedded.$S2",
  386. nextEmbedded: "$S2"
  387. }
  388. ],
  389. [/"([^"]*)"/, "attribute.value"],
  390. [/'([^']*)'/, "attribute.value"],
  391. [/[\w\-]+/, "attribute.name"],
  392. [/=/, "delimiter"],
  393. [/[ \t\r\n]+/],
  394. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  395. ],
  396. styleEmbedded: [
  397. [
  398. /\{\{/,
  399. {
  400. token: "@rematch",
  401. switchTo: "@handlebarsInEmbeddedState.styleEmbedded.$S2",
  402. nextEmbedded: "@pop"
  403. }
  404. ],
  405. [/<\/style/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]
  406. ],
  407. handlebarsInSimpleState: [
  408. [/\{\{\{?/, "delimiter.handlebars"],
  409. [/\}\}\}?/, { token: "delimiter.handlebars", switchTo: "@$S2.$S3" }],
  410. { include: "handlebarsRoot" }
  411. ],
  412. handlebarsInEmbeddedState: [
  413. [/\{\{\{?/, "delimiter.handlebars"],
  414. [
  415. /\}\}\}?/,
  416. {
  417. token: "delimiter.handlebars",
  418. switchTo: "@$S2.$S3",
  419. nextEmbedded: "$S3"
  420. }
  421. ],
  422. { include: "handlebarsRoot" }
  423. ],
  424. handlebarsRoot: [
  425. [/"[^"]*"/, "string.handlebars"],
  426. [/[#/][^\s}]+/, "keyword.helper.handlebars"],
  427. [/else\b/, "keyword.helper.handlebars"],
  428. [/[\s]+/],
  429. [/[^}]/, "variable.parameter.handlebars"]
  430. ]
  431. }
  432. };
  433. return __toCommonJS(handlebars_exports);
  434. })();
  435. return moduleExports;
  436. });