chrome-devtools-frontend 1.0.1636056 → 1.0.1640418

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/front_end/core/common/Color.ts +0 -4
  2. package/front_end/core/host/AidaClientTypes.ts +8 -6
  3. package/front_end/core/root/Runtime.ts +2 -2
  4. package/front_end/core/sdk/DOMStorageModel.ts +1 -1
  5. package/front_end/core/sdk/SourceMap.ts +8 -3
  6. package/front_end/core/sdk/TargetManager.ts +14 -1
  7. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +147 -0
  8. package/front_end/generated/ARIAProperties.js +17 -4
  9. package/front_end/generated/InspectorBackendCommands.ts +13 -7
  10. package/front_end/generated/SupportedCSSProperties.js +1 -0
  11. package/front_end/generated/protocol-mapping.d.ts +7 -0
  12. package/front_end/generated/protocol-proxy-api.d.ts +14 -0
  13. package/front_end/generated/protocol.ts +120 -2
  14. package/front_end/global_typings/global_defs.d.ts +13 -0
  15. package/front_end/models/ai_assistance/AiAgent2.ts +116 -0
  16. package/front_end/models/ai_assistance/AiConversation.ts +22 -36
  17. package/front_end/models/ai_assistance/AiHistoryStorage.ts +0 -1
  18. package/front_end/models/ai_assistance/AiOrigins.ts +46 -0
  19. package/front_end/models/ai_assistance/AiUtils.ts +9 -0
  20. package/front_end/models/ai_assistance/README.md +16 -0
  21. package/front_end/models/ai_assistance/StorageItem.ts +30 -26
  22. package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +12 -5
  23. package/front_end/models/ai_assistance/agents/AiAgent.ts +86 -32
  24. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +2 -2
  25. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +31 -10
  26. package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +1 -1
  27. package/front_end/models/ai_assistance/agents/FileAgent.ts +2 -2
  28. package/front_end/models/ai_assistance/agents/GreenDevAgent.ts +1 -3
  29. package/front_end/models/ai_assistance/agents/NetworkAgent.snapshot.txt +19 -0
  30. package/front_end/models/ai_assistance/agents/NetworkAgent.ts +9 -4
  31. package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +2 -2
  32. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +41 -12
  33. package/front_end/models/ai_assistance/agents/StorageAgent.ts +442 -122
  34. package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -2
  35. package/front_end/models/ai_assistance/ai_assistance.ts +4 -2
  36. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +2 -2
  37. package/front_end/models/ai_assistance/performance/AIContext.ts +7 -8
  38. package/front_end/models/ai_assistance/skills/README.md +40 -0
  39. package/front_end/models/ai_assistance/skills/Skill.ts +13 -0
  40. package/front_end/models/ai_assistance/skills/SkillRegistry.ts +10 -0
  41. package/front_end/models/ai_assistance/skills/styling.md +6 -0
  42. package/front_end/models/bindings/CompilerScriptMapping.ts +12 -4
  43. package/front_end/models/breakpoints/BreakpointManager.ts +54 -2
  44. package/front_end/models/greendev/Prototypes.ts +0 -7
  45. package/front_end/models/heap_snapshot/HeapSnapshotModel.ts +20 -0
  46. package/front_end/models/heap_snapshot/HeapSnapshotProxy.ts +5 -0
  47. package/front_end/models/issues_manager/EmailVerificationRequestIssue.ts +293 -0
  48. package/front_end/models/issues_manager/IssuesManager.ts +5 -0
  49. package/front_end/models/issues_manager/descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
  50. package/front_end/models/issues_manager/descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
  51. package/front_end/models/issues_manager/descriptions/emailVerificationRequestInvalidEmail.md +1 -0
  52. package/front_end/models/issues_manager/descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
  53. package/front_end/models/issues_manager/descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
  54. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
  55. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
  56. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
  57. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
  58. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
  59. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
  60. package/front_end/models/issues_manager/descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
  61. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
  62. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
  63. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
  64. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
  65. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
  66. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
  67. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
  68. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
  69. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
  70. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
  71. package/front_end/models/issues_manager/issues_manager.ts +2 -0
  72. package/front_end/models/javascript_metadata/NativeFunctions.js +1748 -1739
  73. package/front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts +1 -1
  74. package/front_end/models/stack_trace/DetailedErrorStackParser.ts +9 -1
  75. package/front_end/models/stack_trace/StackTraceImpl.ts +29 -9
  76. package/front_end/models/stack_trace/StackTraceModel.ts +23 -11
  77. package/front_end/models/stack_trace/Trie.ts +11 -1
  78. package/front_end/models/trace/extras/TraceTree.ts +20 -1
  79. package/front_end/models/trace/insights/Common.ts +9 -0
  80. package/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +21 -25
  81. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +19 -75
  82. package/front_end/panels/ai_assistance/components/AccessibilityAgentMarkdownRenderer.ts +10 -3
  83. package/front_end/panels/ai_assistance/components/ChatMessage.ts +148 -2
  84. package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +2 -3
  85. package/front_end/panels/ai_assistance/components/chatMessage.css +27 -0
  86. package/front_end/panels/application/CookieItemsView.ts +24 -0
  87. package/front_end/panels/application/DOMStorageItemsView.ts +9 -4
  88. package/front_end/panels/application/preloading/components/PreloadingString.ts +6 -0
  89. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +4 -4
  90. package/front_end/panels/console/ConsoleViewMessage.ts +13 -102
  91. package/front_end/panels/elements/StandaloneStylesContainer.ts +10 -0
  92. package/front_end/panels/elements/StylePropertiesSection.ts +6 -2
  93. package/front_end/panels/elements/StylePropertyTreeElement.ts +30 -1
  94. package/front_end/panels/elements/StylesContainer.ts +3 -0
  95. package/front_end/panels/elements/StylesSidebarPane.ts +54 -4
  96. package/front_end/panels/elements/elements-meta.ts +14 -0
  97. package/front_end/panels/layer_viewer/layerDetailsView.css +1 -1
  98. package/front_end/panels/lighthouse/LighthouseController.ts +1 -1
  99. package/front_end/panels/lighthouse/LighthouseProtocolService.ts +4 -4
  100. package/front_end/panels/network/NetworkDataGridNode.ts +14 -0
  101. package/front_end/panels/network/NetworkLogViewColumns.ts +2 -2
  102. package/front_end/panels/network/RequestHeadersView.ts +55 -19
  103. package/front_end/panels/network/networkTimingTable.css +2 -4
  104. package/front_end/panels/recorder/components/ReplaySection.ts +28 -16
  105. package/front_end/panels/recorder/converters/LighthouseConverter.snapshot.txt +47 -0
  106. package/front_end/panels/recorder/converters/PuppeteerConverter.snapshot.txt +49 -0
  107. package/front_end/panels/recorder/converters/PuppeteerReplayConverter.snapshot.txt +33 -0
  108. package/front_end/panels/settings/SettingsScreen.ts +1 -2
  109. package/front_end/panels/sources/BreakpointsView.ts +23 -42
  110. package/front_end/panels/sources/DebuggerPlugin.ts +12 -5
  111. package/front_end/panels/sources/ScopeChainSidebarPane.ts +169 -106
  112. package/front_end/panels/timeline/components/IgnoreListSetting.ts +1 -0
  113. package/front_end/third_party/chromium/README.chromium +1 -1
  114. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +2 -2
  115. package/front_end/third_party/marked/README.chromium +3 -6
  116. package/front_end/third_party/marked/package/README.md +5 -5
  117. package/front_end/third_party/marked/package/bin/main.js +27 -22
  118. package/front_end/third_party/marked/package/bin/marked.js +2 -1
  119. package/front_end/third_party/marked/package/lib/marked.esm.d.ts +346 -256
  120. package/front_end/third_party/marked/package/lib/marked.esm.js +67 -2698
  121. package/front_end/third_party/marked/package/lib/marked.esm.js.map +7 -1
  122. package/front_end/third_party/marked/package/lib/marked.umd.js +69 -2722
  123. package/front_end/third_party/marked/package/lib/marked.umd.js.map +7 -1
  124. package/front_end/third_party/marked/package/man/marked.1 +4 -2
  125. package/front_end/third_party/marked/package/man/marked.1.md +2 -1
  126. package/front_end/third_party/marked/package/package.json +49 -57
  127. package/front_end/third_party/puppeteer-replay/README.chromium +2 -2
  128. package/front_end/third_party/puppeteer-replay/package/lib/cli.js +84 -80
  129. package/front_end/third_party/puppeteer-replay/package/lib/cli.js.map +1 -1
  130. package/front_end/third_party/puppeteer-replay/package/lib/extension-test.js +79 -83
  131. package/front_end/third_party/puppeteer-replay/package/lib/extension-test.js.map +1 -1
  132. package/front_end/third_party/puppeteer-replay/package/lib/main.d.ts +43 -171
  133. package/front_end/third_party/puppeteer-replay/package/lib/main.js +51 -206
  134. package/front_end/third_party/puppeteer-replay/package/lib/main.js.map +1 -1
  135. package/front_end/third_party/puppeteer-replay/package/package.json +37 -67
  136. package/front_end/tsconfig.json +1 -1
  137. package/front_end/ui/components/markdown_view/CodeBlock.ts +17 -6
  138. package/front_end/ui/components/markdown_view/MarkdownView.ts +39 -3
  139. package/front_end/ui/components/markdown_view/codeBlock.css +11 -0
  140. package/front_end/ui/components/markdown_view/markdownView.css +17 -0
  141. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +0 -79
  142. package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +16 -4
  143. package/front_end/ui/visual_logging/KnownContextValues.ts +4 -0
  144. package/inspector_overlay/testing/InspectorOverlayHelpers.ts +2 -0
  145. package/mcp/mcp.ts +1 -6
  146. package/package.json +14 -16
  147. package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgent.ts +0 -1015
  148. package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgentOverlay.ts +0 -87
  149. package/front_end/third_party/marked/package/bin/marked +0 -215
  150. package/front_end/third_party/marked/package/lib/marked.cjs +0 -2726
  151. package/front_end/third_party/marked/package/lib/marked.cjs.map +0 -1
  152. package/front_end/third_party/marked/package/lib/marked.d.cts +0 -670
  153. package/front_end/third_party/marked/package/lib/marked.js +0 -2780
  154. package/front_end/third_party/marked/package/man/marked.1.txt +0 -86
  155. package/front_end/third_party/marked/package/marked.min.js +0 -6
  156. package/front_end/third_party/marked/package/src/Lexer.js +0 -492
  157. package/front_end/third_party/marked/package/src/Parser.js +0 -286
  158. package/front_end/third_party/marked/package/src/Renderer.js +0 -166
  159. package/front_end/third_party/marked/package/src/Slugger.js +0 -49
  160. package/front_end/third_party/marked/package/src/TextRenderer.js +0 -42
  161. package/front_end/third_party/marked/package/src/Tokenizer.js +0 -755
  162. package/front_end/third_party/marked/package/src/defaults.js +0 -29
  163. package/front_end/third_party/marked/package/src/helpers.js +0 -249
  164. package/front_end/third_party/marked/package/src/marked.js +0 -350
  165. package/front_end/third_party/marked/package/src/rules.js +0 -285
  166. package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.cjs +0 -2099
  167. package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.cjs.map +0 -1
  168. package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.d.cts +0 -686
  169. package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.d.ts +0 -35
  170. package/mcp/HostBindings.ts +0 -319
  171. /package/front_end/third_party/marked/package/{LICENSE.md → LICENSE} +0 -0
@@ -1,6 +1,7 @@
1
1
  /**
2
- * marked v13.0.1 - a markdown parser
3
- * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
2
+ * marked v18.0.4 - a markdown parser
3
+ * Copyright (c) 2018-2026, MarkedJS. (MIT License)
4
+ * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
4
5
  * https://github.com/markedjs/marked
5
6
  */
6
7
 
@@ -8,2725 +9,71 @@
8
9
  * DO NOT EDIT THIS FILE
9
10
  * The code in this file is generated from files in ./src/
10
11
  */
