markdown.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. define("vs/basic-languages/markdown/markdown",[],()=>{
  8. var moduleExports = (() => {
  9. var __defProp = Object.defineProperty;
  10. var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
  11. var __export = (target, all) => {
  12. __markAsModule(target);
  13. for (var name in all)
  14. __defProp(target, name, { get: all[name], enumerable: true });
  15. };
  16. // src/basic-languages/markdown/markdown.ts
  17. var markdown_exports = {};
  18. __export(markdown_exports, {
  19. conf: () => conf,
  20. language: () => language
  21. });
  22. var conf = {
  23. comments: {
  24. blockComment: ["<!--", "-->"]
  25. },
  26. brackets: [
  27. ["{", "}"],
  28. ["[", "]"],
  29. ["(", ")"]
  30. ],
  31. autoClosingPairs: [
  32. { open: "{", close: "}" },
  33. { open: "[", close: "]" },
  34. { open: "(", close: ")" },
  35. { open: "<", close: ">", notIn: ["string"] }
  36. ],
  37. surroundingPairs: [
  38. { open: "(", close: ")" },
  39. { open: "[", close: "]" },
  40. { open: "`", close: "`" }
  41. ],
  42. folding: {
  43. markers: {
  44. start: new RegExp("^\\s*<!--\\s*#?region\\b.*-->"),
  45. end: new RegExp("^\\s*<!--\\s*#?endregion\\b.*-->")
  46. }
  47. }
  48. };
  49. var language = {
  50. defaultToken: "",
  51. tokenPostfix: ".md",
  52. control: /[\\`*_\[\]{}()#+\-\.!]/,
  53. noncontrol: /[^\\`*_\[\]{}()#+\-\.!]/,
  54. escapes: /\\(?:@control)/,
  55. jsescapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
  56. empty: [
  57. "area",
  58. "base",
  59. "basefont",
  60. "br",
  61. "col",
  62. "frame",
  63. "hr",
  64. "img",
  65. "input",
  66. "isindex",
  67. "link",
  68. "meta",
  69. "param"
  70. ],
  71. tokenizer: {
  72. root: [
  73. [/^\s*\|/, "@rematch", "@table_header"],
  74. [/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ["white", "keyword", "keyword", "keyword"]],
  75. [/^\s*(=+|\-+)\s*$/, "keyword"],
  76. [/^\s*((\*[ ]?)+)\s*$/, "meta.separator"],
  77. [/^\s*>+/, "comment"],
  78. [/^\s*([\*\-+:]|\d+\.)\s/, "keyword"],
  79. [/^(\t|[ ]{4})[^ ].*$/, "string"],
  80. [/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: "string", next: "@codeblock" }],
  81. [
  82. /^\s*```\s*((?:\w|[\/\-#])+).*$/,
  83. { token: "string", next: "@codeblockgh", nextEmbedded: "$1" }
  84. ],
  85. [/^\s*```\s*$/, { token: "string", next: "@codeblock" }],
  86. { include: "@linecontent" }
  87. ],
  88. table_header: [
  89. { include: "@table_common" },
  90. [/[^\|]+/, "keyword.table.header"]
  91. ],
  92. table_body: [{ include: "@table_common" }, { include: "@linecontent" }],
  93. table_common: [
  94. [/\s*[\-:]+\s*/, { token: "keyword", switchTo: "table_body" }],
  95. [/^\s*\|/, "keyword.table.left"],
  96. [/^\s*[^\|]/, "@rematch", "@pop"],
  97. [/^\s*$/, "@rematch", "@pop"],
  98. [
  99. /\|/,
  100. {
  101. cases: {
  102. "@eos": "keyword.table.right",
  103. "@default": "keyword.table.middle"
  104. }
  105. }
  106. ]
  107. ],
  108. codeblock: [
  109. [/^\s*~~~\s*$/, { token: "string", next: "@pop" }],
  110. [/^\s*```\s*$/, { token: "string", next: "@pop" }],
  111. [/.*$/, "variable.source"]
  112. ],
  113. codeblockgh: [
  114. [/```\s*$/, { token: "string", next: "@pop", nextEmbedded: "@pop" }],
  115. [/[^`]+/, "variable.source"]
  116. ],
  117. linecontent: [
  118. [/&\w+;/, "string.escape"],
  119. [/@escapes/, "escape"],
  120. [/\b__([^\\_]|@escapes|_(?!_))+__\b/, "strong"],
  121. [/\*\*([^\\*]|@escapes|\*(?!\*))+\*\*/, "strong"],
  122. [/\b_[^_]+_\b/, "emphasis"],
  123. [/\*([^\\*]|@escapes)+\*/, "emphasis"],
  124. [/`([^\\`]|@escapes)+`/, "variable"],
  125. [/\{+[^}]+\}+/, "string.target"],
  126. [/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/, ["string.link", "", "string.link"]],
  127. [/(!?\[)((?:[^\]\\]|@escapes)*)(\])/, "string.link"],
  128. { include: "html" }
  129. ],
  130. html: [
  131. [/<(\w+)\/>/, "tag"],
  132. [
  133. /<(\w+)/,
  134. {
  135. cases: {
  136. "@empty": { token: "tag", next: "@tag.$1" },
  137. "@default": { token: "tag", next: "@tag.$1" }
  138. }
  139. }
  140. ],
  141. [/<\/(\w+)\s*>/, { token: "tag" }],
  142. [/<!--/, "comment", "@comment"]
  143. ],
  144. comment: [
  145. [/[^<\-]+/, "comment.content"],
  146. [/-->/, "comment", "@pop"],
  147. [/<!--/, "comment.content.invalid"],
  148. [/[<\-]/, "comment.content"]
  149. ],
  150. tag: [
  151. [/[ \t\r\n]+/, "white"],
  152. [
  153. /(type)(\s*=\s*)(")([^"]+)(")/,
  154. [
  155. "attribute.name.html",
  156. "delimiter.html",
  157. "string.html",
  158. { token: "string.html", switchTo: "@tag.$S2.$4" },
  159. "string.html"
  160. ]
  161. ],
  162. [
  163. /(type)(\s*=\s*)(')([^']+)(')/,
  164. [
  165. "attribute.name.html",
  166. "delimiter.html",
  167. "string.html",
  168. { token: "string.html", switchTo: "@tag.$S2.$4" },
  169. "string.html"
  170. ]
  171. ],
  172. [/(\w+)(\s*=\s*)("[^"]*"|'[^']*')/, ["attribute.name.html", "delimiter.html", "string.html"]],
  173. [/\w+/, "attribute.name.html"],
  174. [/\/>/, "tag", "@pop"],
  175. [
  176. />/,
  177. {
  178. cases: {
  179. "$S2==style": {
  180. token: "tag",
  181. switchTo: "embeddedStyle",
  182. nextEmbedded: "text/css"
  183. },
  184. "$S2==script": {
  185. cases: {
  186. $S3: {
  187. token: "tag",
  188. switchTo: "embeddedScript",
  189. nextEmbedded: "$S3"
  190. },
  191. "@default": {
  192. token: "tag",
  193. switchTo: "embeddedScript",
  194. nextEmbedded: "text/javascript"
  195. }
  196. }
  197. },
  198. "@default": { token: "tag", next: "@pop" }
  199. }
  200. }
  201. ]
  202. ],
  203. embeddedStyle: [
  204. [/[^<]+/, ""],
  205. [/<\/style\s*>/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }],
  206. [/</, ""]
  207. ],
  208. embeddedScript: [
  209. [/[^<]+/, ""],
  210. [/<\/script\s*>/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }],
  211. [/</, ""]
  212. ]
  213. }
  214. };
  215. return markdown_exports;
  216. })();
  217. return moduleExports;
  218. });