liquid.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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/liquid/liquid", ["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/liquid/liquid.ts
  49. var liquid_exports = {};
  50. __export(liquid_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/liquid/liquid.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. brackets: [
  79. ["<!--", "-->"],
  80. ["<", ">"],
  81. ["{{", "}}"],
  82. ["{%", "%}"],
  83. ["{", "}"],
  84. ["(", ")"]
  85. ],
  86. autoClosingPairs: [
  87. { open: "{", close: "}" },
  88. { open: "%", close: "%" },
  89. { open: "[", close: "]" },
  90. { open: "(", close: ")" },
  91. { open: '"', close: '"' },
  92. { open: "'", close: "'" }
  93. ],
  94. surroundingPairs: [
  95. { open: "<", close: ">" },
  96. { open: '"', close: '"' },
  97. { open: "'", close: "'" }
  98. ],
  99. onEnterRules: [
  100. {
  101. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  102. afterText: /^<\/(\w[\w\d]*)\s*>$/i,
  103. action: {
  104. indentAction: monaco_editor_core_exports.languages.IndentAction.IndentOutdent
  105. }
  106. },
  107. {
  108. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  109. action: { indentAction: monaco_editor_core_exports.languages.IndentAction.Indent }
  110. }
  111. ]
  112. };
  113. var language = {
  114. defaultToken: "",
  115. tokenPostfix: "",
  116. builtinTags: [
  117. "if",
  118. "else",
  119. "elseif",
  120. "endif",
  121. "render",
  122. "assign",
  123. "capture",
  124. "endcapture",
  125. "case",
  126. "endcase",
  127. "comment",
  128. "endcomment",
  129. "cycle",
  130. "decrement",
  131. "for",
  132. "endfor",
  133. "include",
  134. "increment",
  135. "layout",
  136. "raw",
  137. "endraw",
  138. "render",
  139. "tablerow",
  140. "endtablerow",
  141. "unless",
  142. "endunless"
  143. ],
  144. builtinFilters: [
  145. "abs",
  146. "append",
  147. "at_least",
  148. "at_most",
  149. "capitalize",
  150. "ceil",
  151. "compact",
  152. "date",
  153. "default",
  154. "divided_by",
  155. "downcase",
  156. "escape",
  157. "escape_once",
  158. "first",
  159. "floor",
  160. "join",
  161. "json",
  162. "last",
  163. "lstrip",
  164. "map",
  165. "minus",
  166. "modulo",
  167. "newline_to_br",
  168. "plus",
  169. "prepend",
  170. "remove",
  171. "remove_first",
  172. "replace",
  173. "replace_first",
  174. "reverse",
  175. "round",
  176. "rstrip",
  177. "size",
  178. "slice",
  179. "sort",
  180. "sort_natural",
  181. "split",
  182. "strip",
  183. "strip_html",
  184. "strip_newlines",
  185. "times",
  186. "truncate",
  187. "truncatewords",
  188. "uniq",
  189. "upcase",
  190. "url_decode",
  191. "url_encode",
  192. "where"
  193. ],
  194. constants: ["true", "false"],
  195. operators: ["==", "!=", ">", "<", ">=", "<="],
  196. symbol: /[=><!]+/,
  197. identifier: /[a-zA-Z_][\w]*/,
  198. tokenizer: {
  199. root: [
  200. [/\{\%\s*comment\s*\%\}/, "comment.start.liquid", "@comment"],
  201. [/\{\{/, { token: "@rematch", switchTo: "@liquidState.root" }],
  202. [/\{\%/, { token: "@rematch", switchTo: "@liquidState.root" }],
  203. [/(<)([\w\-]+)(\/>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  204. [/(<)([:\w]+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  205. [/(<\/)([\w\-]+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  206. [/</, "delimiter.html"],
  207. [/\{/, "delimiter.html"],
  208. [/[^<{]+/]
  209. ],
  210. comment: [
  211. [/\{\%\s*endcomment\s*\%\}/, "comment.end.liquid", "@pop"],
  212. [/./, "comment.content.liquid"]
  213. ],
  214. otherTag: [
  215. [
  216. /\{\{/,
  217. {
  218. token: "@rematch",
  219. switchTo: "@liquidState.otherTag"
  220. }
  221. ],
  222. [
  223. /\{\%/,
  224. {
  225. token: "@rematch",
  226. switchTo: "@liquidState.otherTag"
  227. }
  228. ],
  229. [/\/?>/, "delimiter.html", "@pop"],
  230. [/"([^"]*)"/, "attribute.value"],
  231. [/'([^']*)'/, "attribute.value"],
  232. [/[\w\-]+/, "attribute.name"],
  233. [/=/, "delimiter"],
  234. [/[ \t\r\n]+/]
  235. ],
  236. liquidState: [
  237. [/\{\{/, "delimiter.output.liquid"],
  238. [/\}\}/, { token: "delimiter.output.liquid", switchTo: "@$S2.$S3" }],
  239. [/\{\%/, "delimiter.tag.liquid"],
  240. [/raw\s*\%\}/, "delimiter.tag.liquid", "@liquidRaw"],
  241. [/\%\}/, { token: "delimiter.tag.liquid", switchTo: "@$S2.$S3" }],
  242. { include: "liquidRoot" }
  243. ],
  244. liquidRaw: [
  245. [/^(?!\{\%\s*endraw\s*\%\}).+/],
  246. [/\{\%/, "delimiter.tag.liquid"],
  247. [/@identifier/],
  248. [/\%\}/, { token: "delimiter.tag.liquid", next: "@root" }]
  249. ],
  250. liquidRoot: [
  251. [/\d+(\.\d+)?/, "number.liquid"],
  252. [/"[^"]*"/, "string.liquid"],
  253. [/'[^']*'/, "string.liquid"],
  254. [/\s+/],
  255. [
  256. /@symbol/,
  257. {
  258. cases: {
  259. "@operators": "operator.liquid",
  260. "@default": ""
  261. }
  262. }
  263. ],
  264. [/\./],
  265. [
  266. /@identifier/,
  267. {
  268. cases: {
  269. "@constants": "keyword.liquid",
  270. "@builtinFilters": "predefined.liquid",
  271. "@builtinTags": "predefined.liquid",
  272. "@default": "variable.liquid"
  273. }
  274. }
  275. ],
  276. [/[^}|%]/, "variable.liquid"]
  277. ]
  278. }
  279. };
  280. return __toCommonJS(liquid_exports);
  281. })();
  282. return moduleExports;
  283. });