12
+ (function(g,f){if(typeof exports=="object"&&typeof module<"u"){module.exports=f()}else if("function"==typeof define && define.amd){define("marked",f)}else {g["marked"]=f()}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports};
13
+ "use strict";var N=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var Pe=(l,e)=>{for(var t in e)N(l,t,{get:e[t],enumerable:!0})},Se=(l,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of we(e))!ye.call(l,s)&&s!==t&&N(l,s,{get:()=>e[s],enumerable:!(n=Oe(e,s))||n.enumerable});return l};var $e=l=>Se(N({},"__esModule",{value:!0}),l);var Rt={};Pe(Rt,{Hooks:()=>P,Lexer:()=>x,Marked:()=>C,Parser:()=>b,Renderer:()=>y,TextRenderer:()=>S,Tokenizer:()=>w,defaults:()=>T,getDefaults:()=>_,lexer:()=>bt,marked:()=>g,options:()=>ht,parse:()=>mt,parseInline:()=>ft,parser:()=>xt,setOptions:()=>kt,use:()=>dt,walkTokens:()=>gt});module.exports=$e(Rt);function _(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var T=_();function Q(l){T=l}var z={exec:()=>null};function E(l){let e=[];return t=>{let n=Math.max(0,Math.min(3,t-1)),s=e[n];return s||(s=l(n),e[n]=s),s}}function d(l,e=""){let t=typeof l=="string"?l:l.source,n={replace:(s,r)=>{let i=typeof r=="string"?r:r.source;return i=i.replace(m.caret,"$1"),t=t.replace(s,i),n},getRegex:()=>new RegExp(t,e)};return n}var Le=((l="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+l)}catch{return!1}})(),m={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:l=>new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:E(l=>new RegExp(`^ {0,${l}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:E(l=>new RegExp(`^ {0,${l}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:E(l=>new RegExp(`^ {0,${l}}(?:\`\`\`|~~~)`)),headingBeginRegex:E(l=>new RegExp(`^ {0,${l}}#`)),htmlBeginRegex:E(l=>new RegExp(`^ {0,${l}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:E(l=>new RegExp(`^ {0,${l}}>`))},_e=/^(?:[ \t]*(?:\n|$))+/,ze=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Me=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,D=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ee=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,F=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ae=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,le=d(ae).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ie=d(ae).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),U=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ae=/^[^\n]+/,K=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ce=d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",K).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Be=d(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,F).getRegex(),H="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",W=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,De=d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",W).replace("tag",H).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ue=d(U).replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex(),qe=d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ue).getRegex(),X={blockquote:qe,code:ze,def:Ce,fences:Me,heading:Ee,hr:D,html:De,lheading:le,list:Be,newline:_e,paragraph:ue,table:z,text:Ae},ie=d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex(),ve={...X,lheading:Ie,table:ie,paragraph:d(U).replace("hr",D).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ie).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H).getRegex()},He={...X,html:d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",W).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:z,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:d(U).replace("hr",D).replace("heading",` *#{1,6} *[^
14
+ ]`).replace("lheading",le).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ze=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ge=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pe=/^( {2,}|\\)\n(?!\s*$)/,Ne=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,I=/[\p{P}\p{S}]/u,Z=/[\s\p{P}\p{S}]/u,J=/[^\s\p{P}\p{S}]/u,Qe=d(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Z).getRegex(),ce=/(?!~)[\p{P}\p{S}]/u,je=/(?!~)[\s\p{P}\p{S}]/u,Fe=/(?:[^\s\p{P}\p{S}]|~)/u,Ue=d(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Le?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),he=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ke=d(he,"u").replace(/punct/g,I).getRegex(),We=d(he,"u").replace(/punct/g,ce).getRegex(),ke="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Xe=d(ke,"gu").replace(/notPunctSpace/g,J).replace(/punctSpace/g,Z).replace(/punct/g,I).getRegex(),Je=d(ke,"gu").replace(/notPunctSpace/g,Fe).replace(/punctSpace/g,je).replace(/punct/g,ce).getRegex(),Ve=d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,J).replace(/punctSpace/g,Z).replace(/punct/g,I).getRegex(),Ye=d(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,I).getRegex(),et="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",tt=d(et,"gu").replace(/notPunctSpace/g,J).replace(/punctSpace/g,Z).replace(/punct/g,I).getRegex(),nt=d(/\\(punct)/,"gu").replace(/punct/g,I).getRegex(),rt=d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),st=d(W).replace("(?:-->|$)","-->").getRegex(),it=d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",st).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),v=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ot=d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",v).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),de=d(/^!?\[(label)\]\[(ref)\]/).replace("label",v).replace("ref",K).getRegex(),ge=d(/^!?\[(ref)\](?:\[\])?/).replace("ref",K).getRegex(),at=d("reflink|nolink(?!\\()","g").replace("reflink",de).replace("nolink",ge).getRegex(),oe=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,V={_backpedal:z,anyPunctuation:nt,autolink:rt,blockSkip:Ue,br:pe,code:Ge,del:z,delLDelim:z,delRDelim:z,emStrongLDelim:Ke,emStrongRDelimAst:Xe,emStrongRDelimUnd:Ve,escape:Ze,link:ot,nolink:ge,punctuation:Qe,reflink:de,reflinkSearch:at,tag:it,text:Ne,url:z},lt={...V,link:d(/^!?\[(label)\]\((.*?)\)/).replace("label",v).getRegex(),reflink:d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",v).getRegex()},j={...V,emStrongRDelimAst:Je,emStrongLDelim:We,delLDelim:Ye,delRDelim:tt,url:d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",oe).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",oe).getRegex()},ut={...j,br:d(pe).replace("{2,}","*").getRegex(),text:d(j.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},q={normal:X,gfm:ve,pedantic:He},A={normal:V,gfm:j,breaks:ut,pedantic:lt};var pt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},fe=l=>pt[l];function O(l,e){if(e){if(m.escapeTest.test(l))return l.replace(m.escapeReplace,fe)}else if(m.escapeTestNoEncode.test(l))return l.replace(m.escapeReplaceNoEncode,fe);return l}function Y(l){try{l=encodeURI(l).replace(m.percentDecode,"%")}catch{return null}return l}function ee(l,e){let t=l.replace(m.findPipe,(r,i,o)=>{let u=!1,a=i;for(;--a>=0&&o[a]==="\\";)u=!u;return u?"|":" |"}),n=t.split(m.splitPipe),s=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(m.slashPipe,"|");return n}function L(l,e,t){let n=l.length;if(n===0)return"";let s=0;for(;s<n;){let r=l.charAt(n-s-1);if(r===e&&!t)s++;else if(r!==e&&t)s++;else break}return l.slice(0,n-s)}function te(l){let e=l.split(`
15
+ `),t=e.length-1;for(;t>=0&&m.blankLine.test(e[t]);)t--;return e.length-t<=2?l:e.slice(0,t+1).join(`
16
+ `)}function me(l,e){if(l.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<l.length;n++)if(l[n]==="\\")n++;else if(l[n]===e[0])t++;else if(l[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function xe(l,e=0){let t=e,n="";for(let s of l)if(s===" "){let r=4-t%4;n+=" ".repeat(r),t+=r}else n+=s,t++;return n}function be(l,e,t,n,s){let r=e.href,i=e.title||null,o=l[1].replace(s.other.outputLinkReplace,"$1");n.state.inLink=!0;let u={type:l[0].charAt(0)==="!"?"image":"link",raw:t,href:r,title:i,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=!1,u}function ct(l,e,t){let n=l.match(t.other.indentCodeCompensation);if(n===null)return e;let s=n[1];return e.split(`
17
+ `).map(r=>{let i=r.match(t.other.beginningSpace);if(i===null)return r;let[o]=i;return o.length>=s.length?r.slice(s.length):r}).join(`
18
+ `)}var w=class{options;rules;lexer;constructor(e){this.options=e||T}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:te(t[0]),s=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:s}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=ct(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=L(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:L(t[0],`
19
+ `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:L(t[0],`
20
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=L(t[0],`
21
+ `).split(`
22
+ `),s="",r="",i=[];for(;n.length>0;){let o=!1,u=[],a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))u.push(n[a]),o=!0;else if(!o)u.push(n[a]);else break;n=n.slice(a);let c=u.join(`
23
+ `),p=c.replace(this.rules.other.blockquoteSetextReplace,`
24
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
25
+ ${c}`:c,r=r?`${r}
26
+ ${p}`:p;let k=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,i,!0),this.lexer.state.top=k,n.length===0)break;let h=i.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let R=h,f=R.raw+`
27
+ `+n.join(`
28
+ `),$=this.blockquote(f);i[i.length-1]=$,s=s.substring(0,s.length-R.raw.length)+$.raw,r=r.substring(0,r.length-R.text.length)+$.text;break}else if(h?.type==="list"){let R=h,f=R.raw+`
29
+ `+n.join(`
30
+ `),$=this.list(f);i[i.length-1]=$,s=s.substring(0,s.length-h.raw.length)+$.raw,r=r.substring(0,r.length-R.raw.length)+$.raw,n=f.substring(i.at(-1).raw.length).split(`
31
+ `);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let i=this.rules.other.listItemRegex(n),o=!1;for(;e;){let a=!1,c="",p="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let k=xe(t[2].split(`
32
+ `,1)[0],t[1].length),h=e.split(`
33
+ `,1)[0],R=!k.trim(),f=0;if(this.options.pedantic?(f=2,p=k.trimStart()):R?f=t[1].length+1:(f=k.search(this.rules.other.nonSpaceChar),f=f>4?1:f,p=k.slice(f),f+=t[1].length),R&&this.rules.other.blankLine.test(h)&&(c+=h+`
34
+ `,e=e.substring(h.length+1),a=!0),!a){let $=this.rules.other.nextBulletRegex(f),ne=this.rules.other.hrRegex(f),re=this.rules.other.fencesBeginRegex(f),se=this.rules.other.headingBeginRegex(f),Re=this.rules.other.htmlBeginRegex(f),Te=this.rules.other.blockquoteBeginRegex(f);for(;e;){let G=e.split(`
35
+ `,1)[0],B;if(h=G,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),B=h):B=h.replace(this.rules.other.tabCharGlobal," "),re.test(h)||se.test(h)||Re.test(h)||Te.test(h)||$.test(h)||ne.test(h))break;if(B.search(this.rules.other.nonSpaceChar)>=f||!h.trim())p+=`
36
+ `+B.slice(f);else{if(R||k.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||re.test(k)||se.test(k)||ne.test(k))break;p+=`
37
+ `+h}R=!h.trim(),c+=G+`
38
+ `,e=e.substring(G.length+1),k=B.slice(f)}}r.loose||(o?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),r.raw+=c}let u=r.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let a of r.items){this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]);let c=a.tokens[0];if(a.task&&(c?.type==="text"||c?.type==="paragraph")){a.text=a.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let k=this.lexer.inlineQueue.length-1;k>=0;k--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)){this.lexer.inlineQueue[k].src=this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask,"");break}let p=this.rules.other.listTaskCheckbox.exec(a.raw);if(p){let k={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};a.checked=k.checked,r.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=k.raw+a.tokens[0].raw,a.tokens[0].text=k.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(k)):a.tokens.unshift({type:"paragraph",raw:k.raw,text:k.raw,tokens:[k]}):a.tokens.unshift(k)}}else a.task&&(a.task=!1);if(!r.loose){let p=a.tokens.filter(h=>h.type==="space"),k=p.length>0&&p.some(h=>this.rules.other.anyLine.test(h.raw));r.loose=k}}if(r.loose)for(let a of r.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=te(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:L(t[0],`
39
+ `),href:s,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ee(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
40
+ `):[],i={type:"table",raw:L(t[0],`
41
+ `),header:[],align:[],rows:[]};if(n.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<n.length;o++)i.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:i.align[o]});for(let o of r)i.rows.push(ee(o,i.header.length).map((u,a)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:i.align[a]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:L(t[0],`
42
+ `),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
43
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=L(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=me(t[2],"()");if(i===-2)return;if(i>-1){let u=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,u).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),be(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[s.toLowerCase()];if(!r){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return be(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[3]||"")||!n||this.rules.inline.punctuation.exec(n)){let i=[...s[0]].length-1,o,u,a=i,c=0,p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+i);(s=p.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(u=[...o].length,s[3]||s[4]){a+=u;continue}else if((s[5]||s[6])&&i%3&&!((i+u)%3)){c+=u;continue}if(a-=u,a>0)continue;u=Math.min(u,u+a+c);let k=[...s[0]][0].length,h=e.slice(0,i+s.index+k+u);if(Math.min(i,u)%2){let f=h.slice(1,-1);return{type:"em",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}let R=h.slice(2,-2);return{type:"strong",raw:h,text:R,tokens:this.lexer.inlineTokens(R)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let s=this.rules.inline.delLDelim.exec(e);if(!s)return;if(!(s[1]||"")||!n||this.rules.inline.punctuation.exec(n)){let i=[...s[0]].length-1,o,u,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*e.length+i);(s=c.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o||(u=[...o].length,u!==i))continue;if(s[3]||s[4]){a+=u;continue}if(a-=u,a>0)continue;u=Math.min(u,u+a);let p=[...s[0]][0].length,k=e.slice(0,i+s.index+p+u),h=k.slice(i,-i);return{type:"del",raw:k,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}};var x=class l{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||T,this.options.tokenizer=this.options.tokenizer||new w,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:m,block:q.normal,inline:A.normal};this.options.pedantic?(t.block=q.pedantic,t.inline=A.pedantic):this.options.gfm&&(t.block=q.gfm,this.options.breaks?t.inline=A.breaks:t.inline=A.gfm),this.tokenizer.rules=t}static get rules(){return{block:q,inline:A}}static lex(e,t){return new l(t).lex(e)}static lexInline(e,t){return new l(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,`
44
+ `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(m.tabCharGlobal," ").replace(m.spaceLine,""));let s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let r;if(this.options.extensions?.block?.some(o=>(r=o.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let o=t.at(-1);r.raw.length===1&&o!==void 0?o.raw+=`
45
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let o=t.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
46
+ `)?"":`
47
+ `)+r.raw,o.text+=`
48
+ `+r.text,this.inlineQueue.at(-1).src=o.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let o=t.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
49
+ `)?"":`
50
+ `)+r.raw,o.text+=`
51
+ `+r.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let o=1/0,u=e.slice(1),a;this.options.extensions.startBlock.forEach(c=>{a=c.call({lexer:this},u),typeof a=="number"&&a>=0&&(o=Math.min(o,a))}),o<1/0&&o>=0&&(i=e.substring(0,o+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let o=t.at(-1);n&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
52
+ `)?"":`
53
+ `)+r.raw,o.text+=`
54
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let o=t.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
55
+ `)?"":`
56
+ `)+r.raw,o.text+=`
57
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(r);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,s=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)a.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,s.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let r;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)r=s[2]?s[2].length:0,n=n.slice(0,s.index+r)+"["+"a".repeat(s[0].length-r-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=!1,o="",u=1/0;for(;e;){if(e.length<u)u=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(o=""),i=!1;let a;if(this.options.extensions?.inline?.some(p=>(a=p.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let p=t.at(-1);a.type==="text"&&p?.type==="text"?(p.raw+=a.raw,p.text+=a.text):t.push(a);continue}if(a=this.tokenizer.emStrong(e,n,o)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.del(e,n,o)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),t.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if(this.options.extensions?.startInline){let p=1/0,k=e.slice(1),h;this.options.extensions.startInline.forEach(R=>{h=R.call({lexer:this},k),typeof h=="number"&&h>=0&&(p=Math.min(p,h))}),p<1/0&&p>=0&&(c=e.substring(0,p+1))}if(a=this.tokenizer.inlineText(c)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(o=a.raw.slice(-1)),i=!0;let p=t.at(-1);p?.type==="text"?(p.raw+=a.raw,p.text+=a.text):t.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw new Error(t)}};var y=class{options;parser;constructor(e){this.options=e||T}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(m.notSpaceStart)?.[0],r=e.replace(m.endingNewline,"")+`
58
+ `;return s?'<pre><code class="language-'+O(s)+'">'+(n?r:O(r,!0))+`</code></pre>
59
+ `:"<pre><code>"+(n?r:O(r,!0))+`</code></pre>
60
+ `}blockquote({tokens:e}){return`<blockquote>
61
+ ${this.parser.parse(e)}</blockquote>
62
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
63
+ `}hr(e){return`<hr>
64
+ `}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o<e.items.length;o++){let u=e.items[o];s+=this.listitem(u)}let r=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+r+i+`>
65
+ `+s+"</"+r+`>
66
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
67
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
68
+ `}table(e){let t="",n="";for(let r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});let s="";for(let r=0;r<e.rows.length;r++){let i=e.rows[r];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
69
+ <thead>
70
+ `+t+`</thead>
71
+ `+s+`</table>
72
+ `}tablerow({text:e}){return`<tr>
73
+ ${e}</tr>
74
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
75
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${O(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),r=Y(e);if(r===null)return s;e=r;let i='<a href="'+e+'"';return t&&(i+=' title="'+O(t)+'"'),i+=">"+s+"</a>",i}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=Y(e);if(r===null)return O(n);e=r;let i=`<img src="${e}" alt="${O(n)}"`;return t&&(i+=` title="${O(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:O(e.text)}};var S=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}};var b=class l{options;renderer;textRenderer;constructor(e){this.options=e||T,this.options.renderer=this.options.renderer||new y,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new S}static parse(e,t){return new l(t).parse(e)}static parseInline(e,t){return new l(t).parseInline(e)}parse(e){this.renderer.parser=this;let t="";for(let n=0;n<e.length;n++){let s=e[n];if(this.options.extensions?.renderers?.[s.type]){let i=s,o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){t+=o||"";continue}}let r=s;switch(r.type){case"space":{t+=this.renderer.space(r);break}case"hr":{t+=this.renderer.hr(r);break}case"heading":{t+=this.renderer.heading(r);break}case"code":{t+=this.renderer.code(r);break}case"table":{t+=this.renderer.table(r);break}case"blockquote":{t+=this.renderer.blockquote(r);break}case"list":{t+=this.renderer.list(r);break}case"checkbox":{t+=this.renderer.checkbox(r);break}case"html":{t+=this.renderer.html(r);break}case"def":{t+=this.renderer.def(r);break}case"paragraph":{t+=this.renderer.paragraph(r);break}case"text":{t+=this.renderer.text(r);break}default:{let i='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let r=e[s];if(this.options.extensions?.renderers?.[r.type]){let o=this.options.extensions.renderers[r.type].call({parser:this},r);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=o||"";continue}}let i=r;switch(i.type){case"escape":{n+=t.text(i);break}case"html":{n+=t.html(i);break}case"link":{n+=t.link(i);break}case"image":{n+=t.image(i);break}case"checkbox":{n+=t.checkbox(i);break}case"strong":{n+=t.strong(i);break}case"em":{n+=t.em(i);break}case"codespan":{n+=t.codespan(i);break}case"br":{n+=t.br(i);break}case"del":{n+=t.del(i);break}case"text":{n+=t.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}};var P=class{options;block;constructor(e){this.options=e||T}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?x.lex:x.lexInline}provideParser(e=this.block){return e?b.parse:b.parseInline}};var C=class{defaults=_();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=b;Renderer=y;TextRenderer=S;Lexer=x;Tokenizer=w;Hooks=P;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let r=s;for(let i of r.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of r.rows)for(let o of i)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let r=s;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{let o=r[i].flat(1/0);n=n.concat(this.walkTokens(o,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=t.renderers[r.name];i?t.renderers[r.name]=function(...o){let u=r.renderer.apply(this,o);return u===!1&&(u=i.apply(this,o)),u}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[r.level];i?i.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),n.renderer){let r=this.defaults.renderer||new y(this.defaults);for(let i in n.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,u=n.renderer[o],a=r[o];r[o]=(...c)=>{let p=u.apply(r,c);return p===!1&&(p=a.apply(r,c)),p||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new w(this.defaults);for(let i in n.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,u=n.tokenizer[o],a=r[o];r[o]=(...c)=>{let p=u.apply(r,c);return p===!1&&(p=a.apply(r,c)),p}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new P;for(let i in n.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,u=n.hooks[o],a=r[o];P.passThroughHooks.has(i)?r[o]=c=>{if(this.defaults.async&&P.passThroughHooksRespectAsync.has(i))return(async()=>{let k=await u.call(r,c);return a.call(r,k)})();let p=u.call(r,c);return a.call(r,p)}:r[o]=(...c)=>{if(this.defaults.async)return(async()=>{let k=await u.apply(r,c);return k===!1&&(k=await a.apply(r,c)),k})();let p=u.apply(r,c);return p===!1&&(p=a.apply(r,c)),p}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,i=n.walkTokens;s.walkTokens=function(o){let u=[];return u.push(i.call(this,o)),r&&(u=u.concat(r.call(this,o))),u}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return x.lex(e,t??this.defaults)}parser(e,t){return b.parse(e,t??this.defaults)}parseMarkdown(e){return(n,s)=>{let r={...s},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let u=i.hooks?await i.hooks.preprocess(n):n,c=await(i.hooks?await i.hooks.provideLexer(e):e?x.lex:x.lexInline)(u,i),p=i.hooks?await i.hooks.processAllTokens(c):c;i.walkTokens&&await Promise.all(this.walkTokens(p,i.walkTokens));let h=await(i.hooks?await i.hooks.provideParser(e):e?b.parse:b.parseInline)(p,i);return i.hooks?await i.hooks.postprocess(h):h})().catch(o);try{i.hooks&&(n=i.hooks.preprocess(n));let a=(i.hooks?i.hooks.provideLexer(e):e?x.lex:x.lexInline)(n,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let p=(i.hooks?i.hooks.provideParser(e):e?b.parse:b.parseInline)(a,i);return i.hooks&&(p=i.hooks.postprocess(p)),p}catch(u){return o(u)}}}onError(e,t){return n=>{if(n.message+=`
76
+ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+O(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}};var M=new C;function g(l,e){return M.parse(l,e)}g.options=g.setOptions=function(l){return M.setOptions(l),g.defaults=M.defaults,Q(g.defaults),g};g.getDefaults=_;g.defaults=T;g.use=function(...l){return M.use(...l),g.defaults=M.defaults,Q(g.defaults),g};g.walkTokens=function(l,e){return M.walkTokens(l,e)};g.parseInline=M.parseInline;g.Parser=b;g.parser=b.parse;g.Renderer=y;g.TextRenderer=S;g.Lexer=x;g.lexer=x.lex;g.Tokenizer=w;g.Hooks=P;g.parse=g;var ht=g.options,kt=g.setOptions,dt=g.use,gt=g.walkTokens,ft=g.parseInline,mt=g,xt=b.parse,bt=x.lex;
11
77
 
12
- (function (global, factory) {
13
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
14
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
15
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.marked = {}));
16
- })(this, (function (exports) { 'use strict';
17
-
18
- /**
19
- * Gets the original marked default options.
20
- */
21
- function _getDefaults() {
22
- return {
23
- async: false,
24
- breaks: false,
25
- extensions: null,
26
- gfm: true,
27
- hooks: null,
28
- pedantic: false,
29
- renderer: null,
30
- silent: false,
31
- tokenizer: null,
32
- walkTokens: null
33
- };
34
- }
35
- exports.defaults = _getDefaults();
36
- function changeDefaults(newDefaults) {
37
- exports.defaults = newDefaults;
38
- }
39
-
40
- /**
41
- * Helpers
42
- */
43
- const escapeTest = /[&<>"']/;
44
- const escapeReplace = new RegExp(escapeTest.source, 'g');
45
- const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
46
- const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
47
- const escapeReplacements = {
48
- '&': '&amp;',
49
- '<': '&lt;',
50
- '>': '&gt;',
51
- '"': '&quot;',
52
- "'": '&#39;'
53
- };
54
- const getEscapeReplacement = (ch) => escapeReplacements[ch];
55
- function escape$1(html, encode) {
56
- if (encode) {
57
- if (escapeTest.test(html)) {
58
- return html.replace(escapeReplace, getEscapeReplacement);
59
- }
60
- }
61
- else {
62
- if (escapeTestNoEncode.test(html)) {
63
- return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
64
- }
65
- }
66
- return html;
67
- }
68
- const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
69
- function unescape(html) {
70
- // explicitly match decimal, hex, and named HTML entities
71
- return html.replace(unescapeTest, (_, n) => {
72
- n = n.toLowerCase();
73
- if (n === 'colon')
74
- return ':';
75
- if (n.charAt(0) === '#') {
76
- return n.charAt(1) === 'x'
77
- ? String.fromCharCode(parseInt(n.substring(2), 16))
78
- : String.fromCharCode(+n.substring(1));
79
- }
80
- return '';
81
- });
82
- }
83
- const caret = /(^|[^\[])\^/g;
84
- function edit(regex, opt) {
85
- let source = typeof regex === 'string' ? regex : regex.source;
86
- opt = opt || '';
87
- const obj = {
88
- replace: (name, val) => {
89
- let valSource = typeof val === 'string' ? val : val.source;
90
- valSource = valSource.replace(caret, '$1');
91
- source = source.replace(name, valSource);
92
- return obj;
93
- },
94
- getRegex: () => {
95
- return new RegExp(source, opt);
96
- }
97
- };
98
- return obj;
99
- }
100
- function cleanUrl(href) {
101
- try {
102
- href = encodeURI(href).replace(/%25/g, '%');
103
- }
104
- catch (e) {
105
- return null;
106
- }
107
- return href;
108
- }
109
- const noopTest = { exec: () => null };
110
- function splitCells(tableRow, count) {
111
- // ensure that every cell-delimiting pipe has a space
112
- // before it to distinguish it from an escaped pipe
113
- const row = tableRow.replace(/\|/g, (match, offset, str) => {
114
- let escaped = false;
115
- let curr = offset;
116
- while (--curr >= 0 && str[curr] === '\\')
117
- escaped = !escaped;
118
- if (escaped) {
119
- // odd number of slashes means | is escaped
120
- // so we leave it alone
121
- return '|';
122
- }
123
- else {
124
- // add space before unescaped |
125
- return ' |';
126
- }
127
- }), cells = row.split(/ \|/);
128
- let i = 0;
129
- // First/last cell in a row cannot be empty if it has no leading/trailing pipe
130
- if (!cells[0].trim()) {
131
- cells.shift();
132
- }
133
- if (cells.length > 0 && !cells[cells.length - 1].trim()) {
134
- cells.pop();
135
- }
136
- if (count) {
137
- if (cells.length > count) {
138
- cells.splice(count);
139
- }
140
- else {
141
- while (cells.length < count)
142
- cells.push('');
143
- }
144
- }
145
- for (; i < cells.length; i++) {
146
- // leading or trailing whitespace is ignored per the gfm spec
147
- cells[i] = cells[i].trim().replace(/\\\|/g, '|');
148
- }
149
- return cells;
150
- }
151
- /**
152
- * Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
153
- * /c*$/ is vulnerable to REDOS.
154
- *
155
- * @param str
156
- * @param c
157
- * @param invert Remove suffix of non-c chars instead. Default falsey.
158
- */
159
- function rtrim(str, c, invert) {
160
- const l = str.length;
161
- if (l === 0) {
162
- return '';
163
- }
164
- // Length of suffix matching the invert condition.
165
- let suffLen = 0;
166
- // Step left until we fail to match the invert condition.
167
- while (suffLen < l) {
168
- const currChar = str.charAt(l - suffLen - 1);
169
- if (currChar === c && !invert) {
170
- suffLen++;
171
- }
172
- else if (currChar !== c && invert) {
173
- suffLen++;
174
- }
175
- else {
176
- break;
177
- }
178
- }
179
- return str.slice(0, l - suffLen);
180
- }
181
- function findClosingBracket(str, b) {
182
- if (str.indexOf(b[1]) === -1) {
183
- return -1;
184
- }
185
- let level = 0;
186
- for (let i = 0; i < str.length; i++) {
187
- if (str[i] === '\\') {
188
- i++;
189
- }
190
- else if (str[i] === b[0]) {
191
- level++;
192
- }
193
- else if (str[i] === b[1]) {
194
- level--;
195
- if (level < 0) {
196
- return i;
197
- }
198
- }
199
- }
200
- return -1;
201
- }
202
-
203
- function outputLink(cap, link, raw, lexer) {
204
- const href = link.href;
205
- const title = link.title ? escape$1(link.title) : null;
206
- const text = cap[1].replace(/\\([\[\]])/g, '$1');
207
- if (cap[0].charAt(0) !== '!') {
208
- lexer.state.inLink = true;
209
- const token = {
210
- type: 'link',
211
- raw,
212
- href,
213
- title,
214
- text,
215
- tokens: lexer.inlineTokens(text)
216
- };
217
- lexer.state.inLink = false;
218
- return token;
219
- }
220
- return {
221
- type: 'image',
222
- raw,
223
- href,
224
- title,
225
- text: escape$1(text)
226
- };
227
- }
228
- function indentCodeCompensation(raw, text) {
229
- const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
230
- if (matchIndentToCode === null) {
231
- return text;
232
- }
233
- const indentToCode = matchIndentToCode[1];
234
- return text
235
- .split('\n')
236
- .map(node => {
237
- const matchIndentInNode = node.match(/^\s+/);
238
- if (matchIndentInNode === null) {
239
- return node;
240
- }
241
- const [indentInNode] = matchIndentInNode;
242
- if (indentInNode.length >= indentToCode.length) {
243
- return node.slice(indentToCode.length);
244
- }
245
- return node;
246
- })
247
- .join('\n');
248
- }
249
- /**
250
- * Tokenizer
251
- */
252
- class _Tokenizer {
253
- options;
254
- rules; // set by the lexer
255
- lexer; // set by the lexer
256
- constructor(options) {
257
- this.options = options || exports.defaults;
258
- }
259
- space(src) {
260
- const cap = this.rules.block.newline.exec(src);
261
- if (cap && cap[0].length > 0) {
262
- return {
263
- type: 'space',
264
- raw: cap[0]
265
- };
266
- }
267
- }
268
- code(src) {
269
- const cap = this.rules.block.code.exec(src);
270
- if (cap) {
271
- const text = cap[0].replace(/^ {1,4}/gm, '');
272
- return {
273
- type: 'code',
274
- raw: cap[0],
275
- codeBlockStyle: 'indented',
276
- text: !this.options.pedantic
277
- ? rtrim(text, '\n')
278
- : text
279
- };
280
- }
281
- }
282
- fences(src) {
283
- const cap = this.rules.block.fences.exec(src);
284
- if (cap) {
285
- const raw = cap[0];
286
- const text = indentCodeCompensation(raw, cap[3] || '');
287
- return {
288
- type: 'code',
289
- raw,
290
- lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
291
- text
292
- };
293
- }
294
- }
295
- heading(src) {
296
- const cap = this.rules.block.heading.exec(src);
297
- if (cap) {
298
- let text = cap[2].trim();
299
- // remove trailing #s
300
- if (/#$/.test(text)) {
301
- const trimmed = rtrim(text, '#');
302
- if (this.options.pedantic) {
303
- text = trimmed.trim();
304
- }
305
- else if (!trimmed || / $/.test(trimmed)) {
306
- // CommonMark requires space before trailing #s
307
- text = trimmed.trim();
308
- }
309
- }
310
- return {
311
- type: 'heading',
312
- raw: cap[0],
313
- depth: cap[1].length,
314
- text,
315
- tokens: this.lexer.inline(text)
316
- };
317
- }
318
- }
319
- hr(src) {
320
- const cap = this.rules.block.hr.exec(src);
321
- if (cap) {
322
- return {
323
- type: 'hr',
324
- raw: rtrim(cap[0], '\n')
325
- };
326
- }
327
- }
328
- blockquote(src) {
329
- const cap = this.rules.block.blockquote.exec(src);
330
- if (cap) {
331
- let lines = rtrim(cap[0], '\n').split('\n');
332
- let raw = '';
333
- let text = '';
334
- const tokens = [];
335
- while (lines.length > 0) {
336
- let inBlockquote = false;
337
- const currentLines = [];
338
- let i;
339
- for (i = 0; i < lines.length; i++) {
340
- // get lines up to a continuation
341
- if (/^ {0,3}>/.test(lines[i])) {
342
- currentLines.push(lines[i]);
343
- inBlockquote = true;
344
- }
345
- else if (!inBlockquote) {
346
- currentLines.push(lines[i]);
347
- }
348
- else {
349
- break;
350
- }
351
- }
352
- lines = lines.slice(i);
353
- const currentRaw = currentLines.join('\n');
354
- const currentText = currentRaw
355
- // precede setext continuation with 4 spaces so it isn't a setext
356
- .replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, '\n $1')
357
- .replace(/^ {0,3}>[ \t]?/gm, '');
358
- raw = raw ? `${raw}\n${currentRaw}` : currentRaw;
359
- text = text ? `${text}\n${currentText}` : currentText;
360
- // parse blockquote lines as top level tokens
361
- // merge paragraphs if this is a continuation
362
- const top = this.lexer.state.top;
363
- this.lexer.state.top = true;
364
- this.lexer.blockTokens(currentText, tokens, true);
365
- this.lexer.state.top = top;
366
- // if there is no continuation then we are done
367
- if (lines.length === 0) {
368
- break;
369
- }
370
- const lastToken = tokens[tokens.length - 1];
371
- if (lastToken?.type === 'code') {
372
- // blockquote continuation cannot be preceded by a code block
373
- break;
374
- }
375
- else if (lastToken?.type === 'blockquote') {
376
- // include continuation in nested blockquote
377
- const oldToken = lastToken;
378
- const newText = oldToken.raw + '\n' + lines.join('\n');
379
- const newToken = this.blockquote(newText);
380
- tokens[tokens.length - 1] = newToken;
381
- raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
382
- text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
383
- break;
384
- }
385
- else if (lastToken?.type === 'list') {
386
- // include continuation in nested list
387
- const oldToken = lastToken;
388
- const newText = oldToken.raw + '\n' + lines.join('\n');
389
- const newToken = this.list(newText);
390
- tokens[tokens.length - 1] = newToken;
391
- raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
392
- text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
393
- lines = newText.substring(tokens[tokens.length - 1].raw.length).split('\n');
394
- continue;
395
- }
396
- }
397
- return {
398
- type: 'blockquote',
399
- raw,
400
- tokens,
401
- text
402
- };
403
- }
404
- }
405
- list(src) {
406
- let cap = this.rules.block.list.exec(src);
407
- if (cap) {
408
- let bull = cap[1].trim();
409
- const isordered = bull.length > 1;
410
- const list = {
411
- type: 'list',
412
- raw: '',
413
- ordered: isordered,
414
- start: isordered ? +bull.slice(0, -1) : '',
415
- loose: false,
416
- items: []
417
- };
418
- bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
419
- if (this.options.pedantic) {
420
- bull = isordered ? bull : '[*+-]';
421
- }
422
- // Get next list item
423
- const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
424
- let raw = '';
425
- let itemContents = '';
426
- let endsWithBlankLine = false;
427
- // Check if current bullet point can start a new List Item
428
- while (src) {
429
- let endEarly = false;
430
- if (!(cap = itemRegex.exec(src))) {
431
- break;
432
- }
433
- if (this.rules.block.hr.test(src)) { // End list if bullet was actually HR (possibly move into itemRegex?)
434
- break;
435
- }
436
- raw = cap[0];
437
- src = src.substring(raw.length);
438
- let line = cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length));
439
- let nextLine = src.split('\n', 1)[0];
440
- let indent = 0;
441
- if (this.options.pedantic) {
442
- indent = 2;
443
- itemContents = line.trimStart();
444
- }
445
- else {
446
- indent = cap[2].search(/[^ ]/); // Find first non-space char
447
- indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
448
- itemContents = line.slice(indent);
449
- indent += cap[1].length;
450
- }
451
- let blankLine = false;
452
- if (!line && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
453
- raw += nextLine + '\n';
454
- src = src.substring(nextLine.length + 1);
455
- endEarly = true;
456
- }
457
- if (!endEarly) {
458
- const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
459
- const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
460
- const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
461
- const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
462
- // Check if following lines should be included in List Item
463
- while (src) {
464
- const rawLine = src.split('\n', 1)[0];
465
- nextLine = rawLine;
466
- // Re-align to follow commonmark nesting rules
467
- if (this.options.pedantic) {
468
- nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
469
- }
470
- // End list item if found code fences
471
- if (fencesBeginRegex.test(nextLine)) {
472
- break;
473
- }
474
- // End list item if found start of new heading
475
- if (headingBeginRegex.test(nextLine)) {
476
- break;
477
- }
478
- // End list item if found start of new bullet
479
- if (nextBulletRegex.test(nextLine)) {
480
- break;
481
- }
482
- // Horizontal rule found
483
- if (hrRegex.test(src)) {
484
- break;
485
- }
486
- if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible
487
- itemContents += '\n' + nextLine.slice(indent);
488
- }
489
- else {
490
- // not enough indentation
491
- if (blankLine) {
492
- break;
493
- }
494
- // paragraph continuation unless last line was a different block level element
495
- if (line.search(/[^ ]/) >= 4) { // indented code block
496
- break;
497
- }
498
- if (fencesBeginRegex.test(line)) {
499
- break;
500
- }
501
- if (headingBeginRegex.test(line)) {
502
- break;
503
- }
504
- if (hrRegex.test(line)) {
505
- break;
506
- }
507
- itemContents += '\n' + nextLine;
508
- }
509
- if (!blankLine && !nextLine.trim()) { // Check if current line is blank
510
- blankLine = true;
511
- }
512
- raw += rawLine + '\n';
513
- src = src.substring(rawLine.length + 1);
514
- line = nextLine.slice(indent);
515
- }
516
- }
517
- if (!list.loose) {
518
- // If the previous item ended with a blank line, the list is loose
519
- if (endsWithBlankLine) {
520
- list.loose = true;
521
- }
522
- else if (/\n *\n *$/.test(raw)) {
523
- endsWithBlankLine = true;
524
- }
525
- }
526
- let istask = null;
527
- let ischecked;
528
- // Check for task list items
529
- if (this.options.gfm) {
530
- istask = /^\[[ xX]\] /.exec(itemContents);
531
- if (istask) {
532
- ischecked = istask[0] !== '[ ] ';
533
- itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
534
- }
535
- }
536
- list.items.push({
537
- type: 'list_item',
538
- raw,
539
- task: !!istask,
540
- checked: ischecked,
541
- loose: false,
542
- text: itemContents,
543
- tokens: []
544
- });
545
- list.raw += raw;
546
- }
547
- // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
548
- list.items[list.items.length - 1].raw = raw.trimEnd();
549
- (list.items[list.items.length - 1]).text = itemContents.trimEnd();
550
- list.raw = list.raw.trimEnd();
551
- // Item child tokens handled here at end because we needed to have the final item to trim it first
552
- for (let i = 0; i < list.items.length; i++) {
553
- this.lexer.state.top = false;
554
- list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
555
- if (!list.loose) {
556
- // Check if list should be loose
557
- const spacers = list.items[i].tokens.filter(t => t.type === 'space');
558
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => /\n.*\n/.test(t.raw));
559
- list.loose = hasMultipleLineBreaks;
560
- }
561
- }
562
- // Set all items to loose if list is loose
563
- if (list.loose) {
564
- for (let i = 0; i < list.items.length; i++) {
565
- list.items[i].loose = true;
566
- }
567
- }
568
- return list;
569
- }
570
- }
571
- html(src) {
572
- const cap = this.rules.block.html.exec(src);
573
- if (cap) {
574
- const token = {
575
- type: 'html',
576
- block: true,
577
- raw: cap[0],
578
- pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
579
- text: cap[0]
580
- };
581
- return token;
582
- }
583
- }
584
- def(src) {
585
- const cap = this.rules.block.def.exec(src);
586
- if (cap) {
587
- const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
588
- const href = cap[2] ? cap[2].replace(/^<(.*)>$/, '$1').replace(this.rules.inline.anyPunctuation, '$1') : '';
589
- const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, '$1') : cap[3];
590
- return {
591
- type: 'def',
592
- tag,
593
- raw: cap[0],
594
- href,
595
- title
596
- };
597
- }
598
- }
599
- table(src) {
600
- const cap = this.rules.block.table.exec(src);
601
- if (!cap) {
602
- return;
603
- }
604
- if (!/[:|]/.test(cap[2])) {
605
- // delimiter row must have a pipe (|) or colon (:) otherwise it is a setext heading
606
- return;
607
- }
608
- const headers = splitCells(cap[1]);
609
- const aligns = cap[2].replace(/^\||\| *$/g, '').split('|');
610
- const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : [];
611
- const item = {
612
- type: 'table',
613
- raw: cap[0],
614
- header: [],
615
- align: [],
616
- rows: []
617
- };
618
- if (headers.length !== aligns.length) {
619
- // header and align columns must be equal, rows can be different.
620
- return;
621
- }
622
- for (const align of aligns) {
623
- if (/^ *-+: *$/.test(align)) {
624
- item.align.push('right');
625
- }
626
- else if (/^ *:-+: *$/.test(align)) {
627
- item.align.push('center');
628
- }
629
- else if (/^ *:-+ *$/.test(align)) {
630
- item.align.push('left');
631
- }
632
- else {
633
- item.align.push(null);
634
- }
635
- }
636
- for (let i = 0; i < headers.length; i++) {
637
- item.header.push({
638
- text: headers[i],
639
- tokens: this.lexer.inline(headers[i]),
640
- header: true,
641
- align: item.align[i]
642
- });
643
- }
644
- for (const row of rows) {
645
- item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
646
- return {
647
- text: cell,
648
- tokens: this.lexer.inline(cell),
649
- header: false,
650
- align: item.align[i]
651
- };
652
- }));
653
- }
654
- return item;
655
- }
656
- lheading(src) {
657
- const cap = this.rules.block.lheading.exec(src);
658
- if (cap) {
659
- return {
660
- type: 'heading',
661
- raw: cap[0],
662
- depth: cap[2].charAt(0) === '=' ? 1 : 2,
663
- text: cap[1],
664
- tokens: this.lexer.inline(cap[1])
665
- };
666
- }
667
- }
668
- paragraph(src) {
669
- const cap = this.rules.block.paragraph.exec(src);
670
- if (cap) {
671
- const text = cap[1].charAt(cap[1].length - 1) === '\n'
672
- ? cap[1].slice(0, -1)
673
- : cap[1];
674
- return {
675
- type: 'paragraph',
676
- raw: cap[0],
677
- text,
678
- tokens: this.lexer.inline(text)
679
- };
680
- }
681
- }
682
- text(src) {
683
- const cap = this.rules.block.text.exec(src);
684
- if (cap) {
685
- return {
686
- type: 'text',
687
- raw: cap[0],
688
- text: cap[0],
689
- tokens: this.lexer.inline(cap[0])
690
- };
691
- }
692
- }
693
- escape(src) {
694
- const cap = this.rules.inline.escape.exec(src);
695
- if (cap) {
696
- return {
697
- type: 'escape',
698
- raw: cap[0],
699
- text: escape$1(cap[1])
700
- };
701
- }
702
- }
703
- tag(src) {
704
- const cap = this.rules.inline.tag.exec(src);
705
- if (cap) {
706
- if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
707
- this.lexer.state.inLink = true;
708
- }
709
- else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
710
- this.lexer.state.inLink = false;
711
- }
712
- if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
713
- this.lexer.state.inRawBlock = true;
714
- }
715
- else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
716
- this.lexer.state.inRawBlock = false;
717
- }
718
- return {
719
- type: 'html',
720
- raw: cap[0],
721
- inLink: this.lexer.state.inLink,
722
- inRawBlock: this.lexer.state.inRawBlock,
723
- block: false,
724
- text: cap[0]
725
- };
726
- }
727
- }
728
- link(src) {
729
- const cap = this.rules.inline.link.exec(src);
730
- if (cap) {
731
- const trimmedUrl = cap[2].trim();
732
- if (!this.options.pedantic && /^</.test(trimmedUrl)) {
733
- // commonmark requires matching angle brackets
734
- if (!(/>$/.test(trimmedUrl))) {
735
- return;
736
- }
737
- // ending angle bracket cannot be escaped
738
- const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
739
- if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
740
- return;
741
- }
742
- }
743
- else {
744
- // find closing parenthesis
745
- const lastParenIndex = findClosingBracket(cap[2], '()');
746
- if (lastParenIndex > -1) {
747
- const start = cap[0].indexOf('!') === 0 ? 5 : 4;
748
- const linkLen = start + cap[1].length + lastParenIndex;
749
- cap[2] = cap[2].substring(0, lastParenIndex);
750
- cap[0] = cap[0].substring(0, linkLen).trim();
751
- cap[3] = '';
752
- }
753
- }
754
- let href = cap[2];
755
- let title = '';
756
- if (this.options.pedantic) {
757
- // split pedantic href and title
758
- const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
759
- if (link) {
760
- href = link[1];
761
- title = link[3];
762
- }
763
- }
764
- else {
765
- title = cap[3] ? cap[3].slice(1, -1) : '';
766
- }
767
- href = href.trim();
768
- if (/^</.test(href)) {
769
- if (this.options.pedantic && !(/>$/.test(trimmedUrl))) {
770
- // pedantic allows starting angle bracket without ending angle bracket
771
- href = href.slice(1);
772
- }
773
- else {
774
- href = href.slice(1, -1);
775
- }
776
- }
777
- return outputLink(cap, {
778
- href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
779
- title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
780
- }, cap[0], this.lexer);
781
- }
782
- }
783
- reflink(src, links) {
784
- let cap;
785
- if ((cap = this.rules.inline.reflink.exec(src))
786
- || (cap = this.rules.inline.nolink.exec(src))) {
787
- const linkString = (cap[2] || cap[1]).replace(/\s+/g, ' ');
788
- const link = links[linkString.toLowerCase()];
789
- if (!link) {
790
- const text = cap[0].charAt(0);
791
- return {
792
- type: 'text',
793
- raw: text,
794
- text
795
- };
796
- }
797
- return outputLink(cap, link, cap[0], this.lexer);
798
- }
799
- }
800
- emStrong(src, maskedSrc, prevChar = '') {
801
- let match = this.rules.inline.emStrongLDelim.exec(src);
802
- if (!match)
803
- return;
804
- // _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
805
- if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
806
- return;
807
- const nextChar = match[1] || match[2] || '';
808
- if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
809
- // unicode Regex counts emoji as 1 char; spread into array for proper count (used multiple times below)
810
- const lLength = [...match[0]].length - 1;
811
- let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
812
- const endReg = match[0][0] === '*' ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
813
- endReg.lastIndex = 0;
814
- // Clip maskedSrc to same section of string as src (move to lexer?)
815
- maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
816
- while ((match = endReg.exec(maskedSrc)) != null) {
817
- rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
818
- if (!rDelim)
819
- continue; // skip single * in __abc*abc__
820
- rLength = [...rDelim].length;
821
- if (match[3] || match[4]) { // found another Left Delim
822
- delimTotal += rLength;
823
- continue;
824
- }
825
- else if (match[5] || match[6]) { // either Left or Right Delim
826
- if (lLength % 3 && !((lLength + rLength) % 3)) {
827
- midDelimTotal += rLength;
828
- continue; // CommonMark Emphasis Rules 9-10
829
- }
830
- }
831
- delimTotal -= rLength;
832
- if (delimTotal > 0)
833
- continue; // Haven't found enough closing delimiters
834
- // Remove extra characters. *a*** -> *a*
835
- rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
836
- // char length can be >1 for unicode characters;
837
- const lastCharLength = [...match[0]][0].length;
838
- const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
839
- // Create `em` if smallest delimiter has odd char count. *a***
840
- if (Math.min(lLength, rLength) % 2) {
841
- const text = raw.slice(1, -1);
842
- return {
843
- type: 'em',
844
- raw,
845
- text,
846
- tokens: this.lexer.inlineTokens(text)
847
- };
848
- }
849
- // Create 'strong' if smallest delimiter has even char count. **a***
850
- const text = raw.slice(2, -2);
851
- return {
852
- type: 'strong',
853
- raw,
854
- text,
855
- tokens: this.lexer.inlineTokens(text)
856
- };
857
- }
858
- }
859
- }
860
- codespan(src) {
861
- const cap = this.rules.inline.code.exec(src);
862
- if (cap) {
863
- let text = cap[2].replace(/\n/g, ' ');
864
- const hasNonSpaceChars = /[^ ]/.test(text);
865
- const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
866
- if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
867
- text = text.substring(1, text.length - 1);
868
- }
869
- text = escape$1(text, true);
870
- return {
871
- type: 'codespan',
872
- raw: cap[0],
873
- text
874
- };
875
- }
876
- }
877
- br(src) {
878
- const cap = this.rules.inline.br.exec(src);
879
- if (cap) {
880
- return {
881
- type: 'br',
882
- raw: cap[0]
883
- };
884
- }
885
- }
886
- del(src) {
887
- const cap = this.rules.inline.del.exec(src);
888
- if (cap) {
889
- return {
890
- type: 'del',
891
- raw: cap[0],
892
- text: cap[2],
893
- tokens: this.lexer.inlineTokens(cap[2])
894
- };
895
- }
896
- }
897
- autolink(src) {
898
- const cap = this.rules.inline.autolink.exec(src);
899
- if (cap) {
900
- let text, href;
901
- if (cap[2] === '@') {
902
- text = escape$1(cap[1]);
903
- href = 'mailto:' + text;
904
- }
905
- else {
906
- text = escape$1(cap[1]);
907
- href = text;
908
- }
909
- return {
910
- type: 'link',
911
- raw: cap[0],
912
- text,
913
- href,
914
- tokens: [
915
- {
916
- type: 'text',
917
- raw: text,
918
- text
919
- }
920
- ]
921
- };
922
- }
923
- }
924
- url(src) {
925
- let cap;
926
- if (cap = this.rules.inline.url.exec(src)) {
927
- let text, href;
928
- if (cap[2] === '@') {
929
- text = escape$1(cap[0]);
930
- href = 'mailto:' + text;
931
- }
932
- else {
933
- // do extended autolink path validation
934
- let prevCapZero;
935
- do {
936
- prevCapZero = cap[0];
937
- cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? '';
938
- } while (prevCapZero !== cap[0]);
939
- text = escape$1(cap[0]);
940
- if (cap[1] === 'www.') {
941
- href = 'http://' + cap[0];
942
- }
943
- else {
944
- href = cap[0];
945
- }
946
- }
947
- return {
948
- type: 'link',
949
- raw: cap[0],
950
- text,
951
- href,
952
- tokens: [
953
- {
954
- type: 'text',
955
- raw: text,
956
- text
957
- }
958
- ]
959
- };
960
- }
961
- }
962
- inlineText(src) {
963
- const cap = this.rules.inline.text.exec(src);
964
- if (cap) {
965
- let text;
966
- if (this.lexer.state.inRawBlock) {
967
- text = cap[0];
968
- }
969
- else {
970
- text = escape$1(cap[0]);
971
- }
972
- return {
973
- type: 'text',
974
- raw: cap[0],
975
- text
976
- };
977
- }
978
- }
979
- }
980
-
981
- /**
982
- * Block-Level Grammar
983
- */
984
- const newline = /^(?: *(?:\n|$))+/;
985
- const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
986
- const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
987
- const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
988
- const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
989
- const bullet = /(?:[*+-]|\d{1,9}[.)])/;
990
- const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
991
- .replace(/bull/g, bullet) // lists can interrupt
992
- .replace(/blockCode/g, / {4}/) // indented code blocks can interrupt
993
- .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
994
- .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
995
- .replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
996
- .replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
997
- .getRegex();
998
- const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
999
- const blockText = /^[^\n]+/;
1000
- const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
1001
- const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/)
1002
- .replace('label', _blockLabel)
1003
- .replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/)
1004
- .getRegex();
1005
- const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/)
1006
- .replace(/bull/g, bullet)
1007
- .getRegex();
1008
- const _tag = 'address|article|aside|base|basefont|blockquote|body|caption'
1009
- + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
1010
- + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
1011
- + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
1012
- + '|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title'
1013
- + '|tr|track|ul';
1014
- const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
1015
- const html = edit('^ {0,3}(?:' // optional indentation
1016
- + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
1017
- + '|comment[^\\n]*(\\n+|$)' // (2)
1018
- + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
1019
- + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
1020
- + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
1021
- + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
1022
- + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
1023
- + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
1024
- + ')', 'i')
1025
- .replace('comment', _comment)
1026
- .replace('tag', _tag)
1027
- .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
1028
- .getRegex();
1029
- const paragraph = edit(_paragraph)
1030
- .replace('hr', hr)
1031
- .replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
1032
- .replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
1033
- .replace('|table', '')
1034
- .replace('blockquote', ' {0,3}>')
1035
- .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
1036
- .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1037
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1038
- .replace('tag', _tag) // pars can be interrupted by type (6) html blocks
1039
- .getRegex();
1040
- const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
1041
- .replace('paragraph', paragraph)
1042
- .getRegex();
1043
- /**
1044
- * Normal Block Grammar
1045
- */
1046
- const blockNormal = {
1047
- blockquote,
1048
- code: blockCode,
1049
- def,
1050
- fences,
1051
- heading,
1052
- hr,
1053
- html,
1054
- lheading,
1055
- list,
1056
- newline,
1057
- paragraph,
1058
- table: noopTest,
1059
- text: blockText
1060
- };
1061
- /**
1062
- * GFM Block Grammar
1063
- */
1064
- const gfmTable = edit('^ *([^\\n ].*)\\n' // Header
1065
- + ' {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)' // Align
1066
- + '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)') // Cells
1067
- .replace('hr', hr)
1068
- .replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
1069
- .replace('blockquote', ' {0,3}>')
1070
- .replace('code', ' {4}[^\\n]')
1071
- .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
1072
- .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1073
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1074
- .replace('tag', _tag) // tables can be interrupted by type (6) html blocks
1075
- .getRegex();
1076
- const blockGfm = {
1077
- ...blockNormal,
1078
- table: gfmTable,
1079
- paragraph: edit(_paragraph)
1080
- .replace('hr', hr)
1081
- .replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
1082
- .replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
1083
- .replace('table', gfmTable) // interrupt paragraphs with table
1084
- .replace('blockquote', ' {0,3}>')
1085
- .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
1086
- .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1087
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1088
- .replace('tag', _tag) // pars can be interrupted by type (6) html blocks
1089
- .getRegex()
1090
- };
1091
- /**
1092
- * Pedantic grammar (original John Gruber's loose markdown specification)
1093
- */
1094
- const blockPedantic = {
1095
- ...blockNormal,
1096
- html: edit('^ *(?:comment *(?:\\n|\\s*$)'
1097
- + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
1098
- + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
1099
- .replace('comment', _comment)
1100
- .replace(/tag/g, '(?!(?:'
1101
- + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
1102
- + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
1103
- + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
1104
- .getRegex(),
1105
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
1106
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
1107
- fences: noopTest, // fences not supported
1108
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1109
- paragraph: edit(_paragraph)
1110
- .replace('hr', hr)
1111
- .replace('heading', ' *#{1,6} *[^\n]')
1112
- .replace('lheading', lheading)
1113
- .replace('|table', '')
1114
- .replace('blockquote', ' {0,3}>')
1115
- .replace('|fences', '')
1116
- .replace('|list', '')
1117
- .replace('|html', '')
1118
- .replace('|tag', '')
1119
- .getRegex()
1120
- };
1121
- /**
1122
- * Inline-Level Grammar
1123
- */
1124
- const escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
1125
- const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
1126
- const br = /^( {2,}|\\)\n(?!\s*$)/;
1127
- const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
1128
- // list of unicode punctuation marks, plus any missing characters from CommonMark spec
1129
- const _punctuation = '\\p{P}\\p{S}';
1130
- const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u')
1131
- .replace(/punctuation/g, _punctuation).getRegex();
1132
- // sequences em should skip over [title](link), `code`, <html>
1133
- const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
1134
- const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u')
1135
- .replace(/punct/g, _punctuation)
1136
- .getRegex();
1137
- const emStrongRDelimAst = edit('^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
1138
- + '|[^*]+(?=[^*])' // Consume to delim
1139
- + '|(?!\\*)[punct](\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
1140
- + '|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)' // (2) a***#, a*** can only be a Right Delimiter
1141
- + '|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])' // (3) #***a, ***a can only be Left Delimiter
1142
- + '|[\\s](\\*+)(?!\\*)(?=[punct])' // (4) ***# can only be Left Delimiter
1143
- + '|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])' // (5) #***# can be either Left or Right Delimiter
1144
- + '|[^punct\\s](\\*+)(?=[^punct\\s])', 'gu') // (6) a***a can be either Left or Right Delimiter
1145
- .replace(/punct/g, _punctuation)
1146
- .getRegex();
1147
- // (6) Not allowed for _
1148
- const emStrongRDelimUnd = edit('^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong
1149
- + '|[^_]+(?=[^_])' // Consume to delim
1150
- + '|(?!_)[punct](_+)(?=[\\s]|$)' // (1) #___ can only be a Right Delimiter
1151
- + '|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)' // (2) a___#, a___ can only be a Right Delimiter
1152
- + '|(?!_)[punct\\s](_+)(?=[^punct\\s])' // (3) #___a, ___a can only be Left Delimiter
1153
- + '|[\\s](_+)(?!_)(?=[punct])' // (4) ___# can only be Left Delimiter
1154
- + '|(?!_)[punct](_+)(?!_)(?=[punct])', 'gu') // (5) #___# can be either Left or Right Delimiter
1155
- .replace(/punct/g, _punctuation)
1156
- .getRegex();
1157
- const anyPunctuation = edit(/\\([punct])/, 'gu')
1158
- .replace(/punct/g, _punctuation)
1159
- .getRegex();
1160
- const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/)
1161
- .replace('scheme', /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/)
1162
- .replace('email', /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/)
1163
- .getRegex();
1164
- const _inlineComment = edit(_comment).replace('(?:-->|$)', '-->').getRegex();
1165
- const tag = edit('^comment'
1166
- + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
1167
- + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
1168
- + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
1169
- + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
1170
- + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>') // CDATA section
1171
- .replace('comment', _inlineComment)
1172
- .replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/)
1173
- .getRegex();
1174
- const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
1175
- const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/)
1176
- .replace('label', _inlineLabel)
1177
- .replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/)
1178
- .replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/)
1179
- .getRegex();
1180
- const reflink = edit(/^!?\[(label)\]\[(ref)\]/)
1181
- .replace('label', _inlineLabel)
1182
- .replace('ref', _blockLabel)
1183
- .getRegex();
1184
- const nolink = edit(/^!?\[(ref)\](?:\[\])?/)
1185
- .replace('ref', _blockLabel)
1186
- .getRegex();
1187
- const reflinkSearch = edit('reflink|nolink(?!\\()', 'g')
1188
- .replace('reflink', reflink)
1189
- .replace('nolink', nolink)
1190
- .getRegex();
1191
- /**
1192
- * Normal Inline Grammar
1193
- */
1194
- const inlineNormal = {
1195
- _backpedal: noopTest, // only used for GFM url
1196
- anyPunctuation,
1197
- autolink,
1198
- blockSkip,
1199
- br,
1200
- code: inlineCode,
1201
- del: noopTest,
1202
- emStrongLDelim,
1203
- emStrongRDelimAst,
1204
- emStrongRDelimUnd,
1205
- escape,
1206
- link,
1207
- nolink,
1208
- punctuation,
1209
- reflink,
1210
- reflinkSearch,
1211
- tag,
1212
- text: inlineText,
1213
- url: noopTest
1214
- };
1215
- /**
1216
- * Pedantic Inline Grammar
1217
- */
1218
- const inlinePedantic = {
1219
- ...inlineNormal,
1220
- link: edit(/^!?\[(label)\]\((.*?)\)/)
1221
- .replace('label', _inlineLabel)
1222
- .getRegex(),
1223
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
1224
- .replace('label', _inlineLabel)
1225
- .getRegex()
1226
- };
1227
- /**
1228
- * GFM Inline Grammar
1229
- */
1230
- const inlineGfm = {
1231
- ...inlineNormal,
1232
- escape: edit(escape).replace('])', '~|])').getRegex(),
1233
- url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i')
1234
- .replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
1235
- .getRegex(),
1236
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
1237
- del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
1238
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
1239
- };
1240
- /**
1241
- * GFM + Line Breaks Inline Grammar
1242
- */
1243
- const inlineBreaks = {
1244
- ...inlineGfm,
1245
- br: edit(br).replace('{2,}', '*').getRegex(),
1246
- text: edit(inlineGfm.text)
1247
- .replace('\\b_', '\\b_| {2,}\\n')
1248
- .replace(/\{2,\}/g, '*')
1249
- .getRegex()
1250
- };
1251
- /**
1252
- * exports
1253
- */
1254
- const block = {
1255
- normal: blockNormal,
1256
- gfm: blockGfm,
1257
- pedantic: blockPedantic
1258
- };
1259
- const inline = {
1260
- normal: inlineNormal,
1261
- gfm: inlineGfm,
1262
- breaks: inlineBreaks,
1263
- pedantic: inlinePedantic
1264
- };
1265
-
1266
- /**
1267
- * Block Lexer
1268
- */
1269
- class _Lexer {
1270
- tokens;
1271
- options;
1272
- state;
1273
- tokenizer;
1274
- inlineQueue;
1275
- constructor(options) {
1276
- // TokenList cannot be created in one go
1277
- this.tokens = [];
1278
- this.tokens.links = Object.create(null);
1279
- this.options = options || exports.defaults;
1280
- this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
1281
- this.tokenizer = this.options.tokenizer;
1282
- this.tokenizer.options = this.options;
1283
- this.tokenizer.lexer = this;
1284
- this.inlineQueue = [];
1285
- this.state = {
1286
- inLink: false,
1287
- inRawBlock: false,
1288
- top: true
1289
- };
1290
- const rules = {
1291
- block: block.normal,
1292
- inline: inline.normal
1293
- };
1294
- if (this.options.pedantic) {
1295
- rules.block = block.pedantic;
1296
- rules.inline = inline.pedantic;
1297
- }
1298
- else if (this.options.gfm) {
1299
- rules.block = block.gfm;
1300
- if (this.options.breaks) {
1301
- rules.inline = inline.breaks;
1302
- }
1303
- else {
1304
- rules.inline = inline.gfm;
1305
- }
1306
- }
1307
- this.tokenizer.rules = rules;
1308
- }
1309
- /**
1310
- * Expose Rules
1311
- */
1312
- static get rules() {
1313
- return {
1314
- block,
1315
- inline
1316
- };
1317
- }
1318
- /**
1319
- * Static Lex Method
1320
- */
1321
- static lex(src, options) {
1322
- const lexer = new _Lexer(options);
1323
- return lexer.lex(src);
1324
- }
1325
- /**
1326
- * Static Lex Inline Method
1327
- */
1328
- static lexInline(src, options) {
1329
- const lexer = new _Lexer(options);
1330
- return lexer.inlineTokens(src);
1331
- }
1332
- /**
1333
- * Preprocessing
1334
- */
1335
- lex(src) {
1336
- src = src
1337
- .replace(/\r\n|\r/g, '\n');
1338
- this.blockTokens(src, this.tokens);
1339
- for (let i = 0; i < this.inlineQueue.length; i++) {
1340
- const next = this.inlineQueue[i];
1341
- this.inlineTokens(next.src, next.tokens);
1342
- }
1343
- this.inlineQueue = [];
1344
- return this.tokens;
1345
- }
1346
- blockTokens(src, tokens = [], lastParagraphClipped = false) {
1347
- if (this.options.pedantic) {
1348
- src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
1349
- }
1350
- else {
1351
- src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
1352
- return leading + ' '.repeat(tabs.length);
1353
- });
1354
- }
1355
- let token;
1356
- let lastToken;
1357
- let cutSrc;
1358
- while (src) {
1359
- if (this.options.extensions
1360
- && this.options.extensions.block
1361
- && this.options.extensions.block.some((extTokenizer) => {
1362
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1363
- src = src.substring(token.raw.length);
1364
- tokens.push(token);
1365
- return true;
1366
- }
1367
- return false;
1368
- })) {
1369
- continue;
1370
- }
1371
- // newline
1372
- if (token = this.tokenizer.space(src)) {
1373
- src = src.substring(token.raw.length);
1374
- if (token.raw.length === 1 && tokens.length > 0) {
1375
- // if there's a single \n as a spacer, it's terminating the last line,
1376
- // so move it there so that we don't get unnecessary paragraph tags
1377
- tokens[tokens.length - 1].raw += '\n';
1378
- }
1379
- else {
1380
- tokens.push(token);
1381
- }
1382
- continue;
1383
- }
1384
- // code
1385
- if (token = this.tokenizer.code(src)) {
1386
- src = src.substring(token.raw.length);
1387
- lastToken = tokens[tokens.length - 1];
1388
- // An indented code block cannot interrupt a paragraph.
1389
- if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
1390
- lastToken.raw += '\n' + token.raw;
1391
- lastToken.text += '\n' + token.text;
1392
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1393
- }
1394
- else {
1395
- tokens.push(token);
1396
- }
1397
- continue;
1398
- }
1399
- // fences
1400
- if (token = this.tokenizer.fences(src)) {
1401
- src = src.substring(token.raw.length);
1402
- tokens.push(token);
1403
- continue;
1404
- }
1405
- // heading
1406
- if (token = this.tokenizer.heading(src)) {
1407
- src = src.substring(token.raw.length);
1408
- tokens.push(token);
1409
- continue;
1410
- }
1411
- // hr
1412
- if (token = this.tokenizer.hr(src)) {
1413
- src = src.substring(token.raw.length);
1414
- tokens.push(token);
1415
- continue;
1416
- }
1417
- // blockquote
1418
- if (token = this.tokenizer.blockquote(src)) {
1419
- src = src.substring(token.raw.length);
1420
- tokens.push(token);
1421
- continue;
1422
- }
1423
- // list
1424
- if (token = this.tokenizer.list(src)) {
1425
- src = src.substring(token.raw.length);
1426
- tokens.push(token);
1427
- continue;
1428
- }
1429
- // html
1430
- if (token = this.tokenizer.html(src)) {
1431
- src = src.substring(token.raw.length);
1432
- tokens.push(token);
1433
- continue;
1434
- }
1435
- // def
1436
- if (token = this.tokenizer.def(src)) {
1437
- src = src.substring(token.raw.length);
1438
- lastToken = tokens[tokens.length - 1];
1439
- if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
1440
- lastToken.raw += '\n' + token.raw;
1441
- lastToken.text += '\n' + token.raw;
1442
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1443
- }
1444
- else if (!this.tokens.links[token.tag]) {
1445
- this.tokens.links[token.tag] = {
1446
- href: token.href,
1447
- title: token.title
1448
- };
1449
- }
1450
- continue;
1451
- }
1452
- // table (gfm)
1453
- if (token = this.tokenizer.table(src)) {
1454
- src = src.substring(token.raw.length);
1455
- tokens.push(token);
1456
- continue;
1457
- }
1458
- // lheading
1459
- if (token = this.tokenizer.lheading(src)) {
1460
- src = src.substring(token.raw.length);
1461
- tokens.push(token);
1462
- continue;
1463
- }
1464
- // top-level paragraph
1465
- // prevent paragraph consuming extensions by clipping 'src' to extension start
1466
- cutSrc = src;
1467
- if (this.options.extensions && this.options.extensions.startBlock) {
1468
- let startIndex = Infinity;
1469
- const tempSrc = src.slice(1);
1470
- let tempStart;
1471
- this.options.extensions.startBlock.forEach((getStartIndex) => {
1472
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1473
- if (typeof tempStart === 'number' && tempStart >= 0) {
1474
- startIndex = Math.min(startIndex, tempStart);
1475
- }
1476
- });
1477
- if (startIndex < Infinity && startIndex >= 0) {
1478
- cutSrc = src.substring(0, startIndex + 1);
1479
- }
1480
- }
1481
- if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
1482
- lastToken = tokens[tokens.length - 1];
1483
- if (lastParagraphClipped && lastToken?.type === 'paragraph') {
1484
- lastToken.raw += '\n' + token.raw;
1485
- lastToken.text += '\n' + token.text;
1486
- this.inlineQueue.pop();
1487
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1488
- }
1489
- else {
1490
- tokens.push(token);
1491
- }
1492
- lastParagraphClipped = (cutSrc.length !== src.length);
1493
- src = src.substring(token.raw.length);
1494
- continue;
1495
- }
1496
- // text
1497
- if (token = this.tokenizer.text(src)) {
1498
- src = src.substring(token.raw.length);
1499
- lastToken = tokens[tokens.length - 1];
1500
- if (lastToken && lastToken.type === 'text') {
1501
- lastToken.raw += '\n' + token.raw;
1502
- lastToken.text += '\n' + token.text;
1503
- this.inlineQueue.pop();
1504
- this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1505
- }
1506
- else {
1507
- tokens.push(token);
1508
- }
1509
- continue;
1510
- }
1511
- if (src) {
1512
- const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
1513
- if (this.options.silent) {
1514
- console.error(errMsg);
1515
- break;
1516
- }
1517
- else {
1518
- throw new Error(errMsg);
1519
- }
1520
- }
1521
- }
1522
- this.state.top = true;
1523
- return tokens;
1524
- }
1525
- inline(src, tokens = []) {
1526
- this.inlineQueue.push({ src, tokens });
1527
- return tokens;
1528
- }
1529
- /**
1530
- * Lexing/Compiling
1531
- */
1532
- inlineTokens(src, tokens = []) {
1533
- let token, lastToken, cutSrc;
1534
- // String with links masked to avoid interference with em and strong
1535
- let maskedSrc = src;
1536
- let match;
1537
- let keepPrevChar, prevChar;
1538
- // Mask out reflinks
1539
- if (this.tokens.links) {
1540
- const links = Object.keys(this.tokens.links);
1541
- if (links.length > 0) {
1542
- while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1543
- if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
1544
- maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1545
- }
1546
- }
1547
- }
1548
- }
1549
- // Mask out other blocks
1550
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1551
- maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1552
- }
1553
- // Mask out escaped characters
1554
- while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
1555
- maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1556
- }
1557
- while (src) {
1558
- if (!keepPrevChar) {
1559
- prevChar = '';
1560
- }
1561
- keepPrevChar = false;
1562
- // extensions
1563
- if (this.options.extensions
1564
- && this.options.extensions.inline
1565
- && this.options.extensions.inline.some((extTokenizer) => {
1566
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1567
- src = src.substring(token.raw.length);
1568
- tokens.push(token);
1569
- return true;
1570
- }
1571
- return false;
1572
- })) {
1573
- continue;
1574
- }
1575
- // escape
1576
- if (token = this.tokenizer.escape(src)) {
1577
- src = src.substring(token.raw.length);
1578
- tokens.push(token);
1579
- continue;
1580
- }
1581
- // tag
1582
- if (token = this.tokenizer.tag(src)) {
1583
- src = src.substring(token.raw.length);
1584
- lastToken = tokens[tokens.length - 1];
1585
- if (lastToken && token.type === 'text' && lastToken.type === 'text') {
1586
- lastToken.raw += token.raw;
1587
- lastToken.text += token.text;
1588
- }
1589
- else {
1590
- tokens.push(token);
1591
- }
1592
- continue;
1593
- }
1594
- // link
1595
- if (token = this.tokenizer.link(src)) {
1596
- src = src.substring(token.raw.length);
1597
- tokens.push(token);
1598
- continue;
1599
- }
1600
- // reflink, nolink
1601
- if (token = this.tokenizer.reflink(src, this.tokens.links)) {
1602
- src = src.substring(token.raw.length);
1603
- lastToken = tokens[tokens.length - 1];
1604
- if (lastToken && token.type === 'text' && lastToken.type === 'text') {
1605
- lastToken.raw += token.raw;
1606
- lastToken.text += token.text;
1607
- }
1608
- else {
1609
- tokens.push(token);
1610
- }
1611
- continue;
1612
- }
1613
- // em & strong
1614
- if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
1615
- src = src.substring(token.raw.length);
1616
- tokens.push(token);
1617
- continue;
1618
- }
1619
- // code
1620
- if (token = this.tokenizer.codespan(src)) {
1621
- src = src.substring(token.raw.length);
1622
- tokens.push(token);
1623
- continue;
1624
- }
1625
- // br
1626
- if (token = this.tokenizer.br(src)) {
1627
- src = src.substring(token.raw.length);
1628
- tokens.push(token);
1629
- continue;
1630
- }
1631
- // del (gfm)
1632
- if (token = this.tokenizer.del(src)) {
1633
- src = src.substring(token.raw.length);
1634
- tokens.push(token);
1635
- continue;
1636
- }
1637
- // autolink
1638
- if (token = this.tokenizer.autolink(src)) {
1639
- src = src.substring(token.raw.length);
1640
- tokens.push(token);
1641
- continue;
1642
- }
1643
- // url (gfm)
1644
- if (!this.state.inLink && (token = this.tokenizer.url(src))) {
1645
- src = src.substring(token.raw.length);
1646
- tokens.push(token);
1647
- continue;
1648
- }
1649
- // text
1650
- // prevent inlineText consuming extensions by clipping 'src' to extension start
1651
- cutSrc = src;
1652
- if (this.options.extensions && this.options.extensions.startInline) {
1653
- let startIndex = Infinity;
1654
- const tempSrc = src.slice(1);
1655
- let tempStart;
1656
- this.options.extensions.startInline.forEach((getStartIndex) => {
1657
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1658
- if (typeof tempStart === 'number' && tempStart >= 0) {
1659
- startIndex = Math.min(startIndex, tempStart);
1660
- }
1661
- });
1662
- if (startIndex < Infinity && startIndex >= 0) {
1663
- cutSrc = src.substring(0, startIndex + 1);
1664
- }
1665
- }
1666
- if (token = this.tokenizer.inlineText(cutSrc)) {
1667
- src = src.substring(token.raw.length);
1668
- if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started
1669
- prevChar = token.raw.slice(-1);
1670
- }
1671
- keepPrevChar = true;
1672
- lastToken = tokens[tokens.length - 1];
1673
- if (lastToken && lastToken.type === 'text') {
1674
- lastToken.raw += token.raw;
1675
- lastToken.text += token.text;
1676
- }
1677
- else {
1678
- tokens.push(token);
1679
- }
1680
- continue;
1681
- }
1682
- if (src) {
1683
- const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
1684
- if (this.options.silent) {
1685
- console.error(errMsg);
1686
- break;
1687
- }
1688
- else {
1689
- throw new Error(errMsg);
1690
- }
1691
- }
1692
- }
1693
- return tokens;
1694
- }
1695
- }
1696
-
1697
- /**
1698
- * Renderer
1699
- */
1700
- class _Renderer {
1701
- options;
1702
- parser; // set by the parser
1703
- constructor(options) {
1704
- this.options = options || exports.defaults;
1705
- }
1706
- space(token) {
1707
- return '';
1708
- }
1709
- code({ text, lang, escaped }) {
1710
- const langString = (lang || '').match(/^\S*/)?.[0];
1711
- const code = text.replace(/\n$/, '') + '\n';
1712
- if (!langString) {
1713
- return '<pre><code>'
1714
- + (escaped ? code : escape$1(code, true))
1715
- + '</code></pre>\n';
1716
- }
1717
- return '<pre><code class="language-'
1718
- + escape$1(langString)
1719
- + '">'
1720
- + (escaped ? code : escape$1(code, true))
1721
- + '</code></pre>\n';
1722
- }
1723
- blockquote({ tokens }) {
1724
- const body = this.parser.parse(tokens);
1725
- return `<blockquote>\n${body}</blockquote>\n`;
1726
- }
1727
- html({ text }) {
1728
- return text;
1729
- }
1730
- heading({ tokens, depth }) {
1731
- return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>\n`;
1732
- }
1733
- hr(token) {
1734
- return '<hr>\n';
1735
- }
1736
- list(token) {
1737
- const ordered = token.ordered;
1738
- const start = token.start;
1739
- let body = '';
1740
- for (let j = 0; j < token.items.length; j++) {
1741
- const item = token.items[j];
1742
- body += this.listitem(item);
1743
- }
1744
- const type = ordered ? 'ol' : 'ul';
1745
- const startAttr = (ordered && start !== 1) ? (' start="' + start + '"') : '';
1746
- return '<' + type + startAttr + '>\n' + body + '</' + type + '>\n';
1747
- }
1748
- listitem(item) {
1749
- let itemBody = '';
1750
- if (item.task) {
1751
- const checkbox = this.checkbox({ checked: !!item.checked });
1752
- if (item.loose) {
1753
- if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
1754
- item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
1755
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
1756
- item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
1757
- }
1758
- }
1759
- else {
1760
- item.tokens.unshift({
1761
- type: 'text',
1762
- raw: checkbox + ' ',
1763
- text: checkbox + ' '
1764
- });
1765
- }
1766
- }
1767
- else {
1768
- itemBody += checkbox + ' ';
1769
- }
1770
- }
1771
- itemBody += this.parser.parse(item.tokens, !!item.loose);
1772
- return `<li>${itemBody}</li>\n`;
1773
- }
1774
- checkbox({ checked }) {
1775
- return '<input '
1776
- + (checked ? 'checked="" ' : '')
1777
- + 'disabled="" type="checkbox">';
1778
- }
1779
- paragraph({ tokens }) {
1780
- return `<p>${this.parser.parseInline(tokens)}</p>\n`;
1781
- }
1782
- table(token) {
1783
- let header = '';
1784
- // header
1785
- let cell = '';
1786
- for (let j = 0; j < token.header.length; j++) {
1787
- cell += this.tablecell(token.header[j]);
1788
- }
1789
- header += this.tablerow({ text: cell });
1790
- let body = '';
1791
- for (let j = 0; j < token.rows.length; j++) {
1792
- const row = token.rows[j];
1793
- cell = '';
1794
- for (let k = 0; k < row.length; k++) {
1795
- cell += this.tablecell(row[k]);
1796
- }
1797
- body += this.tablerow({ text: cell });
1798
- }
1799
- if (body)
1800
- body = `<tbody>${body}</tbody>`;
1801
- return '<table>\n'
1802
- + '<thead>\n'
1803
- + header
1804
- + '</thead>\n'
1805
- + body
1806
- + '</table>\n';
1807
- }
1808
- tablerow({ text }) {
1809
- return `<tr>\n${text}</tr>\n`;
1810
- }
1811
- tablecell(token) {
1812
- const content = this.parser.parseInline(token.tokens);
1813
- const type = token.header ? 'th' : 'td';
1814
- const tag = token.align
1815
- ? `<${type} align="${token.align}">`
1816
- : `<${type}>`;
1817
- return tag + content + `</${type}>\n`;
1818
- }
1819
- /**
1820
- * span level renderer
1821
- */
1822
- strong({ tokens }) {
1823
- return `<strong>${this.parser.parseInline(tokens)}</strong>`;
1824
- }
1825
- em({ tokens }) {
1826
- return `<em>${this.parser.parseInline(tokens)}</em>`;
1827
- }
1828
- codespan({ text }) {
1829
- return `<code>${text}</code>`;
1830
- }
1831
- br(token) {
1832
- return '<br>';
1833
- }
1834
- del({ tokens }) {
1835
- return `<del>${this.parser.parseInline(tokens)}</del>`;
1836
- }
1837
- link({ href, title, tokens }) {
1838
- const text = this.parser.parseInline(tokens);
1839
- const cleanHref = cleanUrl(href);
1840
- if (cleanHref === null) {
1841
- return text;
1842
- }
1843
- href = cleanHref;
1844
- let out = '<a href="' + href + '"';
1845
- if (title) {
1846
- out += ' title="' + title + '"';
1847
- }
1848
- out += '>' + text + '</a>';
1849
- return out;
1850
- }
1851
- image({ href, title, text }) {
1852
- const cleanHref = cleanUrl(href);
1853
- if (cleanHref === null) {
1854
- return text;
1855
- }
1856
- href = cleanHref;
1857
- let out = `<img src="${href}" alt="${text}"`;
1858
- if (title) {
1859
- out += ` title="${title}"`;
1860
- }
1861
- out += '>';
1862
- return out;
1863
- }
1864
- text(token) {
1865
- return 'tokens' in token && token.tokens ? this.parser.parseInline(token.tokens) : token.text;
1866
- }
1867
- }
1868
-
1869
- /**
1870
- * TextRenderer
1871
- * returns only the textual part of the token
1872
- */
1873
- class _TextRenderer {
1874
- // no need for block level renderers
1875
- strong({ text }) {
1876
- return text;
1877
- }
1878
- em({ text }) {
1879
- return text;
1880
- }
1881
- codespan({ text }) {
1882
- return text;
1883
- }
1884
- del({ text }) {
1885
- return text;
1886
- }
1887
- html({ text }) {
1888
- return text;
1889
- }
1890
- text({ text }) {
1891
- return text;
1892
- }
1893
- link({ text }) {
1894
- return '' + text;
1895
- }
1896
- image({ text }) {
1897
- return '' + text;
1898
- }
1899
- br() {
1900
- return '';
1901
- }
1902
- }
1903
-
1904
- /**
1905
- * Parsing & Compiling
1906
- */
1907
- class _Parser {
1908
- options;
1909
- renderer;
1910
- textRenderer;
1911
- constructor(options) {
1912
- this.options = options || exports.defaults;
1913
- this.options.renderer = this.options.renderer || new _Renderer();
1914
- this.renderer = this.options.renderer;
1915
- this.renderer.options = this.options;
1916
- this.renderer.parser = this;
1917
- this.textRenderer = new _TextRenderer();
1918
- }
1919
- /**
1920
- * Static Parse Method
1921
- */
1922
- static parse(tokens, options) {
1923
- const parser = new _Parser(options);
1924
- return parser.parse(tokens);
1925
- }
1926
- /**
1927
- * Static Parse Inline Method
1928
- */
1929
- static parseInline(tokens, options) {
1930
- const parser = new _Parser(options);
1931
- return parser.parseInline(tokens);
1932
- }
1933
- /**
1934
- * Parse Loop
1935
- */
1936
- parse(tokens, top = true) {
1937
- let out = '';
1938
- for (let i = 0; i < tokens.length; i++) {
1939
- const anyToken = tokens[i];
1940
- // Run any renderer extensions
1941
- if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
1942
- const genericToken = anyToken;
1943
- const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
1944
- if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(genericToken.type)) {
1945
- out += ret || '';
1946
- continue;
1947
- }
1948
- }
1949
- const token = anyToken;
1950
- switch (token.type) {
1951
- case 'space': {
1952
- out += this.renderer.space(token);
1953
- continue;
1954
- }
1955
- case 'hr': {
1956
- out += this.renderer.hr(token);
1957
- continue;
1958
- }
1959
- case 'heading': {
1960
- out += this.renderer.heading(token);
1961
- continue;
1962
- }
1963
- case 'code': {
1964
- out += this.renderer.code(token);
1965
- continue;
1966
- }
1967
- case 'table': {
1968
- out += this.renderer.table(token);
1969
- continue;
1970
- }
1971
- case 'blockquote': {
1972
- out += this.renderer.blockquote(token);
1973
- continue;
1974
- }
1975
- case 'list': {
1976
- out += this.renderer.list(token);
1977
- continue;
1978
- }
1979
- case 'html': {
1980
- out += this.renderer.html(token);
1981
- continue;
1982
- }
1983
- case 'paragraph': {
1984
- out += this.renderer.paragraph(token);
1985
- continue;
1986
- }
1987
- case 'text': {
1988
- let textToken = token;
1989
- let body = this.renderer.text(textToken);
1990
- while (i + 1 < tokens.length && tokens[i + 1].type === 'text') {
1991
- textToken = tokens[++i];
1992
- body += '\n' + this.renderer.text(textToken);
1993
- }
1994
- if (top) {
1995
- out += this.renderer.paragraph({
1996
- type: 'paragraph',
1997
- raw: body,
1998
- text: body,
1999
- tokens: [{ type: 'text', raw: body, text: body }]
2000
- });
2001
- }
2002
- else {
2003
- out += body;
2004
- }
2005
- continue;
2006
- }
2007
- default: {
2008
- const errMsg = 'Token with "' + token.type + '" type was not found.';
2009
- if (this.options.silent) {
2010
- console.error(errMsg);
2011
- return '';
2012
- }
2013
- else {
2014
- throw new Error(errMsg);
2015
- }
2016
- }
2017
- }
2018
- }
2019
- return out;
2020
- }
2021
- /**
2022
- * Parse Inline Tokens
2023
- */
2024
- parseInline(tokens, renderer) {
2025
- renderer = renderer || this.renderer;
2026
- let out = '';
2027
- for (let i = 0; i < tokens.length; i++) {
2028
- const anyToken = tokens[i];
2029
- // Run any renderer extensions
2030
- if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
2031
- const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
2032
- if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(anyToken.type)) {
2033
- out += ret || '';
2034
- continue;
2035
- }
2036
- }
2037
- const token = anyToken;
2038
- switch (token.type) {
2039
- case 'escape': {
2040
- out += renderer.text(token);
2041
- break;
2042
- }
2043
- case 'html': {
2044
- out += renderer.html(token);
2045
- break;
2046
- }
2047
- case 'link': {
2048
- out += renderer.link(token);
2049
- break;
2050
- }
2051
- case 'image': {
2052
- out += renderer.image(token);
2053
- break;
2054
- }
2055
- case 'strong': {
2056
- out += renderer.strong(token);
2057
- break;
2058
- }
2059
- case 'em': {
2060
- out += renderer.em(token);
2061
- break;
2062
- }
2063
- case 'codespan': {
2064
- out += renderer.codespan(token);
2065
- break;
2066
- }
2067
- case 'br': {
2068
- out += renderer.br(token);
2069
- break;
2070
- }
2071
- case 'del': {
2072
- out += renderer.del(token);
2073
- break;
2074
- }
2075
- case 'text': {
2076
- out += renderer.text(token);
2077
- break;
2078
- }
2079
- default: {
2080
- const errMsg = 'Token with "' + token.type + '" type was not found.';
2081
- if (this.options.silent) {
2082
- console.error(errMsg);
2083
- return '';
2084
- }
2085
- else {
2086
- throw new Error(errMsg);
2087
- }
2088
- }
2089
- }
2090
- }
2091
- return out;
2092
- }
2093
- }
2094
-
2095
- class _Hooks {
2096
- options;
2097
- constructor(options) {
2098
- this.options = options || exports.defaults;
2099
- }
2100
- static passThroughHooks = new Set([
2101
- 'preprocess',
2102
- 'postprocess',
2103
- 'processAllTokens'
2104
- ]);
2105
- /**
2106
- * Process markdown before marked
2107
- */
2108
- preprocess(markdown) {
2109
- return markdown;
2110
- }
2111
- /**
2112
- * Process HTML after marked is finished
2113
- */
2114
- postprocess(html) {
2115
- return html;
2116
- }
2117
- /**
2118
- * Process all tokens before walk tokens
2119
- */
2120
- processAllTokens(tokens) {
2121
- return tokens;
2122
- }
2123
- }
2124
-
2125
- class Marked {
2126
- defaults = _getDefaults();
2127
- options = this.setOptions;
2128
- parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);
2129
- parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
2130
- Parser = _Parser;
2131
- Renderer = _Renderer;
2132
- TextRenderer = _TextRenderer;
2133
- Lexer = _Lexer;
2134
- Tokenizer = _Tokenizer;
2135
- Hooks = _Hooks;
2136
- constructor(...args) {
2137
- this.use(...args);
2138
- }
2139
- /**
2140
- * Run callback for every token
2141
- */
2142
- walkTokens(tokens, callback) {
2143
- let values = [];
2144
- for (const token of tokens) {
2145
- values = values.concat(callback.call(this, token));
2146
- switch (token.type) {
2147
- case 'table': {
2148
- const tableToken = token;
2149
- for (const cell of tableToken.header) {
2150
- values = values.concat(this.walkTokens(cell.tokens, callback));
2151
- }
2152
- for (const row of tableToken.rows) {
2153
- for (const cell of row) {
2154
- values = values.concat(this.walkTokens(cell.tokens, callback));
2155
- }
2156
- }
2157
- break;
2158
- }
2159
- case 'list': {
2160
- const listToken = token;
2161
- values = values.concat(this.walkTokens(listToken.items, callback));
2162
- break;
2163
- }
2164
- default: {
2165
- const genericToken = token;
2166
- if (this.defaults.extensions?.childTokens?.[genericToken.type]) {
2167
- this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
2168
- const tokens = genericToken[childTokens].flat(Infinity);
2169
- values = values.concat(this.walkTokens(tokens, callback));
2170
- });
2171
- }
2172
- else if (genericToken.tokens) {
2173
- values = values.concat(this.walkTokens(genericToken.tokens, callback));
2174
- }
2175
- }
2176
- }
2177
- }
2178
- return values;
2179
- }
2180
- use(...args) {
2181
- const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
2182
- args.forEach((pack) => {
2183
- // copy options to new object
2184
- const opts = { ...pack };
2185
- // set async to true if it was set to true before
2186
- opts.async = this.defaults.async || opts.async || false;
2187
- // ==-- Parse "addon" extensions --== //
2188
- if (pack.extensions) {
2189
- pack.extensions.forEach((ext) => {
2190
- if (!ext.name) {
2191
- throw new Error('extension name required');
2192
- }
2193
- if ('renderer' in ext) { // Renderer extensions
2194
- const prevRenderer = extensions.renderers[ext.name];
2195
- if (prevRenderer) {
2196
- // Replace extension with func to run new extension but fall back if false
2197
- extensions.renderers[ext.name] = function (...args) {
2198
- let ret = ext.renderer.apply(this, args);
2199
- if (ret === false) {
2200
- ret = prevRenderer.apply(this, args);
2201
- }
2202
- return ret;
2203
- };
2204
- }
2205
- else {
2206
- extensions.renderers[ext.name] = ext.renderer;
2207
- }
2208
- }
2209
- if ('tokenizer' in ext) { // Tokenizer Extensions
2210
- if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) {
2211
- throw new Error("extension level must be 'block' or 'inline'");
2212
- }
2213
- const extLevel = extensions[ext.level];
2214
- if (extLevel) {
2215
- extLevel.unshift(ext.tokenizer);
2216
- }
2217
- else {
2218
- extensions[ext.level] = [ext.tokenizer];
2219
- }
2220
- if (ext.start) { // Function to check for start of token
2221
- if (ext.level === 'block') {
2222
- if (extensions.startBlock) {
2223
- extensions.startBlock.push(ext.start);
2224
- }
2225
- else {
2226
- extensions.startBlock = [ext.start];
2227
- }
2228
- }
2229
- else if (ext.level === 'inline') {
2230
- if (extensions.startInline) {
2231
- extensions.startInline.push(ext.start);
2232
- }
2233
- else {
2234
- extensions.startInline = [ext.start];
2235
- }
2236
- }
2237
- }
2238
- }
2239
- if ('childTokens' in ext && ext.childTokens) { // Child tokens to be visited by walkTokens
2240
- extensions.childTokens[ext.name] = ext.childTokens;
2241
- }
2242
- });
2243
- opts.extensions = extensions;
2244
- }
2245
- // ==-- Parse "overwrite" extensions --== //
2246
- if (pack.renderer) {
2247
- const renderer = this.defaults.renderer || new _Renderer(this.defaults);
2248
- for (const prop in pack.renderer) {
2249
- if (!(prop in renderer)) {
2250
- throw new Error(`renderer '${prop}' does not exist`);
2251
- }
2252
- if (['options', 'parser'].includes(prop)) {
2253
- // ignore options property
2254
- continue;
2255
- }
2256
- const rendererProp = prop;
2257
- let rendererFunc = pack.renderer[rendererProp];
2258
- const prevRenderer = renderer[rendererProp];
2259
- // Replace renderer with func to run extension, but fall back if false
2260
- renderer[rendererProp] = (...args) => {
2261
- if (!pack.useNewRenderer) {
2262
- // TODO: Remove this in next major version
2263
- rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer);
2264
- }
2265
- let ret = rendererFunc.apply(renderer, args);
2266
- if (ret === false) {
2267
- ret = prevRenderer.apply(renderer, args);
2268
- }
2269
- return ret || '';
2270
- };
2271
- }
2272
- opts.renderer = renderer;
2273
- }
2274
- if (pack.tokenizer) {
2275
- const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
2276
- for (const prop in pack.tokenizer) {
2277
- if (!(prop in tokenizer)) {
2278
- throw new Error(`tokenizer '${prop}' does not exist`);
2279
- }
2280
- if (['options', 'rules', 'lexer'].includes(prop)) {
2281
- // ignore options, rules, and lexer properties
2282
- continue;
2283
- }
2284
- const tokenizerProp = prop;
2285
- const tokenizerFunc = pack.tokenizer[tokenizerProp];
2286
- const prevTokenizer = tokenizer[tokenizerProp];
2287
- // Replace tokenizer with func to run extension, but fall back if false
2288
- // @ts-expect-error cannot type tokenizer function dynamically
2289
- tokenizer[tokenizerProp] = (...args) => {
2290
- let ret = tokenizerFunc.apply(tokenizer, args);
2291
- if (ret === false) {
2292
- ret = prevTokenizer.apply(tokenizer, args);
2293
- }
2294
- return ret;
2295
- };
2296
- }
2297
- opts.tokenizer = tokenizer;
2298
- }
2299
- // ==-- Parse Hooks extensions --== //
2300
- if (pack.hooks) {
2301
- const hooks = this.defaults.hooks || new _Hooks();
2302
- for (const prop in pack.hooks) {
2303
- if (!(prop in hooks)) {
2304
- throw new Error(`hook '${prop}' does not exist`);
2305
- }
2306
- if (prop === 'options') {
2307
- // ignore options property
2308
- continue;
2309
- }
2310
- const hooksProp = prop;
2311
- const hooksFunc = pack.hooks[hooksProp];
2312
- const prevHook = hooks[hooksProp];
2313
- if (_Hooks.passThroughHooks.has(prop)) {
2314
- // @ts-expect-error cannot type hook function dynamically
2315
- hooks[hooksProp] = (arg) => {
2316
- if (this.defaults.async) {
2317
- return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => {
2318
- return prevHook.call(hooks, ret);
2319
- });
2320
- }
2321
- const ret = hooksFunc.call(hooks, arg);
2322
- return prevHook.call(hooks, ret);
2323
- };
2324
- }
2325
- else {
2326
- // @ts-expect-error cannot type hook function dynamically
2327
- hooks[hooksProp] = (...args) => {
2328
- let ret = hooksFunc.apply(hooks, args);
2329
- if (ret === false) {
2330
- ret = prevHook.apply(hooks, args);
2331
- }
2332
- return ret;
2333
- };
2334
- }
2335
- }
2336
- opts.hooks = hooks;
2337
- }
2338
- // ==-- Parse WalkTokens extensions --== //
2339
- if (pack.walkTokens) {
2340
- const walkTokens = this.defaults.walkTokens;
2341
- const packWalktokens = pack.walkTokens;
2342
- opts.walkTokens = function (token) {
2343
- let values = [];
2344
- values.push(packWalktokens.call(this, token));
2345
- if (walkTokens) {
2346
- values = values.concat(walkTokens.call(this, token));
2347
- }
2348
- return values;
2349
- };
2350
- }
2351
- this.defaults = { ...this.defaults, ...opts };
2352
- });
2353
- return this;
2354
- }
2355
- // TODO: Remove this in next major release
2356
- #convertRendererFunction(func, prop, renderer) {
2357
- switch (prop) {
2358
- case 'heading':
2359
- return function (token) {
2360
- if (!token.type || token.type !== prop) {
2361
- // @ts-ignore
2362
- // eslint-disable-next-line prefer-rest-params
2363
- return func.apply(this, arguments);
2364
- }
2365
- return func.call(this, renderer.parser.parseInline(token.tokens), token.depth, unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer)));
2366
- };
2367
- case 'code':
2368
- return function (token) {
2369
- if (!token.type || token.type !== prop) {
2370
- // @ts-ignore
2371
- // eslint-disable-next-line prefer-rest-params
2372
- return func.apply(this, arguments);
2373
- }
2374
- return func.call(this, token.text, token.lang, !!token.escaped);
2375
- };
2376
- case 'table':
2377
- return function (token) {
2378
- if (!token.type || token.type !== prop) {
2379
- // @ts-ignore
2380
- // eslint-disable-next-line prefer-rest-params
2381
- return func.apply(this, arguments);
2382
- }
2383
- let header = '';
2384
- // header
2385
- let cell = '';
2386
- for (let j = 0; j < token.header.length; j++) {
2387
- cell += this.tablecell({
2388
- text: token.header[j].text,
2389
- tokens: token.header[j].tokens,
2390
- header: true,
2391
- align: token.align[j]
2392
- });
2393
- }
2394
- header += this.tablerow({ text: cell });
2395
- let body = '';
2396
- for (let j = 0; j < token.rows.length; j++) {
2397
- const row = token.rows[j];
2398
- cell = '';
2399
- for (let k = 0; k < row.length; k++) {
2400
- cell += this.tablecell({
2401
- text: row[k].text,
2402
- tokens: row[k].tokens,
2403
- header: false,
2404
- align: token.align[k]
2405
- });
2406
- }
2407
- body += this.tablerow({ text: cell });
2408
- }
2409
- return func.call(this, header, body);
2410
- };
2411
- case 'blockquote':
2412
- return function (token) {
2413
- if (!token.type || token.type !== prop) {
2414
- // @ts-ignore
2415
- // eslint-disable-next-line prefer-rest-params
2416
- return func.apply(this, arguments);
2417
- }
2418
- const body = this.parser.parse(token.tokens);
2419
- return func.call(this, body);
2420
- };
2421
- case 'list':
2422
- return function (token) {
2423
- if (!token.type || token.type !== prop) {
2424
- // @ts-ignore
2425
- // eslint-disable-next-line prefer-rest-params
2426
- return func.apply(this, arguments);
2427
- }
2428
- const ordered = token.ordered;
2429
- const start = token.start;
2430
- const loose = token.loose;
2431
- let body = '';
2432
- for (let j = 0; j < token.items.length; j++) {
2433
- const item = token.items[j];
2434
- const checked = item.checked;
2435
- const task = item.task;
2436
- let itemBody = '';
2437
- if (item.task) {
2438
- const checkbox = this.checkbox({ checked: !!checked });
2439
- if (loose) {
2440
- if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
2441
- item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
2442
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
2443
- item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
2444
- }
2445
- }
2446
- else {
2447
- item.tokens.unshift({
2448
- type: 'text',
2449
- text: checkbox + ' '
2450
- });
2451
- }
2452
- }
2453
- else {
2454
- itemBody += checkbox + ' ';
2455
- }
2456
- }
2457
- itemBody += this.parser.parse(item.tokens, loose);
2458
- body += this.listitem({
2459
- type: 'list_item',
2460
- raw: itemBody,
2461
- text: itemBody,
2462
- task,
2463
- checked: !!checked,
2464
- loose,
2465
- tokens: item.tokens
2466
- });
2467
- }
2468
- return func.call(this, body, ordered, start);
2469
- };
2470
- case 'html':
2471
- return function (token) {
2472
- if (!token.type || token.type !== prop) {
2473
- // @ts-ignore
2474
- // eslint-disable-next-line prefer-rest-params
2475
- return func.apply(this, arguments);
2476
- }
2477
- return func.call(this, token.text, token.block);
2478
- };
2479
- case 'paragraph':
2480
- return function (token) {
2481
- if (!token.type || token.type !== prop) {
2482
- // @ts-ignore
2483
- // eslint-disable-next-line prefer-rest-params
2484
- return func.apply(this, arguments);
2485
- }
2486
- return func.call(this, this.parser.parseInline(token.tokens));
2487
- };
2488
- case 'escape':
2489
- return function (token) {
2490
- if (!token.type || token.type !== prop) {
2491
- // @ts-ignore
2492
- // eslint-disable-next-line prefer-rest-params
2493
- return func.apply(this, arguments);
2494
- }
2495
- return func.call(this, token.text);
2496
- };
2497
- case 'link':
2498
- return function (token) {
2499
- if (!token.type || token.type !== prop) {
2500
- // @ts-ignore
2501
- // eslint-disable-next-line prefer-rest-params
2502
- return func.apply(this, arguments);
2503
- }
2504
- return func.call(this, token.href, token.title, this.parser.parseInline(token.tokens));
2505
- };
2506
- case 'image':
2507
- return function (token) {
2508
- if (!token.type || token.type !== prop) {
2509
- // @ts-ignore
2510
- // eslint-disable-next-line prefer-rest-params
2511
- return func.apply(this, arguments);
2512
- }
2513
- return func.call(this, token.href, token.title, token.text);
2514
- };
2515
- case 'strong':
2516
- return function (token) {
2517
- if (!token.type || token.type !== prop) {
2518
- // @ts-ignore
2519
- // eslint-disable-next-line prefer-rest-params
2520
- return func.apply(this, arguments);
2521
- }
2522
- return func.call(this, this.parser.parseInline(token.tokens));
2523
- };
2524
- case 'em':
2525
- return function (token) {
2526
- if (!token.type || token.type !== prop) {
2527
- // @ts-ignore
2528
- // eslint-disable-next-line prefer-rest-params
2529
- return func.apply(this, arguments);
2530
- }
2531
- return func.call(this, this.parser.parseInline(token.tokens));
2532
- };
2533
- case 'codespan':
2534
- return function (token) {
2535
- if (!token.type || token.type !== prop) {
2536
- // @ts-ignore
2537
- // eslint-disable-next-line prefer-rest-params
2538
- return func.apply(this, arguments);
2539
- }
2540
- return func.call(this, token.text);
2541
- };
2542
- case 'del':
2543
- return function (token) {
2544
- if (!token.type || token.type !== prop) {
2545
- // @ts-ignore
2546
- // eslint-disable-next-line prefer-rest-params
2547
- return func.apply(this, arguments);
2548
- }
2549
- return func.call(this, this.parser.parseInline(token.tokens));
2550
- };
2551
- case 'text':
2552
- return function (token) {
2553
- if (!token.type || token.type !== prop) {
2554
- // @ts-ignore
2555
- // eslint-disable-next-line prefer-rest-params
2556
- return func.apply(this, arguments);
2557
- }
2558
- return func.call(this, token.text);
2559
- };
2560
- // do nothing
2561
- }
2562
- return func;
2563
- }
2564
- setOptions(opt) {
2565
- this.defaults = { ...this.defaults, ...opt };
2566
- return this;
2567
- }
2568
- lexer(src, options) {
2569
- return _Lexer.lex(src, options ?? this.defaults);
2570
- }
2571
- parser(tokens, options) {
2572
- return _Parser.parse(tokens, options ?? this.defaults);
2573
- }
2574
- #parseMarkdown(lexer, parser) {
2575
- return (src, options) => {
2576
- const origOpt = { ...options };
2577
- const opt = { ...this.defaults, ...origOpt };
2578
- // Show warning if an extension set async to true but the parse was called with async: false
2579
- if (this.defaults.async === true && origOpt.async === false) {
2580
- if (!opt.silent) {
2581
- console.warn('marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.');
2582
- }
2583
- opt.async = true;
2584
- }
2585
- const throwError = this.#onError(!!opt.silent, !!opt.async);
2586
- // throw error in case of non string input
2587
- if (typeof src === 'undefined' || src === null) {
2588
- return throwError(new Error('marked(): input parameter is undefined or null'));
2589
- }
2590
- if (typeof src !== 'string') {
2591
- return throwError(new Error('marked(): input parameter is of type '
2592
- + Object.prototype.toString.call(src) + ', string expected'));
2593
- }
2594
- if (opt.hooks) {
2595
- opt.hooks.options = opt;
2596
- }
2597
- if (opt.async) {
2598
- return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
2599
- .then(src => lexer(src, opt))
2600
- .then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens)
2601
- .then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens)
2602
- .then(tokens => parser(tokens, opt))
2603
- .then(html => opt.hooks ? opt.hooks.postprocess(html) : html)
2604
- .catch(throwError);
2605
- }
2606
- try {
2607
- if (opt.hooks) {
2608
- src = opt.hooks.preprocess(src);
2609
- }
2610
- let tokens = lexer(src, opt);
2611
- if (opt.hooks) {
2612
- tokens = opt.hooks.processAllTokens(tokens);
2613
- }
2614
- if (opt.walkTokens) {
2615
- this.walkTokens(tokens, opt.walkTokens);
2616
- }
2617
- let html = parser(tokens, opt);
2618
- if (opt.hooks) {
2619
- html = opt.hooks.postprocess(html);
2620
- }
2621
- return html;
2622
- }
2623
- catch (e) {
2624
- return throwError(e);
2625
- }
2626
- };
2627
- }
2628
- #onError(silent, async) {
2629
- return (e) => {
2630
- e.message += '\nPlease report this to https://github.com/markedjs/marked.';
2631
- if (silent) {
2632
- const msg = '<p>An error occurred:</p><pre>'
2633
- + escape$1(e.message + '', true)
2634
- + '</pre>';
2635
- if (async) {
2636
- return Promise.resolve(msg);
2637
- }
2638
- return msg;
2639
- }
2640
- if (async) {
2641
- return Promise.reject(e);
2642
- }
2643
- throw e;
2644
- };
2645
- }
2646
- }
2647
-
2648
- const markedInstance = new Marked();
2649
- function marked(src, opt) {
2650
- return markedInstance.parse(src, opt);
2651
- }
2652
- /**
2653
- * Sets the default options.
2654
- *
2655
- * @param options Hash of options
2656
- */
2657
- marked.options =
2658
- marked.setOptions = function (options) {
2659
- markedInstance.setOptions(options);
2660
- marked.defaults = markedInstance.defaults;
2661
- changeDefaults(marked.defaults);
2662
- return marked;
2663
- };
2664
- /**
2665
- * Gets the original marked default options.
2666
- */
2667
- marked.getDefaults = _getDefaults;
2668
- marked.defaults = exports.defaults;
2669
- /**
2670
- * Use Extension
2671
- */
2672
- marked.use = function (...args) {
2673
- markedInstance.use(...args);
2674
- marked.defaults = markedInstance.defaults;
2675
- changeDefaults(marked.defaults);
2676
- return marked;
2677
- };
2678
- /**
2679
- * Run callback for every token
2680
- */
2681
- marked.walkTokens = function (tokens, callback) {
2682
- return markedInstance.walkTokens(tokens, callback);
2683
- };
2684
- /**
2685
- * Compiles markdown to HTML without enclosing `p` tag.
2686
- *
2687
- * @param src String of markdown source to be compiled
2688
- * @param options Hash of options
2689
- * @return String of compiled HTML
2690
- */
2691
- marked.parseInline = markedInstance.parseInline;
2692
- /**
2693
- * Expose
2694
- */
2695
- marked.Parser = _Parser;
2696
- marked.parser = _Parser.parse;
2697
- marked.Renderer = _Renderer;
2698
- marked.TextRenderer = _TextRenderer;
2699
- marked.Lexer = _Lexer;
2700
- marked.lexer = _Lexer.lex;
2701
- marked.Tokenizer = _Tokenizer;
2702
- marked.Hooks = _Hooks;
2703
- marked.parse = marked;
2704
- const options = marked.options;
2705
- const setOptions = marked.setOptions;
2706
- const use = marked.use;
2707
- const walkTokens = marked.walkTokens;
2708
- const parseInline = marked.parseInline;
2709
- const parse = marked;
2710
- const parser = _Parser.parse;
2711
- const lexer = _Lexer.lex;
2712
-
2713
- exports.Hooks = _Hooks;
2714
- exports.Lexer = _Lexer;
2715
- exports.Marked = Marked;
2716
- exports.Parser = _Parser;
2717
- exports.Renderer = _Renderer;
2718
- exports.TextRenderer = _TextRenderer;
2719
- exports.Tokenizer = _Tokenizer;
2720
- exports.getDefaults = _getDefaults;
2721
- exports.lexer = lexer;
2722
- exports.marked = marked;
2723
- exports.options = options;
2724
- exports.parse = parse;
2725
- exports.parseInline = parseInline;
2726
- exports.parser = parser;
2727
- exports.setOptions = setOptions;
2728
- exports.use = use;
2729
- exports.walkTokens = walkTokens;
2730
-
2731
- }));
78
+ if(__exports != exports)module.exports = exports;return module.exports}));
2732
79
  //# sourceMappingURL=marked.umd.js.map