html.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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/html/html.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. { open: "[", close: "]" },
  67. { open: "(", close: ")" },
  68. { open: "<", close: ">" }
  69. ],
  70. onEnterRules: [
  71. {
  72. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  73. afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i,
  74. action: {
  75. indentAction: monaco_editor_core_exports.languages.IndentAction.IndentOutdent
  76. }
  77. },
  78. {
  79. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  80. action: { indentAction: monaco_editor_core_exports.languages.IndentAction.Indent }
  81. }
  82. ],
  83. folding: {
  84. markers: {
  85. start: new RegExp("^\\s*<!--\\s*#region\\b.*-->"),
  86. end: new RegExp("^\\s*<!--\\s*#endregion\\b.*-->")
  87. }
  88. }
  89. };
  90. var language = {
  91. defaultToken: "",
  92. tokenPostfix: ".html",
  93. ignoreCase: true,
  94. tokenizer: {
  95. root: [
  96. [/<!DOCTYPE/, "metatag", "@doctype"],
  97. [/<!--/, "comment", "@comment"],
  98. [/(<)((?:[\w\-]+:)?[\w\-]+)(\s*)(\/>)/, ["delimiter", "tag", "", "delimiter"]],
  99. [/(<)(script)/, ["delimiter", { token: "tag", next: "@script" }]],
  100. [/(<)(style)/, ["delimiter", { token: "tag", next: "@style" }]],
  101. [/(<)((?:[\w\-]+:)?[\w\-]+)/, ["delimiter", { token: "tag", next: "@otherTag" }]],
  102. [/(<\/)((?:[\w\-]+:)?[\w\-]+)/, ["delimiter", { token: "tag", next: "@otherTag" }]],
  103. [/</, "delimiter"],
  104. [/[^<]+/]
  105. ],
  106. doctype: [
  107. [/[^>]+/, "metatag.content"],
  108. [/>/, "metatag", "@pop"]
  109. ],
  110. comment: [
  111. [/-->/, "comment", "@pop"],
  112. [/[^-]+/, "comment.content"],
  113. [/./, "comment.content"]
  114. ],
  115. otherTag: [
  116. [/\/?>/, "delimiter", "@pop"],
  117. [/"([^"]*)"/, "attribute.value"],
  118. [/'([^']*)'/, "attribute.value"],
  119. [/[\w\-]+/, "attribute.name"],
  120. [/=/, "delimiter"],
  121. [/[ \t\r\n]+/]
  122. ],
  123. script: [
  124. [/type/, "attribute.name", "@scriptAfterType"],
  125. [/"([^"]*)"/, "attribute.value"],
  126. [/'([^']*)'/, "attribute.value"],
  127. [/[\w\-]+/, "attribute.name"],
  128. [/=/, "delimiter"],
  129. [
  130. />/,
  131. {
  132. token: "delimiter",
  133. next: "@scriptEmbedded",
  134. nextEmbedded: "text/javascript"
  135. }
  136. ],
  137. [/[ \t\r\n]+/],
  138. [/(<\/)(script\s*)(>)/, ["delimiter", "tag", { token: "delimiter", next: "@pop" }]]
  139. ],
  140. scriptAfterType: [
  141. [/=/, "delimiter", "@scriptAfterTypeEquals"],
  142. [
  143. />/,
  144. {
  145. token: "delimiter",
  146. next: "@scriptEmbedded",
  147. nextEmbedded: "text/javascript"
  148. }
  149. ],
  150. [/[ \t\r\n]+/],
  151. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  152. ],
  153. scriptAfterTypeEquals: [
  154. [
  155. /"([^"]*)"/,
  156. {
  157. token: "attribute.value",
  158. switchTo: "@scriptWithCustomType.$1"
  159. }
  160. ],
  161. [
  162. /'([^']*)'/,
  163. {
  164. token: "attribute.value",
  165. switchTo: "@scriptWithCustomType.$1"
  166. }
  167. ],
  168. [
  169. />/,
  170. {
  171. token: "delimiter",
  172. next: "@scriptEmbedded",
  173. nextEmbedded: "text/javascript"
  174. }
  175. ],
  176. [/[ \t\r\n]+/],
  177. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  178. ],
  179. scriptWithCustomType: [
  180. [
  181. />/,
  182. {
  183. token: "delimiter",
  184. next: "@scriptEmbedded.$S2",
  185. nextEmbedded: "$S2"
  186. }
  187. ],
  188. [/"([^"]*)"/, "attribute.value"],
  189. [/'([^']*)'/, "attribute.value"],
  190. [/[\w\-]+/, "attribute.name"],
  191. [/=/, "delimiter"],
  192. [/[ \t\r\n]+/],
  193. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  194. ],
  195. scriptEmbedded: [
  196. [/<\/script/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }],
  197. [/[^<]+/, ""]
  198. ],
  199. style: [
  200. [/type/, "attribute.name", "@styleAfterType"],
  201. [/"([^"]*)"/, "attribute.value"],
  202. [/'([^']*)'/, "attribute.value"],
  203. [/[\w\-]+/, "attribute.name"],
  204. [/=/, "delimiter"],
  205. [
  206. />/,
  207. {
  208. token: "delimiter",
  209. next: "@styleEmbedded",
  210. nextEmbedded: "text/css"
  211. }
  212. ],
  213. [/[ \t\r\n]+/],
  214. [/(<\/)(style\s*)(>)/, ["delimiter", "tag", { token: "delimiter", next: "@pop" }]]
  215. ],
  216. styleAfterType: [
  217. [/=/, "delimiter", "@styleAfterTypeEquals"],
  218. [
  219. />/,
  220. {
  221. token: "delimiter",
  222. next: "@styleEmbedded",
  223. nextEmbedded: "text/css"
  224. }
  225. ],
  226. [/[ \t\r\n]+/],
  227. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  228. ],
  229. styleAfterTypeEquals: [
  230. [
  231. /"([^"]*)"/,
  232. {
  233. token: "attribute.value",
  234. switchTo: "@styleWithCustomType.$1"
  235. }
  236. ],
  237. [
  238. /'([^']*)'/,
  239. {
  240. token: "attribute.value",
  241. switchTo: "@styleWithCustomType.$1"
  242. }
  243. ],
  244. [
  245. />/,
  246. {
  247. token: "delimiter",
  248. next: "@styleEmbedded",
  249. nextEmbedded: "text/css"
  250. }
  251. ],
  252. [/[ \t\r\n]+/],
  253. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  254. ],
  255. styleWithCustomType: [
  256. [
  257. />/,
  258. {
  259. token: "delimiter",
  260. next: "@styleEmbedded.$S2",
  261. nextEmbedded: "$S2"
  262. }
  263. ],
  264. [/"([^"]*)"/, "attribute.value"],
  265. [/'([^']*)'/, "attribute.value"],
  266. [/[\w\-]+/, "attribute.name"],
  267. [/=/, "delimiter"],
  268. [/[ \t\r\n]+/],
  269. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  270. ],
  271. styleEmbedded: [
  272. [/<\/style/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }],
  273. [/[^<]+/, ""]
  274. ]
  275. }
  276. };
  277. export {
  278. conf,
  279. language
  280. };