@pod-os/elements 0.37.0-rc.c8b54d1.0 → 0.37.0

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 (144) hide show
  1. package/dist/cjs/{chunk.URTPIBTY-DdK9pL5v.js → chunk.URTPIBTY-DcQsb_nW.js} +2 -2
  2. package/dist/cjs/{chunk.XQ2OKYYA-DEkhm1i7.js → chunk.XQ2OKYYA-D224sdKt.js} +3 -3
  3. package/dist/cjs/{chunk.ZGGPD2XJ-uKZZdqOH.js → chunk.ZGGPD2XJ-Cj6xUx2M.js} +1 -1
  4. package/dist/cjs/{class-map-DAZXfKKA.js → class-map-Nx8L8ElN.js} +1 -1
  5. package/dist/cjs/elements.cjs.js +3 -3
  6. package/dist/cjs/{index-DCpu_nnH.js → index-Be_lnf0w.js} +547 -2001
  7. package/dist/cjs/{index-FUnpyb19.js → index-OR1wNkjG.js} +1052 -489
  8. package/dist/cjs/{jsonld-V2RB47OZ-BerQ9IRa.js → jsonld-V2RB47OZ-B82QNsYZ.js} +1 -1
  9. package/dist/cjs/loader.cjs.js +2 -2
  10. package/dist/cjs/pos-add-literal-value_3.cjs.entry.js +6 -6
  11. package/dist/cjs/{pos-add-new-thing_31.cjs.entry.js → pos-add-new-thing_32.cjs.entry.js} +411 -227
  12. package/dist/cjs/pos-app-document-viewer.cjs.entry.js +1 -1
  13. package/dist/cjs/pos-app-generic.cjs.entry.js +1 -1
  14. package/dist/cjs/pos-app-image-viewer.cjs.entry.js +1 -1
  15. package/dist/cjs/pos-app-ldp-container.cjs.entry.js +1 -1
  16. package/dist/cjs/pos-app-rdf-document.cjs.entry.js +1 -1
  17. package/dist/cjs/pos-attachments.cjs.entry.js +2 -2
  18. package/dist/cjs/pos-case.cjs.entry.js +24 -0
  19. package/dist/cjs/pos-container-contents.cjs.entry.js +13 -4
  20. package/dist/cjs/pos-container-item_3.cjs.entry.js +4 -4
  21. package/dist/cjs/pos-document.cjs.entry.js +4 -4
  22. package/dist/cjs/pos-list.cjs.entry.js +1 -1
  23. package/dist/cjs/pos-markdown-document.cjs.entry.js +442 -2327
  24. package/dist/cjs/pos-relations_2.cjs.entry.js +1 -1
  25. package/dist/cjs/pos-subjects.cjs.entry.js +2 -2
  26. package/dist/cjs/pos-switch.cjs.entry.js +64 -0
  27. package/dist/cjs/pos-tool-attachments.cjs.entry.js +2 -2
  28. package/dist/cjs/pos-value.cjs.entry.js +1 -1
  29. package/dist/collection/collection-manifest.json +5 -1
  30. package/dist/collection/components/pos-app/pos-app.js +2 -1
  31. package/dist/collection/components/pos-attachments/pos-attachments.js +2 -1
  32. package/dist/collection/components/pos-container-contents/pos-container-contents.js +10 -1
  33. package/dist/collection/components/pos-container-contents/pos-create-new-container-item/pos-create-new-container-item.js +4 -2
  34. package/dist/collection/components/pos-markdown-document/pos-markdown-document.js +2 -1
  35. package/dist/collection/components/pos-navigation/bar/pos-navigation-bar.css +42 -22
  36. package/dist/collection/components/pos-navigation/bar/pos-navigation-bar.js +3 -2
  37. package/dist/collection/components/pos-new-thing-form/pos-new-thing-form.js +1 -1
  38. package/dist/collection/components/pos-router/pos-router.js +1 -1
  39. package/dist/collection/components/pos-select-term/pos-select-term.js +1 -1
  40. package/dist/collection/components/pos-share/openNewTab.js +3 -0
  41. package/dist/collection/components/pos-share/pos-share.css +36 -0
  42. package/dist/collection/components/pos-share/pos-share.js +111 -0
  43. package/dist/collection/components/pos-switch/pos-case/pos-case.js +88 -0
  44. package/dist/collection/components/pos-switch/pos-switch.js +89 -0
  45. package/dist/collection/components/pos-tool-select/pos-tool-select.js +6 -3
  46. package/dist/collection/components/pos-upload/pos-upload.js +7 -4
  47. package/dist/collection/components/pos-user-menu/pos-user-menu.js +1 -1
  48. package/dist/collection/tools/pos-tool-attachments/pos-tool-attachments.js +1 -1
  49. package/dist/components/chunk.IVVHNXMC.js +20 -0
  50. package/dist/components/index.js +1 -1
  51. package/dist/components/index2.js +2 -2
  52. package/dist/components/pos-add-literal-value2.js +1 -1
  53. package/dist/components/pos-app-browser.js +1 -1
  54. package/dist/components/pos-attachments2.js +1 -1
  55. package/dist/components/pos-case.d.ts +11 -0
  56. package/dist/components/pos-case.js +1 -0
  57. package/dist/components/pos-container-contents2.js +1 -1
  58. package/dist/components/pos-make-findable2.js +1 -1
  59. package/dist/components/pos-markdown-document2.js +1 -1
  60. package/dist/components/pos-navigation-bar2.js +1 -1
  61. package/dist/components/pos-navigation2.js +1 -1
  62. package/dist/components/pos-new-thing-form2.js +1 -1
  63. package/dist/components/pos-router2.js +1 -1
  64. package/dist/components/pos-select-term2.js +1 -1
  65. package/dist/components/pos-share.d.ts +11 -0
  66. package/dist/components/pos-share.js +1 -0
  67. package/dist/components/pos-share2.js +1 -0
  68. package/dist/components/pos-switch.d.ts +11 -0
  69. package/dist/components/pos-switch.js +1 -0
  70. package/dist/components/pos-tool-attachments.js +1 -1
  71. package/dist/components/pos-tool-select2.js +1 -1
  72. package/dist/components/pos-type-index-entries2.js +1 -1
  73. package/dist/components/pos-upload2.js +12 -3
  74. package/dist/components/pos-user-menu2.js +6 -25
  75. package/dist/elements/elements.esm.js +1 -1
  76. package/dist/elements/{p-6561f1b7.entry.js → p-03464a71.entry.js} +1 -1
  77. package/dist/elements/{p-52a612ed.entry.js → p-272209e3.entry.js} +1 -1
  78. package/dist/elements/{p-a9a18aa8.entry.js → p-38aa17bc.entry.js} +1 -1
  79. package/dist/elements/p-3a890f5f.entry.js +1 -0
  80. package/dist/elements/{p-9ad80b52.entry.js → p-4cd2f9da.entry.js} +1 -1
  81. package/dist/elements/{p-0e7413e6.entry.js → p-5126fb6e.entry.js} +1 -1
  82. package/dist/elements/p-53610ccd.entry.js +1 -0
  83. package/dist/elements/{p-b5d64c6f.entry.js → p-631976a8.entry.js} +1 -1
  84. package/dist/elements/{p-fe628201.entry.js → p-6d628d74.entry.js} +1 -1
  85. package/dist/elements/{p-b363349c.entry.js → p-7c3785d8.entry.js} +1 -1
  86. package/dist/elements/p-8934c5ea.entry.js +1 -0
  87. package/dist/elements/p-8e76e9dc.entry.js +1 -0
  88. package/dist/elements/{p-3e18b5dd.entry.js → p-9bf6c310.entry.js} +1 -1
  89. package/dist/elements/{p-Doy_38_j.js → p-BLUiM5OK.js} +1 -1
  90. package/dist/elements/{p-BkAnMOpW.js → p-CSTMd_cW.js} +2 -2
  91. package/dist/elements/{p-CrxYqX8r.js → p-CVwgVrbO.js} +7 -7
  92. package/dist/elements/{p-8ggjG2YF.js → p-CnIOZlf7.js} +1 -1
  93. package/dist/elements/p-DHl0QGLf.js +67 -0
  94. package/dist/elements/p-DzbCx-pP.js +2 -0
  95. package/dist/elements/{p-c8ee910c.entry.js → p-a1dd6b42.entry.js} +1 -1
  96. package/dist/elements/p-ab4eba43.entry.js +859 -0
  97. package/dist/elements/{p-dff14248.entry.js → p-c7032012.entry.js} +1 -1
  98. package/dist/elements/{p-a20b72d8.entry.js → p-d396cc56.entry.js} +1 -1
  99. package/dist/elements/p-dc4c38c8.entry.js +1 -0
  100. package/dist/elements/{p-0a087865.entry.js → p-e0660718.entry.js} +1 -1
  101. package/dist/elements/{p-8q-RA2Uq.js → p-mIPOXLnA.js} +3 -3
  102. package/dist/esm/{chunk.URTPIBTY-CNA3-SLq.js → chunk.URTPIBTY-yxgfEQ1K.js} +2 -2
  103. package/dist/esm/{chunk.XQ2OKYYA-CXNlpYUG.js → chunk.XQ2OKYYA-Cr3bMzqn.js} +3 -3
  104. package/dist/esm/{chunk.ZGGPD2XJ-BjT6fS1o.js → chunk.ZGGPD2XJ-SJISSXOc.js} +1 -1
  105. package/dist/esm/{class-map-CUYFUkXU.js → class-map-DEweE_Cr.js} +1 -1
  106. package/dist/esm/elements.js +4 -4
  107. package/dist/esm/{index-DFqG64hG.js → index-CXK32bJz.js} +1052 -489
  108. package/dist/esm/{index-VMHzF3uY.js → index-DzbCx-pP.js} +547 -2001
  109. package/dist/esm/{jsonld-V2RB47OZ-CaIJ08AA.js → jsonld-V2RB47OZ-BbN7F0s8.js} +1 -1
  110. package/dist/esm/loader.js +3 -3
  111. package/dist/esm/pos-add-literal-value_3.entry.js +6 -6
  112. package/dist/esm/{pos-add-new-thing_31.entry.js → pos-add-new-thing_32.entry.js} +411 -228
  113. package/dist/esm/pos-app-document-viewer.entry.js +1 -1
  114. package/dist/esm/pos-app-generic.entry.js +1 -1
  115. package/dist/esm/pos-app-image-viewer.entry.js +1 -1
  116. package/dist/esm/pos-app-ldp-container.entry.js +1 -1
  117. package/dist/esm/pos-app-rdf-document.entry.js +1 -1
  118. package/dist/esm/pos-attachments.entry.js +2 -2
  119. package/dist/esm/pos-case.entry.js +22 -0
  120. package/dist/esm/pos-container-contents.entry.js +12 -3
  121. package/dist/esm/pos-container-item_3.entry.js +4 -4
  122. package/dist/esm/pos-document.entry.js +4 -4
  123. package/dist/esm/pos-list.entry.js +1 -1
  124. package/dist/esm/pos-markdown-document.entry.js +442 -2327
  125. package/dist/esm/pos-relations_2.entry.js +1 -1
  126. package/dist/esm/pos-subjects.entry.js +2 -2
  127. package/dist/esm/pos-switch.entry.js +62 -0
  128. package/dist/esm/pos-tool-attachments.entry.js +2 -2
  129. package/dist/esm/pos-value.entry.js +1 -1
  130. package/dist/jest-setup.js +4 -0
  131. package/dist/types/components/pos-container-contents/pos-container-contents.d.ts +2 -0
  132. package/dist/types/components/pos-share/openNewTab.d.ts +1 -0
  133. package/dist/types/components/pos-share/pos-share.d.ts +28 -0
  134. package/dist/types/components/pos-switch/pos-case/pos-case.d.ts +22 -0
  135. package/dist/types/components/pos-switch/pos-switch.d.ts +19 -0
  136. package/dist/types/components.d.ts +300 -74
  137. package/dist/types/stencil-public-runtime.d.ts +52 -2
  138. package/package.json +13 -12
  139. package/dist/elements/p-637a38d9.entry.js +0 -1
  140. package/dist/elements/p-701f2c84.entry.js +0 -850
  141. package/dist/elements/p-9b74c400.entry.js +0 -1
  142. package/dist/elements/p-LoCE14bN.js +0 -67
  143. package/dist/elements/p-VMHzF3uY.js +0 -2
  144. package/dist/elements/p-ac17ed6a.entry.js +0 -1
@@ -1,6 +1,6 @@
1
- import { r as registerInstance, c as createEvent, h as h$1 } from './index-VMHzF3uY.js';
1
+ import { r as registerInstance, c as createEvent, h as h$1 } from './index-DzbCx-pP.js';
2
2
  import { r as requireFilter, a as requireNot, b as requireRaceWith, d as requireArgsOrArgArray, e as requireAudit, f as requireAuditTime, g as requireBuffer, h as requireBufferCount, i as requireBufferTime, j as requireBufferToggle, k as requireBufferWhen, l as requireCatchError, m as requireCombineAll, n as requireCombineLatestAll, o as requireCombineLatest, p as requireCombineLatestWith, q as requireConcat, s as requireConcatAll, t as requireConcatMap, u as requireConcatMapTo, v as requireConcatWith, w as requireConnect, x as requireCount, y as requireDebounce, z as requireDebounceTime, A as requireDefaultIfEmpty, B as requireDelay, C as requireDelayWhen, D as requireDematerialize, E as requireDistinct, F as requireDistinctUntilChanged, G as requireDistinctUntilKeyChanged, H as requireElementAt, I as requireEndWith, J as requireEvery, K as requireExhaust, L as requireExhaustAll, M as requireExhaustMap, N as requireExpand, O as requireFinalize, P as requireFind, Q as requireFindIndex, R as requireFirst, S as requireGroupBy, T as requireIgnoreElements, U as requireIsEmpty, V as requireLast, W as requireMap, X as requireMapTo, Y as requireMaterialize, Z as requireMax, _ as requireMerge, $ as requireMergeAll, a0 as requireFlatMap, a1 as requireMergeMap, a2 as requireMergeMapTo, a3 as requireMergeScan, a4 as requireMergeWith, a5 as requireMin, a6 as requireMulticast, a7 as requireObserveOn, a8 as requireOnErrorResumeNextWith, a9 as requirePairwise, aa as requirePluck, ab as requirePublish, ac as requirePublishBehavior, ad as requirePublishLast, ae as requirePublishReplay, af as requireReduce, ag as requireRepeat, ah as requireRepeatWhen, ai as requireRetry, aj as requireRetryWhen, ak as requireRefCount, al as requireSample, am as requireSampleTime, an as requireScan, ao as requireSequenceEqual, ap as requireShare, aq as requireShareReplay, ar as requireSingle, as as requireSkip, at as requireSkipLast, au as requireSkipUntil, av as requireSkipWhile, aw as requireStartWith, ax as requireSubscribeOn, ay as requireSwitchAll, az as requireSwitchMap, aA as requireSwitchMapTo, aB as requireSwitchScan, aC as requireTake, aD as requireTakeLast, aE as requireTakeUntil, aF as requireTakeWhile, aG as requireTap, aH as requireThrottle, aI as requireThrottleTime, aJ as requireThrowIfEmpty, aK as requireTimeInterval, aL as requireTimeout, aM as requireTimeoutWith, aN as requireTimestamp, aO as requireToArray, aP as requireWindow, aQ as requireWindowCount, aR as requireWindowTime, aS as requireWindowToggle, aT as requireWindowWhen, aU as requireWithLatestFrom, aV as requireZip, aW as requireZipAll, aX as requireZipWith, c as cjsExports } from './index-vFMstSdt.js';
3
- import './chunk.ZGGPD2XJ-BjT6fS1o.js';
3
+ import './chunk.ZGGPD2XJ-SJISSXOc.js';
4
4
 
5
5
  // ::- Persistent data structure representing an ordered mapping from
6
6
  // strings to values, with some convenient update methods.
@@ -2835,7 +2835,7 @@ function wsOptionsFor(type, preserveWhitespace, base) {
2835
2835
  if (preserveWhitespace != null)
2836
2836
  return (preserveWhitespace ? OPT_PRESERVE_WS : 0) |
2837
2837
  (preserveWhitespace === "full" ? OPT_PRESERVE_WS_FULL : 0);
2838
- return type && type.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base & -5;
2838
+ return type && type.whitespace == "pre" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base & ~OPT_OPEN_LEFT;
2839
2839
  }
2840
2840
  class NodeContext {
2841
2841
  constructor(type, attrs, marks, solid, match, options) {
@@ -6273,7 +6273,7 @@ class Transaction extends Transform {
6273
6273
  throw new RangeError("Selection passed to setSelection must point at the current document");
6274
6274
  this.curSelection = selection;
6275
6275
  this.curSelectionFor = this.steps.length;
6276
- this.updated = (this.updated | UPDATED_SEL) & -3;
6276
+ this.updated = (this.updated | UPDATED_SEL) & ~UPDATED_MARKS;
6277
6277
  this.storedMarks = null;
6278
6278
  return this;
6279
6279
  }
@@ -6324,7 +6324,7 @@ class Transaction extends Transform {
6324
6324
  */
6325
6325
  addStep(step, doc) {
6326
6326
  super.addStep(step, doc);
6327
- this.updated = this.updated & -3;
6327
+ this.updated = this.updated & ~UPDATED_MARKS;
6328
6328
  this.storedMarks = null;
6329
6329
  }
6330
6330
  /**
@@ -7616,13 +7616,13 @@ const agent = (nav && nav.userAgent) || "";
7616
7616
  const ie_edge = /Edge\/(\d+)/.exec(agent);
7617
7617
  const ie_upto10 = /MSIE \d/.exec(agent);
7618
7618
  const ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(agent);
7619
- const ie$1 = !!(ie_upto10 || ie_11up || ie_edge);
7619
+ const ie$2 = !!(ie_upto10 || ie_11up || ie_edge);
7620
7620
  const ie_version = ie_upto10 ? document.documentMode : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0;
7621
- const gecko = !ie$1 && /gecko\/(\d+)/i.test(agent);
7622
- const _chrome = !ie$1 && /Chrome\/(\d+)/.exec(agent);
7621
+ const gecko = !ie$2 && /gecko\/(\d+)/i.test(agent);
7622
+ const _chrome = !ie$2 && /Chrome\/(\d+)/.exec(agent);
7623
7623
  const chrome = !!_chrome;
7624
7624
  const chrome_version = _chrome ? +_chrome[1] : 0;
7625
- const safari = !ie$1 && !!nav && /Apple Computer/.test(nav.vendor);
7625
+ const safari = !ie$2 && !!nav && /Apple Computer/.test(nav.vendor);
7626
7626
  // Is true for both iOS and iPadOS for convenience
7627
7627
  const ios = safari && (/Mobile\/\w+/.test(agent) || !!nav && nav.maxTouchPoints > 2);
7628
7628
  const mac$2 = ios || (nav ? /Mac/.test(nav.platform) : false);
@@ -9794,7 +9794,7 @@ function selectCursorWrapper(view) {
9794
9794
  // resize handles and a selection that considers the absolutely
9795
9795
  // positioned wrapper, rather than the root editable node, the
9796
9796
  // focused element.
9797
- if (!img && !view.state.selection.visible && ie$1 && ie_version <= 11) {
9797
+ if (!img && !view.state.selection.visible && ie$2 && ie_version <= 11) {
9798
9798
  node.disabled = true;
9799
9799
  node.disabled = false;
9800
9800
  }
@@ -11047,7 +11047,7 @@ function captureCopy(view, dom) {
11047
11047
  // This is very crude, but unfortunately both these browsers _pretend_
11048
11048
  // that they have a clipboard API—all the objects and methods are
11049
11049
  // there, they just don't work, and they are hard to test.
11050
- const brokenClipboardAPI = (ie$1 && ie_version < 15) ||
11050
+ const brokenClipboardAPI = (ie$2 && ie_version < 15) ||
11051
11051
  (ios && webkit_version < 604);
11052
11052
  handlers.copy = editHandlers.cut = (view, _event) => {
11053
11053
  let event = _event;
@@ -11978,7 +11978,7 @@ const observeOptions = {
11978
11978
  subtree: true
11979
11979
  };
11980
11980
  // IE11 has very broken mutation observers, so we also listen to DOMCharacterDataModified
11981
- const useCharData = ie$1 && ie_version <= 11;
11981
+ const useCharData = ie$2 && ie_version <= 11;
11982
11982
  class SelectionState {
11983
11983
  constructor() {
11984
11984
  this.anchorNode = null;
@@ -12019,7 +12019,7 @@ class DOMObserver {
12019
12019
  // text node after a BR node) call the observer callback
12020
12020
  // before actually updating the DOM, which will cause
12021
12021
  // ProseMirror to miss the change (see #930)
12022
- if (ie$1 && ie_version <= 11 && mutations.some(m => m.type == "childList" && m.removedNodes.length ||
12022
+ if (ie$2 && ie_version <= 11 && mutations.some(m => m.type == "childList" && m.removedNodes.length ||
12023
12023
  m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
12024
12024
  this.flushSoon();
12025
12025
  else
@@ -12085,7 +12085,7 @@ class DOMObserver {
12085
12085
  // Deletions on IE11 fire their events in the wrong order, giving
12086
12086
  // us a selection change event before the DOM changes are
12087
12087
  // reported.
12088
- if (ie$1 && ie_version <= 11 && !this.view.state.selection.empty) {
12088
+ if (ie$2 && ie_version <= 11 && !this.view.state.selection.empty) {
12089
12089
  let sel = this.view.domSelectionRange();
12090
12090
  // Selection.isCollapsed isn't reliable on IE
12091
12091
  if (sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
@@ -12209,7 +12209,7 @@ class DOMObserver {
12209
12209
  if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
12210
12210
  return { from: desc.posBefore, to: desc.posAfter };
12211
12211
  let prev = mut.previousSibling, next = mut.nextSibling;
12212
- if (ie$1 && ie_version <= 11 && mut.addedNodes.length) {
12212
+ if (ie$2 && ie_version <= 11 && mut.addedNodes.length) {
12213
12213
  // IE11 gives us incorrect next/prev siblings for some
12214
12214
  // insertions, so if there are added nodes, recompute those
12215
12215
  for (let i = 0; i < mut.addedNodes.length; i++) {
@@ -12464,7 +12464,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
12464
12464
  // IE11 will insert a non-breaking space _ahead_ of the space after
12465
12465
  // the cursor space when adding a space before another space. When
12466
12466
  // that happened, adjust the change to cover the space instead.
12467
- if (ie$1 && ie_version <= 11 && change.endB == change.start + 1 &&
12467
+ if (ie$2 && ie_version <= 11 && change.endB == change.start + 1 &&
12468
12468
  change.endA == change.start && change.start > parse.from &&
12469
12469
  parse.doc.textBetween(change.start - parse.from - 1, change.start - parse.from + 1) == " \u00a0") {
12470
12470
  change.start--;
@@ -12528,7 +12528,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
12528
12528
  if (sel && !(chrome && view.composing && sel.empty &&
12529
12529
  (change.start != change.endB || view.input.lastChromeDelete < Date.now() - 100) &&
12530
12530
  (sel.head == chFrom || sel.head == tr.mapping.map(chTo) - 1) ||
12531
- ie$1 && sel.empty && sel.head == chFrom))
12531
+ ie$2 && sel.empty && sel.head == chFrom))
12532
12532
  tr.setSelection(sel);
12533
12533
  }
12534
12534
  if (compositionID)
@@ -12540,7 +12540,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
12540
12540
  if ($from.pos == $to.pos) { // Deletion
12541
12541
  // IE11 sometimes weirdly moves the DOM selection around after
12542
12542
  // backspacing out the first element in a textblock
12543
- if (ie$1 && ie_version <= 11 && $from.parentOffset == 0) {
12543
+ if (ie$2 && ie_version <= 11 && $from.parentOffset == 0) {
12544
12544
  view.domObserver.suppressSelectionUpdates();
12545
12545
  setTimeout(() => selectionToDOM(view), 20);
12546
12546
  }
@@ -12847,7 +12847,7 @@ class EditorView {
12847
12847
  // state where the thing the user sees differs from the
12848
12848
  // selection reported by the Selection object (#710, #973,
12849
12849
  // #1011, #1013, #1035).
12850
- let forceSelUpdate = updateDoc && (ie$1 || chrome) && !this.composing &&
12850
+ let forceSelUpdate = updateDoc && (ie$2 || chrome) && !this.composing &&
12851
12851
  !prev.selection.empty && !state.selection.empty && selectionContextChanged(prev.selection, state.selection);
12852
12852
  if (updateDoc) {
12853
12853
  // If the node that the selection points into is written to,
@@ -12975,7 +12975,7 @@ class EditorView {
12975
12975
  // Work around IE not handling focus correctly if resize handles are shown.
12976
12976
  // If the cursor is inside an element with resize handles, activeElement
12977
12977
  // will be that element instead of this.dom.
12978
- if (ie$1) {
12978
+ if (ie$2) {
12979
12979
  // If activeElement is within this.dom, and there are no other elements
12980
12980
  // setting `contenteditable` to false in between, treat it as focused.
12981
12981
  let node = this.root.activeElement;
@@ -13337,7 +13337,7 @@ var shift = {
13337
13337
  };
13338
13338
 
13339
13339
  var mac$1 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
13340
- var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
13340
+ var ie$1 = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
13341
13341
 
13342
13342
  // Fill in the digit keys
13343
13343
  for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);
@@ -13358,7 +13358,7 @@ function keyName(event) {
13358
13358
  // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.
13359
13359
  // On IE, shift effect is never included in `.key`.
13360
13360
  var ignoreKey = mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||
13361
- ie && event.shiftKey && event.key && event.key.length == 1 ||
13361
+ ie$1 && event.shiftKey && event.key && event.key.length == 1 ||
13362
13362
  event.key == "Unidentified";
13363
13363
  var name = (!ignoreKey && event.key) ||
13364
13364
  (event.shiftKey ? shift : base)[event.keyCode] ||
@@ -13989,6 +13989,11 @@ function isiOS() {
13989
13989
  navigator.userAgent.includes("Mac") && "ontouchend" in document;
13990
13990
  }
13991
13991
 
13992
+ // src/utilities/isSafari.ts
13993
+ function isSafari() {
13994
+ return typeof navigator !== "undefined" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
13995
+ }
13996
+
13992
13997
  // src/commands/focus.ts
13993
13998
  var focus = (position = null, options = {}) => ({ editor, view, tr, dispatch }) => {
13994
13999
  options = {
@@ -13999,6 +14004,9 @@ var focus = (position = null, options = {}) => ({ editor, view, tr, dispatch })
13999
14004
  if (isiOS() || isAndroid()) {
14000
14005
  view.dom.focus();
14001
14006
  }
14007
+ if (isSafari() && !isiOS() && !isAndroid()) {
14008
+ view.dom.focus({ preventScroll: true });
14009
+ }
14002
14010
  requestAnimationFrame(() => {
14003
14011
  if (!editor.isDestroyed) {
14004
14012
  view.focus();
@@ -14008,8 +14016,12 @@ var focus = (position = null, options = {}) => ({ editor, view, tr, dispatch })
14008
14016
  }
14009
14017
  });
14010
14018
  };
14011
- if (view.hasFocus() && position === null || position === false) {
14012
- return true;
14019
+ try {
14020
+ if (view.hasFocus() && position === null || position === false) {
14021
+ return true;
14022
+ }
14023
+ } catch {
14024
+ return false;
14013
14025
  }
14014
14026
  if (dispatch && position === null && !isTextSelection(editor.state.selection)) {
14015
14027
  delayedFocus();
@@ -14722,6 +14734,9 @@ function getAttributesFromExtensions(extensions) {
14722
14734
  keepOnSplit: true,
14723
14735
  isRequired: false
14724
14736
  };
14737
+ const nodeExtensionTypes = nodeExtensions.filter((ext) => ext.name !== "text").map((ext) => ext.name);
14738
+ const markExtensionTypes = markExtensions.map((ext) => ext.name);
14739
+ const allExtensionTypes = [...nodeExtensionTypes, ...markExtensionTypes];
14725
14740
  extensions.forEach((extension) => {
14726
14741
  const context = {
14727
14742
  name: extension.name,
@@ -14739,7 +14754,19 @@ function getAttributesFromExtensions(extensions) {
14739
14754
  }
14740
14755
  const globalAttributes = addGlobalAttributes();
14741
14756
  globalAttributes.forEach((globalAttribute) => {
14742
- globalAttribute.types.forEach((type) => {
14757
+ let resolvedTypes;
14758
+ if (Array.isArray(globalAttribute.types)) {
14759
+ resolvedTypes = globalAttribute.types;
14760
+ } else if (globalAttribute.types === "*") {
14761
+ resolvedTypes = allExtensionTypes;
14762
+ } else if (globalAttribute.types === "nodes") {
14763
+ resolvedTypes = nodeExtensionTypes;
14764
+ } else if (globalAttribute.types === "marks") {
14765
+ resolvedTypes = markExtensionTypes;
14766
+ } else {
14767
+ resolvedTypes = [];
14768
+ }
14769
+ resolvedTypes.forEach((type) => {
14743
14770
  Object.entries(globalAttribute.attributes).forEach(([name, attribute]) => {
14744
14771
  extensionAttributes.push({
14745
14772
  type,
@@ -15290,6 +15317,9 @@ function isMarkActive(state, typeOrName, attributes = {}) {
15290
15317
  const from = $from.pos;
15291
15318
  const to = $to.pos;
15292
15319
  state.doc.nodesBetween(from, to, (node, pos) => {
15320
+ if (type && node.inlineContent && !node.type.allowsMarkType(type)) {
15321
+ return false;
15322
+ }
15293
15323
  if (!node.isText && !node.marks.length) {
15294
15324
  return;
15295
15325
  }
@@ -16821,6 +16851,68 @@ var ExtensionManager = class {
16821
16851
  })
16822
16852
  );
16823
16853
  }
16854
+ /**
16855
+ * Get the composed dispatchTransaction function from all extensions.
16856
+ * @param baseDispatch The base dispatch function (e.g. from the editor or user props)
16857
+ * @returns A composed dispatch function
16858
+ */
16859
+ dispatchTransaction(baseDispatch) {
16860
+ const { editor } = this;
16861
+ const extensions = sortExtensions([...this.extensions].reverse());
16862
+ return extensions.reduceRight((next, extension) => {
16863
+ const context = {
16864
+ name: extension.name,
16865
+ options: extension.options,
16866
+ storage: this.editor.extensionStorage[extension.name],
16867
+ editor,
16868
+ type: getSchemaTypeByName(extension.name, this.schema)
16869
+ };
16870
+ const dispatchTransaction = getExtensionField(
16871
+ extension,
16872
+ "dispatchTransaction",
16873
+ context
16874
+ );
16875
+ if (!dispatchTransaction) {
16876
+ return next;
16877
+ }
16878
+ return (transaction) => {
16879
+ dispatchTransaction.call(context, { transaction, next });
16880
+ };
16881
+ }, baseDispatch);
16882
+ }
16883
+ /**
16884
+ * Get the composed transformPastedHTML function from all extensions.
16885
+ * @param baseTransform The base transform function (e.g. from the editor props)
16886
+ * @returns A composed transform function that chains all extension transforms
16887
+ */
16888
+ transformPastedHTML(baseTransform) {
16889
+ const { editor } = this;
16890
+ const extensions = sortExtensions([...this.extensions]);
16891
+ return extensions.reduce(
16892
+ (transform, extension) => {
16893
+ const context = {
16894
+ name: extension.name,
16895
+ options: extension.options,
16896
+ storage: this.editor.extensionStorage[extension.name],
16897
+ editor,
16898
+ type: getSchemaTypeByName(extension.name, this.schema)
16899
+ };
16900
+ const extensionTransform = getExtensionField(
16901
+ extension,
16902
+ "transformPastedHTML",
16903
+ context
16904
+ );
16905
+ if (!extensionTransform) {
16906
+ return transform;
16907
+ }
16908
+ return (html, view) => {
16909
+ const transformedHtml = transform(html, view);
16910
+ return extensionTransform.call(context, transformedHtml);
16911
+ };
16912
+ },
16913
+ baseTransform || ((html) => html)
16914
+ );
16915
+ }
16824
16916
  get markViews() {
16825
16917
  const { editor } = this;
16826
16918
  const { markExtensions } = splitExtensions(this.extensions);
@@ -17436,19 +17528,20 @@ var NodePos = class _NodePos {
17436
17528
  this.node.content.forEach((node, offset) => {
17437
17529
  const isBlock = node.isBlock && !node.isTextblock;
17438
17530
  const isNonTextAtom = node.isAtom && !node.isText;
17531
+ const isInline = node.isInline;
17439
17532
  const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1);
17440
17533
  if (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) {
17441
17534
  return;
17442
17535
  }
17443
17536
  const $pos = this.resolvedPos.doc.resolve(targetPos);
17444
- if (!isBlock && $pos.depth <= this.depth) {
17537
+ if (!isBlock && !isInline && $pos.depth <= this.depth) {
17445
17538
  return;
17446
17539
  }
17447
- const childNodePos = new _NodePos($pos, this.editor, isBlock, isBlock ? node : null);
17540
+ const childNodePos = new _NodePos($pos, this.editor, isBlock, isBlock || isInline ? node : null);
17448
17541
  if (isBlock) {
17449
17542
  childNodePos.actualDepth = this.depth + 1;
17450
17543
  }
17451
- children.push(new _NodePos($pos, this.editor, isBlock, isBlock ? node : null));
17544
+ children.push(childNodePos);
17452
17545
  });
17453
17546
  return children;
17454
17547
  }
@@ -17646,7 +17739,8 @@ var Editor = class extends EventEmitter {
17646
17739
  },
17647
17740
  onPaste: () => null,
17648
17741
  onDrop: () => null,
17649
- onDelete: () => null
17742
+ onDelete: () => null,
17743
+ enableExtensionDispatchTransaction: true
17650
17744
  };
17651
17745
  this.isCapturingTransaction = false;
17652
17746
  this.capturedTransaction = null;
@@ -17805,7 +17899,7 @@ var Editor = class extends EventEmitter {
17805
17899
  return this.options.editable && this.view && this.view.editable;
17806
17900
  }
17807
17901
  /**
17808
- * Returns the editor state.
17902
+ * Returns the editor view.
17809
17903
  */
17810
17904
  get view() {
17811
17905
  if (this.editorView) {
@@ -17970,15 +18064,20 @@ var Editor = class extends EventEmitter {
17970
18064
  * Creates a ProseMirror view.
17971
18065
  */
17972
18066
  createView(element) {
17973
- var _a;
18067
+ const { editorProps, enableExtensionDispatchTransaction } = this.options;
18068
+ const baseDispatch = editorProps.dispatchTransaction || this.dispatchTransaction.bind(this);
18069
+ const dispatch = enableExtensionDispatchTransaction ? this.extensionManager.dispatchTransaction(baseDispatch) : baseDispatch;
18070
+ const baseTransformPastedHTML = editorProps.transformPastedHTML;
18071
+ const transformPastedHTML = this.extensionManager.transformPastedHTML(baseTransformPastedHTML);
17974
18072
  this.editorView = new EditorView(element, {
17975
- ...this.options.editorProps,
18073
+ ...editorProps,
17976
18074
  attributes: {
17977
18075
  // add `role="textbox"` to the editor element
17978
18076
  role: "textbox",
17979
- ...(_a = this.options.editorProps) == null ? void 0 : _a.attributes
18077
+ ...editorProps == null ? void 0 : editorProps.attributes
17980
18078
  },
17981
- dispatchTransaction: this.dispatchTransaction.bind(this),
18079
+ dispatchTransaction: dispatch,
18080
+ transformPastedHTML,
17982
18081
  state: this.editorState,
17983
18082
  markViews: this.extensionManager.markViews,
17984
18083
  nodeViews: this.extensionManager.nodeViews
@@ -18466,7 +18565,8 @@ var ResizableNodeView = class {
18466
18565
  return this.container;
18467
18566
  }
18468
18567
  get contentDOM() {
18469
- return this.contentElement;
18568
+ var _a;
18569
+ return (_a = this.contentElement) != null ? _a : null;
18470
18570
  }
18471
18571
  handleEditorUpdate() {
18472
18572
  const isEditable = this.editor.isEditable;
@@ -19358,2271 +19458,184 @@ function renderNestedMarkdownContent(node, h2, prefixOrGenerator, ctx) {
19358
19458
  children.forEach((child) => {
19359
19459
  const childContent = h2.renderChildren([child]);
19360
19460
  if (childContent) {
19361
- const indentedChild = childContent.split("\n").map((line) => line ? h2.indent(line) : "").join("\n");
19362
- output.push(indentedChild);
19363
- }
19364
- });
19365
- }
19366
- return output.join("\n");
19367
- }
19368
-
19369
- // src/MarkView.ts
19370
- function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
19371
- const { state } = editor;
19372
- const { doc, tr } = state;
19373
- const thisMark = checkMark;
19374
- doc.descendants((node, pos) => {
19375
- const from = tr.mapping.map(pos);
19376
- const to = tr.mapping.map(pos) + node.nodeSize;
19377
- let foundMark = null;
19378
- node.marks.forEach((mark) => {
19379
- if (mark !== thisMark) {
19380
- return false;
19381
- }
19382
- foundMark = mark;
19383
- });
19384
- if (!foundMark) {
19385
- return;
19386
- }
19387
- let needsUpdate = false;
19388
- Object.keys(attrs).forEach((k) => {
19389
- if (attrs[k] !== foundMark.attrs[k]) {
19390
- needsUpdate = true;
19391
- }
19392
- });
19393
- if (needsUpdate) {
19394
- const updatedMark = checkMark.type.create({
19395
- ...checkMark.attrs,
19396
- ...attrs
19397
- });
19398
- tr.removeMark(from, to, checkMark.type);
19399
- tr.addMark(from, to, updatedMark);
19400
- }
19401
- });
19402
- if (tr.docChanged) {
19403
- editor.view.dispatch(tr);
19404
- }
19405
- }
19406
-
19407
- // src/Node.ts
19408
- var Node3 = class _Node extends Extendable {
19409
- constructor() {
19410
- super(...arguments);
19411
- this.type = "node";
19412
- }
19413
- /**
19414
- * Create a new Node instance
19415
- * @param config - Node configuration object or a function that returns a configuration object
19416
- */
19417
- static create(config = {}) {
19418
- const resolvedConfig = typeof config === "function" ? config() : config;
19419
- return new _Node(resolvedConfig);
19420
- }
19421
- configure(options) {
19422
- return super.configure(options);
19423
- }
19424
- extend(extendedConfig) {
19425
- const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
19426
- return super.extend(resolvedConfig);
19427
- }
19428
- };
19429
-
19430
- // src/pasteRules/markPasteRule.ts
19431
- function markPasteRule(config) {
19432
- return new PasteRule({
19433
- find: config.find,
19434
- handler: ({ state, range, match, pasteEvent }) => {
19435
- const attributes = callOrReturn(config.getAttributes, void 0, match, pasteEvent);
19436
- if (attributes === false || attributes === null) {
19437
- return null;
19438
- }
19439
- const { tr } = state;
19440
- const captureGroup = match[match.length - 1];
19441
- const fullMatch = match[0];
19442
- let markEnd = range.to;
19443
- if (captureGroup) {
19444
- const startSpaces = fullMatch.search(/\S/);
19445
- const textStart = range.from + fullMatch.indexOf(captureGroup);
19446
- const textEnd = textStart + captureGroup.length;
19447
- const excludedMarks = getMarksBetween(range.from, range.to, state.doc).filter((item) => {
19448
- const excluded = item.mark.type.excluded;
19449
- return excluded.find((type) => type === config.type && type !== item.mark.type);
19450
- }).filter((item) => item.to > textStart);
19451
- if (excludedMarks.length) {
19452
- return null;
19453
- }
19454
- if (textEnd < range.to) {
19455
- tr.delete(textEnd, range.to);
19456
- }
19457
- if (textStart > range.from) {
19458
- tr.delete(range.from + startSpaces, textStart);
19459
- }
19460
- markEnd = range.from + startSpaces + captureGroup.length;
19461
- tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
19462
- tr.removeStoredMark(config.type);
19463
- }
19464
- }
19465
- });
19466
- }
19467
-
19468
- /**
19469
- * marked v15.0.12 - a markdown parser
19470
- * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
19471
- * https://github.com/markedjs/marked
19472
- */
19473
-
19474
- /**
19475
- * DO NOT EDIT THIS FILE
19476
- * The code in this file is generated from files in ./src/
19477
- */
19478
-
19479
-
19480
- // src/defaults.ts
19481
- function _getDefaults() {
19482
- return {
19483
- async: false,
19484
- breaks: false,
19485
- extensions: null,
19486
- gfm: true,
19487
- hooks: null,
19488
- pedantic: false,
19489
- renderer: null,
19490
- silent: false,
19491
- tokenizer: null,
19492
- walkTokens: null
19493
- };
19494
- }
19495
- var _defaults = _getDefaults();
19496
- function changeDefaults(newDefaults) {
19497
- _defaults = newDefaults;
19498
- }
19499
-
19500
- // src/rules.ts
19501
- var noopTest = { exec: () => null };
19502
- function edit(regex, opt = "") {
19503
- let source = typeof regex === "string" ? regex : regex.source;
19504
- const obj = {
19505
- replace: (name, val) => {
19506
- let valSource = typeof val === "string" ? val : val.source;
19507
- valSource = valSource.replace(other.caret, "$1");
19508
- source = source.replace(name, valSource);
19509
- return obj;
19510
- },
19511
- getRegex: () => {
19512
- return new RegExp(source, opt);
19513
- }
19514
- };
19515
- return obj;
19516
- }
19517
- var other = {
19518
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
19519
- outputLinkReplace: /\\([\[\]])/g,
19520
- indentCodeCompensation: /^(\s+)(?:```)/,
19521
- beginningSpace: /^\s+/,
19522
- endingHash: /#$/,
19523
- startingSpaceChar: /^ /,
19524
- endingSpaceChar: / $/,
19525
- nonSpaceChar: /[^ ]/,
19526
- newLineCharGlobal: /\n/g,
19527
- tabCharGlobal: /\t/g,
19528
- multipleSpaceGlobal: /\s+/g,
19529
- blankLine: /^[ \t]*$/,
19530
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
19531
- blockquoteStart: /^ {0,3}>/,
19532
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
19533
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
19534
- listReplaceTabs: /^\t+/,
19535
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
19536
- listIsTask: /^\[[ xX]\] /,
19537
- listReplaceTask: /^\[[ xX]\] +/,
19538
- anyLine: /\n.*\n/,
19539
- hrefBrackets: /^<(.*)>$/,
19540
- tableDelimiter: /[:|]/,
19541
- tableAlignChars: /^\||\| *$/g,
19542
- tableRowBlankLine: /\n[ \t]*$/,
19543
- tableAlignRight: /^ *-+: *$/,
19544
- tableAlignCenter: /^ *:-+: *$/,
19545
- tableAlignLeft: /^ *:-+ *$/,
19546
- startATag: /^<a /i,
19547
- endATag: /^<\/a>/i,
19548
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
19549
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
19550
- startAngleBracket: /^</,
19551
- endAngleBracket: />$/,
19552
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
19553
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
19554
- escapeTest: /[&<>"']/,
19555
- escapeReplace: /[&<>"']/g,
19556
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
19557
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
19558
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
19559
- caret: /(^|[^\[])\^/g,
19560
- percentDecode: /%25/g,
19561
- findPipe: /\|/g,
19562
- splitPipe: / \|/,
19563
- slashPipe: /\\\|/g,
19564
- carriageReturn: /\r\n|\r/g,
19565
- spaceLine: /^ +$/gm,
19566
- notSpaceStart: /^\S*/,
19567
- endingNewline: /\n$/,
19568
- listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`),
19569
- nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
19570
- hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
19571
- fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
19572
- headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
19573
- htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i")
19574
- };
19575
- var newline = /^(?:[ \t]*(?:\n|$))+/;
19576
- var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
19577
- var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
19578
- var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
19579
- var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
19580
- var bullet = /(?:[*+-]|\d{1,9}[.)])/;
19581
- var lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
19582
- var lheading = edit(lheadingCore).replace(/bull/g, bullet).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();
19583
- var lheadingGfm = edit(lheadingCore).replace(/bull/g, bullet).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();
19584
- var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
19585
- var blockText = /^[^\n]+/;
19586
- var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
19587
- var def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
19588
- var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
19589
- var _tag = "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";
19590
- var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
19591
- var html = edit(
19592
- "^ {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|$))",
19593
- "i"
19594
- ).replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
19595
- var paragraph = edit(_paragraph).replace("hr", hr).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[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
19596
- var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
19597
- var blockNormal = {
19598
- blockquote,
19599
- code: blockCode,
19600
- def,
19601
- fences,
19602
- heading,
19603
- hr,
19604
- html,
19605
- lheading,
19606
- list,
19607
- newline,
19608
- paragraph,
19609
- table: noopTest,
19610
- text: blockText
19611
- };
19612
- var gfmTable = edit(
19613
- "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
19614
- ).replace("hr", hr).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[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
19615
- var blockGfm = {
19616
- ...blockNormal,
19617
- lheading: lheadingGfm,
19618
- table: gfmTable,
19619
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
19620
- };
19621
- var blockPedantic = {
19622
- ...blockNormal,
19623
- html: edit(
19624
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
19625
- ).replace("comment", _comment).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(),
19626
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
19627
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
19628
- fences: noopTest,
19629
- // fences not supported
19630
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
19631
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
19632
- };
19633
- var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
19634
- var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
19635
- var br = /^( {2,}|\\)\n(?!\s*$)/;
19636
- var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
19637
- var _punctuation = /[\p{P}\p{S}]/u;
19638
- var _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
19639
- var _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
19640
- var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
19641
- var _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
19642
- var _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
19643
- var _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
19644
- var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
19645
- var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
19646
- var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
19647
- var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
19648
- var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
19649
- var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
19650
- var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
19651
- var emStrongRDelimUnd = edit(
19652
- "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
19653
- "gu"
19654
- ).replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
19655
- var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
19656
- var autolink$1 = edit(/^<(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();
19657
- var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
19658
- var tag = edit(
19659
- "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
19660
- ).replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
19661
- var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
19662
- var link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
19663
- var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
19664
- var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
19665
- var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
19666
- var inlineNormal = {
19667
- _backpedal: noopTest,
19668
- // only used for GFM url
19669
- anyPunctuation,
19670
- autolink: autolink$1,
19671
- blockSkip,
19672
- br,
19673
- code: inlineCode,
19674
- del: noopTest,
19675
- emStrongLDelim,
19676
- emStrongRDelimAst,
19677
- emStrongRDelimUnd,
19678
- escape,
19679
- link,
19680
- nolink,
19681
- punctuation,
19682
- reflink,
19683
- reflinkSearch,
19684
- tag,
19685
- text: inlineText,
19686
- url: noopTest
19687
- };
19688
- var inlinePedantic = {
19689
- ...inlineNormal,
19690
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
19691
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
19692
- };
19693
- var inlineGfm = {
19694
- ...inlineNormal,
19695
- emStrongRDelimAst: emStrongRDelimAstGfm,
19696
- emStrongLDelim: emStrongLDelimGfm,
19697
- url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
19698
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
19699
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
19700
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
19701
- };
19702
- var inlineBreaks = {
19703
- ...inlineGfm,
19704
- br: edit(br).replace("{2,}", "*").getRegex(),
19705
- text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
19706
- };
19707
- var block = {
19708
- normal: blockNormal,
19709
- gfm: blockGfm,
19710
- pedantic: blockPedantic
19711
- };
19712
- var inline = {
19713
- normal: inlineNormal,
19714
- gfm: inlineGfm,
19715
- breaks: inlineBreaks,
19716
- pedantic: inlinePedantic
19717
- };
19718
-
19719
- // src/helpers.ts
19720
- var escapeReplacements = {
19721
- "&": "&amp;",
19722
- "<": "&lt;",
19723
- ">": "&gt;",
19724
- '"': "&quot;",
19725
- "'": "&#39;"
19726
- };
19727
- var getEscapeReplacement = (ch) => escapeReplacements[ch];
19728
- function escape2(html2, encode) {
19729
- if (encode) {
19730
- if (other.escapeTest.test(html2)) {
19731
- return html2.replace(other.escapeReplace, getEscapeReplacement);
19732
- }
19733
- } else {
19734
- if (other.escapeTestNoEncode.test(html2)) {
19735
- return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
19736
- }
19737
- }
19738
- return html2;
19739
- }
19740
- function cleanUrl(href) {
19741
- try {
19742
- href = encodeURI(href).replace(other.percentDecode, "%");
19743
- } catch {
19744
- return null;
19745
- }
19746
- return href;
19747
- }
19748
- function splitCells(tableRow, count) {
19749
- const row = tableRow.replace(other.findPipe, (match, offset, str) => {
19750
- let escaped = false;
19751
- let curr = offset;
19752
- while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
19753
- if (escaped) {
19754
- return "|";
19755
- } else {
19756
- return " |";
19757
- }
19758
- }), cells = row.split(other.splitPipe);
19759
- let i = 0;
19760
- if (!cells[0].trim()) {
19761
- cells.shift();
19762
- }
19763
- if (cells.length > 0 && !cells.at(-1)?.trim()) {
19764
- cells.pop();
19765
- }
19766
- if (count) {
19767
- if (cells.length > count) {
19768
- cells.splice(count);
19769
- } else {
19770
- while (cells.length < count) cells.push("");
19771
- }
19772
- }
19773
- for (; i < cells.length; i++) {
19774
- cells[i] = cells[i].trim().replace(other.slashPipe, "|");
19775
- }
19776
- return cells;
19777
- }
19778
- function rtrim(str, c, invert) {
19779
- const l = str.length;
19780
- if (l === 0) {
19781
- return "";
19782
- }
19783
- let suffLen = 0;
19784
- while (suffLen < l) {
19785
- const currChar = str.charAt(l - suffLen - 1);
19786
- if (currChar === c && true) {
19787
- suffLen++;
19788
- } else {
19789
- break;
19790
- }
19791
- }
19792
- return str.slice(0, l - suffLen);
19793
- }
19794
- function findClosingBracket(str, b) {
19795
- if (str.indexOf(b[1]) === -1) {
19796
- return -1;
19797
- }
19798
- let level = 0;
19799
- for (let i = 0; i < str.length; i++) {
19800
- if (str[i] === "\\") {
19801
- i++;
19802
- } else if (str[i] === b[0]) {
19803
- level++;
19804
- } else if (str[i] === b[1]) {
19805
- level--;
19806
- if (level < 0) {
19807
- return i;
19808
- }
19809
- }
19810
- }
19811
- if (level > 0) {
19812
- return -2;
19813
- }
19814
- return -1;
19815
- }
19816
-
19817
- // src/Tokenizer.ts
19818
- function outputLink(cap, link2, raw, lexer2, rules) {
19819
- const href = link2.href;
19820
- const title = link2.title || null;
19821
- const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
19822
- lexer2.state.inLink = true;
19823
- const token = {
19824
- type: cap[0].charAt(0) === "!" ? "image" : "link",
19825
- raw,
19826
- href,
19827
- title,
19828
- text,
19829
- tokens: lexer2.inlineTokens(text)
19830
- };
19831
- lexer2.state.inLink = false;
19832
- return token;
19833
- }
19834
- function indentCodeCompensation(raw, text, rules) {
19835
- const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
19836
- if (matchIndentToCode === null) {
19837
- return text;
19838
- }
19839
- const indentToCode = matchIndentToCode[1];
19840
- return text.split("\n").map((node) => {
19841
- const matchIndentInNode = node.match(rules.other.beginningSpace);
19842
- if (matchIndentInNode === null) {
19843
- return node;
19844
- }
19845
- const [indentInNode] = matchIndentInNode;
19846
- if (indentInNode.length >= indentToCode.length) {
19847
- return node.slice(indentToCode.length);
19848
- }
19849
- return node;
19850
- }).join("\n");
19851
- }
19852
- var _Tokenizer = class {
19853
- options;
19854
- rules;
19855
- // set by the lexer
19856
- lexer;
19857
- // set by the lexer
19858
- constructor(options2) {
19859
- this.options = options2 || _defaults;
19860
- }
19861
- space(src) {
19862
- const cap = this.rules.block.newline.exec(src);
19863
- if (cap && cap[0].length > 0) {
19864
- return {
19865
- type: "space",
19866
- raw: cap[0]
19867
- };
19868
- }
19869
- }
19870
- code(src) {
19871
- const cap = this.rules.block.code.exec(src);
19872
- if (cap) {
19873
- const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
19874
- return {
19875
- type: "code",
19876
- raw: cap[0],
19877
- codeBlockStyle: "indented",
19878
- text: !this.options.pedantic ? rtrim(text, "\n") : text
19879
- };
19880
- }
19881
- }
19882
- fences(src) {
19883
- const cap = this.rules.block.fences.exec(src);
19884
- if (cap) {
19885
- const raw = cap[0];
19886
- const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
19887
- return {
19888
- type: "code",
19889
- raw,
19890
- lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
19891
- text
19892
- };
19893
- }
19894
- }
19895
- heading(src) {
19896
- const cap = this.rules.block.heading.exec(src);
19897
- if (cap) {
19898
- let text = cap[2].trim();
19899
- if (this.rules.other.endingHash.test(text)) {
19900
- const trimmed = rtrim(text, "#");
19901
- if (this.options.pedantic) {
19902
- text = trimmed.trim();
19903
- } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
19904
- text = trimmed.trim();
19905
- }
19906
- }
19907
- return {
19908
- type: "heading",
19909
- raw: cap[0],
19910
- depth: cap[1].length,
19911
- text,
19912
- tokens: this.lexer.inline(text)
19913
- };
19914
- }
19915
- }
19916
- hr(src) {
19917
- const cap = this.rules.block.hr.exec(src);
19918
- if (cap) {
19919
- return {
19920
- type: "hr",
19921
- raw: rtrim(cap[0], "\n")
19922
- };
19923
- }
19924
- }
19925
- blockquote(src) {
19926
- const cap = this.rules.block.blockquote.exec(src);
19927
- if (cap) {
19928
- let lines = rtrim(cap[0], "\n").split("\n");
19929
- let raw = "";
19930
- let text = "";
19931
- const tokens = [];
19932
- while (lines.length > 0) {
19933
- let inBlockquote = false;
19934
- const currentLines = [];
19935
- let i;
19936
- for (i = 0; i < lines.length; i++) {
19937
- if (this.rules.other.blockquoteStart.test(lines[i])) {
19938
- currentLines.push(lines[i]);
19939
- inBlockquote = true;
19940
- } else if (!inBlockquote) {
19941
- currentLines.push(lines[i]);
19942
- } else {
19943
- break;
19944
- }
19945
- }
19946
- lines = lines.slice(i);
19947
- const currentRaw = currentLines.join("\n");
19948
- const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
19949
- raw = raw ? `${raw}
19950
- ${currentRaw}` : currentRaw;
19951
- text = text ? `${text}
19952
- ${currentText}` : currentText;
19953
- const top = this.lexer.state.top;
19954
- this.lexer.state.top = true;
19955
- this.lexer.blockTokens(currentText, tokens, true);
19956
- this.lexer.state.top = top;
19957
- if (lines.length === 0) {
19958
- break;
19959
- }
19960
- const lastToken = tokens.at(-1);
19961
- if (lastToken?.type === "code") {
19962
- break;
19963
- } else if (lastToken?.type === "blockquote") {
19964
- const oldToken = lastToken;
19965
- const newText = oldToken.raw + "\n" + lines.join("\n");
19966
- const newToken = this.blockquote(newText);
19967
- tokens[tokens.length - 1] = newToken;
19968
- raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
19969
- text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
19970
- break;
19971
- } else if (lastToken?.type === "list") {
19972
- const oldToken = lastToken;
19973
- const newText = oldToken.raw + "\n" + lines.join("\n");
19974
- const newToken = this.list(newText);
19975
- tokens[tokens.length - 1] = newToken;
19976
- raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
19977
- text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
19978
- lines = newText.substring(tokens.at(-1).raw.length).split("\n");
19979
- continue;
19980
- }
19981
- }
19982
- return {
19983
- type: "blockquote",
19984
- raw,
19985
- tokens,
19986
- text
19987
- };
19988
- }
19989
- }
19990
- list(src) {
19991
- let cap = this.rules.block.list.exec(src);
19992
- if (cap) {
19993
- let bull = cap[1].trim();
19994
- const isordered = bull.length > 1;
19995
- const list2 = {
19996
- type: "list",
19997
- raw: "",
19998
- ordered: isordered,
19999
- start: isordered ? +bull.slice(0, -1) : "",
20000
- loose: false,
20001
- items: []
20002
- };
20003
- bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
20004
- if (this.options.pedantic) {
20005
- bull = isordered ? bull : "[*+-]";
20006
- }
20007
- const itemRegex = this.rules.other.listItemRegex(bull);
20008
- let endsWithBlankLine = false;
20009
- while (src) {
20010
- let endEarly = false;
20011
- let raw = "";
20012
- let itemContents = "";
20013
- if (!(cap = itemRegex.exec(src))) {
20014
- break;
20015
- }
20016
- if (this.rules.block.hr.test(src)) {
20017
- break;
20018
- }
20019
- raw = cap[0];
20020
- src = src.substring(raw.length);
20021
- let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => " ".repeat(3 * t.length));
20022
- let nextLine = src.split("\n", 1)[0];
20023
- let blankLine = !line.trim();
20024
- let indent = 0;
20025
- if (this.options.pedantic) {
20026
- indent = 2;
20027
- itemContents = line.trimStart();
20028
- } else if (blankLine) {
20029
- indent = cap[1].length + 1;
20030
- } else {
20031
- indent = cap[2].search(this.rules.other.nonSpaceChar);
20032
- indent = indent > 4 ? 1 : indent;
20033
- itemContents = line.slice(indent);
20034
- indent += cap[1].length;
20035
- }
20036
- if (blankLine && this.rules.other.blankLine.test(nextLine)) {
20037
- raw += nextLine + "\n";
20038
- src = src.substring(nextLine.length + 1);
20039
- endEarly = true;
20040
- }
20041
- if (!endEarly) {
20042
- const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
20043
- const hrRegex = this.rules.other.hrRegex(indent);
20044
- const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
20045
- const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
20046
- const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
20047
- while (src) {
20048
- const rawLine = src.split("\n", 1)[0];
20049
- let nextLineWithoutTabs;
20050
- nextLine = rawLine;
20051
- if (this.options.pedantic) {
20052
- nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
20053
- nextLineWithoutTabs = nextLine;
20054
- } else {
20055
- nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
20056
- }
20057
- if (fencesBeginRegex.test(nextLine)) {
20058
- break;
20059
- }
20060
- if (headingBeginRegex.test(nextLine)) {
20061
- break;
20062
- }
20063
- if (htmlBeginRegex.test(nextLine)) {
20064
- break;
20065
- }
20066
- if (nextBulletRegex.test(nextLine)) {
20067
- break;
20068
- }
20069
- if (hrRegex.test(nextLine)) {
20070
- break;
20071
- }
20072
- if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
20073
- itemContents += "\n" + nextLineWithoutTabs.slice(indent);
20074
- } else {
20075
- if (blankLine) {
20076
- break;
20077
- }
20078
- if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) {
20079
- break;
20080
- }
20081
- if (fencesBeginRegex.test(line)) {
20082
- break;
20083
- }
20084
- if (headingBeginRegex.test(line)) {
20085
- break;
20086
- }
20087
- if (hrRegex.test(line)) {
20088
- break;
20089
- }
20090
- itemContents += "\n" + nextLine;
20091
- }
20092
- if (!blankLine && !nextLine.trim()) {
20093
- blankLine = true;
20094
- }
20095
- raw += rawLine + "\n";
20096
- src = src.substring(rawLine.length + 1);
20097
- line = nextLineWithoutTabs.slice(indent);
20098
- }
20099
- }
20100
- if (!list2.loose) {
20101
- if (endsWithBlankLine) {
20102
- list2.loose = true;
20103
- } else if (this.rules.other.doubleBlankLine.test(raw)) {
20104
- endsWithBlankLine = true;
20105
- }
20106
- }
20107
- let istask = null;
20108
- let ischecked;
20109
- if (this.options.gfm) {
20110
- istask = this.rules.other.listIsTask.exec(itemContents);
20111
- if (istask) {
20112
- ischecked = istask[0] !== "[ ] ";
20113
- itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
20114
- }
20115
- }
20116
- list2.items.push({
20117
- type: "list_item",
20118
- raw,
20119
- task: !!istask,
20120
- checked: ischecked,
20121
- loose: false,
20122
- text: itemContents,
20123
- tokens: []
20124
- });
20125
- list2.raw += raw;
20126
- }
20127
- const lastItem = list2.items.at(-1);
20128
- if (lastItem) {
20129
- lastItem.raw = lastItem.raw.trimEnd();
20130
- lastItem.text = lastItem.text.trimEnd();
20131
- } else {
20132
- return;
20133
- }
20134
- list2.raw = list2.raw.trimEnd();
20135
- for (let i = 0; i < list2.items.length; i++) {
20136
- this.lexer.state.top = false;
20137
- list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
20138
- if (!list2.loose) {
20139
- const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
20140
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));
20141
- list2.loose = hasMultipleLineBreaks;
20142
- }
20143
- }
20144
- if (list2.loose) {
20145
- for (let i = 0; i < list2.items.length; i++) {
20146
- list2.items[i].loose = true;
20147
- }
20148
- }
20149
- return list2;
20150
- }
20151
- }
20152
- html(src) {
20153
- const cap = this.rules.block.html.exec(src);
20154
- if (cap) {
20155
- const token = {
20156
- type: "html",
20157
- block: true,
20158
- raw: cap[0],
20159
- pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
20160
- text: cap[0]
20161
- };
20162
- return token;
20163
- }
20164
- }
20165
- def(src) {
20166
- const cap = this.rules.block.def.exec(src);
20167
- if (cap) {
20168
- const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
20169
- const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
20170
- const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
20171
- return {
20172
- type: "def",
20173
- tag: tag2,
20174
- raw: cap[0],
20175
- href,
20176
- title
20177
- };
20178
- }
20179
- }
20180
- table(src) {
20181
- const cap = this.rules.block.table.exec(src);
20182
- if (!cap) {
20183
- return;
20184
- }
20185
- if (!this.rules.other.tableDelimiter.test(cap[2])) {
20186
- return;
20187
- }
20188
- const headers = splitCells(cap[1]);
20189
- const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
20190
- const rows = cap[3]?.trim() ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
20191
- const item = {
20192
- type: "table",
20193
- raw: cap[0],
20194
- header: [],
20195
- align: [],
20196
- rows: []
20197
- };
20198
- if (headers.length !== aligns.length) {
20199
- return;
20200
- }
20201
- for (const align of aligns) {
20202
- if (this.rules.other.tableAlignRight.test(align)) {
20203
- item.align.push("right");
20204
- } else if (this.rules.other.tableAlignCenter.test(align)) {
20205
- item.align.push("center");
20206
- } else if (this.rules.other.tableAlignLeft.test(align)) {
20207
- item.align.push("left");
20208
- } else {
20209
- item.align.push(null);
20210
- }
20211
- }
20212
- for (let i = 0; i < headers.length; i++) {
20213
- item.header.push({
20214
- text: headers[i],
20215
- tokens: this.lexer.inline(headers[i]),
20216
- header: true,
20217
- align: item.align[i]
20218
- });
20219
- }
20220
- for (const row of rows) {
20221
- item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
20222
- return {
20223
- text: cell,
20224
- tokens: this.lexer.inline(cell),
20225
- header: false,
20226
- align: item.align[i]
20227
- };
20228
- }));
20229
- }
20230
- return item;
20231
- }
20232
- lheading(src) {
20233
- const cap = this.rules.block.lheading.exec(src);
20234
- if (cap) {
20235
- return {
20236
- type: "heading",
20237
- raw: cap[0],
20238
- depth: cap[2].charAt(0) === "=" ? 1 : 2,
20239
- text: cap[1],
20240
- tokens: this.lexer.inline(cap[1])
20241
- };
20242
- }
20243
- }
20244
- paragraph(src) {
20245
- const cap = this.rules.block.paragraph.exec(src);
20246
- if (cap) {
20247
- const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
20248
- return {
20249
- type: "paragraph",
20250
- raw: cap[0],
20251
- text,
20252
- tokens: this.lexer.inline(text)
20253
- };
20254
- }
20255
- }
20256
- text(src) {
20257
- const cap = this.rules.block.text.exec(src);
20258
- if (cap) {
20259
- return {
20260
- type: "text",
20261
- raw: cap[0],
20262
- text: cap[0],
20263
- tokens: this.lexer.inline(cap[0])
20264
- };
20265
- }
20266
- }
20267
- escape(src) {
20268
- const cap = this.rules.inline.escape.exec(src);
20269
- if (cap) {
20270
- return {
20271
- type: "escape",
20272
- raw: cap[0],
20273
- text: cap[1]
20274
- };
20275
- }
20276
- }
20277
- tag(src) {
20278
- const cap = this.rules.inline.tag.exec(src);
20279
- if (cap) {
20280
- if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
20281
- this.lexer.state.inLink = true;
20282
- } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
20283
- this.lexer.state.inLink = false;
20284
- }
20285
- if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
20286
- this.lexer.state.inRawBlock = true;
20287
- } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
20288
- this.lexer.state.inRawBlock = false;
20289
- }
20290
- return {
20291
- type: "html",
20292
- raw: cap[0],
20293
- inLink: this.lexer.state.inLink,
20294
- inRawBlock: this.lexer.state.inRawBlock,
20295
- block: false,
20296
- text: cap[0]
20297
- };
20298
- }
20299
- }
20300
- link(src) {
20301
- const cap = this.rules.inline.link.exec(src);
20302
- if (cap) {
20303
- const trimmedUrl = cap[2].trim();
20304
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
20305
- if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
20306
- return;
20307
- }
20308
- const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
20309
- if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
20310
- return;
20311
- }
20312
- } else {
20313
- const lastParenIndex = findClosingBracket(cap[2], "()");
20314
- if (lastParenIndex === -2) {
20315
- return;
20316
- }
20317
- if (lastParenIndex > -1) {
20318
- const start = cap[0].indexOf("!") === 0 ? 5 : 4;
20319
- const linkLen = start + cap[1].length + lastParenIndex;
20320
- cap[2] = cap[2].substring(0, lastParenIndex);
20321
- cap[0] = cap[0].substring(0, linkLen).trim();
20322
- cap[3] = "";
20323
- }
20324
- }
20325
- let href = cap[2];
20326
- let title = "";
20327
- if (this.options.pedantic) {
20328
- const link2 = this.rules.other.pedanticHrefTitle.exec(href);
20329
- if (link2) {
20330
- href = link2[1];
20331
- title = link2[3];
20332
- }
20333
- } else {
20334
- title = cap[3] ? cap[3].slice(1, -1) : "";
20335
- }
20336
- href = href.trim();
20337
- if (this.rules.other.startAngleBracket.test(href)) {
20338
- if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
20339
- href = href.slice(1);
20340
- } else {
20341
- href = href.slice(1, -1);
20342
- }
20343
- }
20344
- return outputLink(cap, {
20345
- href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
20346
- title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
20347
- }, cap[0], this.lexer, this.rules);
20348
- }
20349
- }
20350
- reflink(src, links) {
20351
- let cap;
20352
- if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
20353
- const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
20354
- const link2 = links[linkString.toLowerCase()];
20355
- if (!link2) {
20356
- const text = cap[0].charAt(0);
20357
- return {
20358
- type: "text",
20359
- raw: text,
20360
- text
20361
- };
20362
- }
20363
- return outputLink(cap, link2, cap[0], this.lexer, this.rules);
20364
- }
20365
- }
20366
- emStrong(src, maskedSrc, prevChar = "") {
20367
- let match = this.rules.inline.emStrongLDelim.exec(src);
20368
- if (!match) return;
20369
- if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;
20370
- const nextChar = match[1] || match[2] || "";
20371
- if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
20372
- const lLength = [...match[0]].length - 1;
20373
- let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
20374
- const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
20375
- endReg.lastIndex = 0;
20376
- maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
20377
- while ((match = endReg.exec(maskedSrc)) != null) {
20378
- rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
20379
- if (!rDelim) continue;
20380
- rLength = [...rDelim].length;
20381
- if (match[3] || match[4]) {
20382
- delimTotal += rLength;
20383
- continue;
20384
- } else if (match[5] || match[6]) {
20385
- if (lLength % 3 && !((lLength + rLength) % 3)) {
20386
- midDelimTotal += rLength;
20387
- continue;
20388
- }
20389
- }
20390
- delimTotal -= rLength;
20391
- if (delimTotal > 0) continue;
20392
- rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
20393
- const lastCharLength = [...match[0]][0].length;
20394
- const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
20395
- if (Math.min(lLength, rLength) % 2) {
20396
- const text2 = raw.slice(1, -1);
20397
- return {
20398
- type: "em",
20399
- raw,
20400
- text: text2,
20401
- tokens: this.lexer.inlineTokens(text2)
20402
- };
20403
- }
20404
- const text = raw.slice(2, -2);
20405
- return {
20406
- type: "strong",
20407
- raw,
20408
- text,
20409
- tokens: this.lexer.inlineTokens(text)
20410
- };
20411
- }
20412
- }
20413
- }
20414
- codespan(src) {
20415
- const cap = this.rules.inline.code.exec(src);
20416
- if (cap) {
20417
- let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
20418
- const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
20419
- const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
20420
- if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
20421
- text = text.substring(1, text.length - 1);
20422
- }
20423
- return {
20424
- type: "codespan",
20425
- raw: cap[0],
20426
- text
20427
- };
20428
- }
20429
- }
20430
- br(src) {
20431
- const cap = this.rules.inline.br.exec(src);
20432
- if (cap) {
20433
- return {
20434
- type: "br",
20435
- raw: cap[0]
20436
- };
20437
- }
20438
- }
20439
- del(src) {
20440
- const cap = this.rules.inline.del.exec(src);
20441
- if (cap) {
20442
- return {
20443
- type: "del",
20444
- raw: cap[0],
20445
- text: cap[2],
20446
- tokens: this.lexer.inlineTokens(cap[2])
20447
- };
20448
- }
20449
- }
20450
- autolink(src) {
20451
- const cap = this.rules.inline.autolink.exec(src);
20452
- if (cap) {
20453
- let text, href;
20454
- if (cap[2] === "@") {
20455
- text = cap[1];
20456
- href = "mailto:" + text;
20457
- } else {
20458
- text = cap[1];
20459
- href = text;
20460
- }
20461
- return {
20462
- type: "link",
20463
- raw: cap[0],
20464
- text,
20465
- href,
20466
- tokens: [
20467
- {
20468
- type: "text",
20469
- raw: text,
20470
- text
20471
- }
20472
- ]
20473
- };
20474
- }
20475
- }
20476
- url(src) {
20477
- let cap;
20478
- if (cap = this.rules.inline.url.exec(src)) {
20479
- let text, href;
20480
- if (cap[2] === "@") {
20481
- text = cap[0];
20482
- href = "mailto:" + text;
20483
- } else {
20484
- let prevCapZero;
20485
- do {
20486
- prevCapZero = cap[0];
20487
- cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
20488
- } while (prevCapZero !== cap[0]);
20489
- text = cap[0];
20490
- if (cap[1] === "www.") {
20491
- href = "http://" + cap[0];
20492
- } else {
20493
- href = cap[0];
20494
- }
20495
- }
20496
- return {
20497
- type: "link",
20498
- raw: cap[0],
20499
- text,
20500
- href,
20501
- tokens: [
20502
- {
20503
- type: "text",
20504
- raw: text,
20505
- text
20506
- }
20507
- ]
20508
- };
20509
- }
20510
- }
20511
- inlineText(src) {
20512
- const cap = this.rules.inline.text.exec(src);
20513
- if (cap) {
20514
- const escaped = this.lexer.state.inRawBlock;
20515
- return {
20516
- type: "text",
20517
- raw: cap[0],
20518
- text: cap[0],
20519
- escaped
20520
- };
20521
- }
20522
- }
20523
- };
20524
-
20525
- // src/Lexer.ts
20526
- var _Lexer = class __Lexer {
20527
- tokens;
20528
- options;
20529
- state;
20530
- tokenizer;
20531
- inlineQueue;
20532
- constructor(options2) {
20533
- this.tokens = [];
20534
- this.tokens.links = /* @__PURE__ */ Object.create(null);
20535
- this.options = options2 || _defaults;
20536
- this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
20537
- this.tokenizer = this.options.tokenizer;
20538
- this.tokenizer.options = this.options;
20539
- this.tokenizer.lexer = this;
20540
- this.inlineQueue = [];
20541
- this.state = {
20542
- inLink: false,
20543
- inRawBlock: false,
20544
- top: true
20545
- };
20546
- const rules = {
20547
- other,
20548
- block: block.normal,
20549
- inline: inline.normal
20550
- };
20551
- if (this.options.pedantic) {
20552
- rules.block = block.pedantic;
20553
- rules.inline = inline.pedantic;
20554
- } else if (this.options.gfm) {
20555
- rules.block = block.gfm;
20556
- if (this.options.breaks) {
20557
- rules.inline = inline.breaks;
20558
- } else {
20559
- rules.inline = inline.gfm;
20560
- }
20561
- }
20562
- this.tokenizer.rules = rules;
20563
- }
20564
- /**
20565
- * Expose Rules
20566
- */
20567
- static get rules() {
20568
- return {
20569
- block,
20570
- inline
20571
- };
20572
- }
20573
- /**
20574
- * Static Lex Method
20575
- */
20576
- static lex(src, options2) {
20577
- const lexer2 = new __Lexer(options2);
20578
- return lexer2.lex(src);
20579
- }
20580
- /**
20581
- * Static Lex Inline Method
20582
- */
20583
- static lexInline(src, options2) {
20584
- const lexer2 = new __Lexer(options2);
20585
- return lexer2.inlineTokens(src);
20586
- }
20587
- /**
20588
- * Preprocessing
20589
- */
20590
- lex(src) {
20591
- src = src.replace(other.carriageReturn, "\n");
20592
- this.blockTokens(src, this.tokens);
20593
- for (let i = 0; i < this.inlineQueue.length; i++) {
20594
- const next = this.inlineQueue[i];
20595
- this.inlineTokens(next.src, next.tokens);
20596
- }
20597
- this.inlineQueue = [];
20598
- return this.tokens;
20599
- }
20600
- blockTokens(src, tokens = [], lastParagraphClipped = false) {
20601
- if (this.options.pedantic) {
20602
- src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
20603
- }
20604
- while (src) {
20605
- let token;
20606
- if (this.options.extensions?.block?.some((extTokenizer) => {
20607
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
20608
- src = src.substring(token.raw.length);
20609
- tokens.push(token);
20610
- return true;
20611
- }
20612
- return false;
20613
- })) {
20614
- continue;
20615
- }
20616
- if (token = this.tokenizer.space(src)) {
20617
- src = src.substring(token.raw.length);
20618
- const lastToken = tokens.at(-1);
20619
- if (token.raw.length === 1 && lastToken !== void 0) {
20620
- lastToken.raw += "\n";
20621
- } else {
20622
- tokens.push(token);
20623
- }
20624
- continue;
20625
- }
20626
- if (token = this.tokenizer.code(src)) {
20627
- src = src.substring(token.raw.length);
20628
- const lastToken = tokens.at(-1);
20629
- if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
20630
- lastToken.raw += "\n" + token.raw;
20631
- lastToken.text += "\n" + token.text;
20632
- this.inlineQueue.at(-1).src = lastToken.text;
20633
- } else {
20634
- tokens.push(token);
20635
- }
20636
- continue;
20637
- }
20638
- if (token = this.tokenizer.fences(src)) {
20639
- src = src.substring(token.raw.length);
20640
- tokens.push(token);
20641
- continue;
20642
- }
20643
- if (token = this.tokenizer.heading(src)) {
20644
- src = src.substring(token.raw.length);
20645
- tokens.push(token);
20646
- continue;
20647
- }
20648
- if (token = this.tokenizer.hr(src)) {
20649
- src = src.substring(token.raw.length);
20650
- tokens.push(token);
20651
- continue;
20652
- }
20653
- if (token = this.tokenizer.blockquote(src)) {
20654
- src = src.substring(token.raw.length);
20655
- tokens.push(token);
20656
- continue;
20657
- }
20658
- if (token = this.tokenizer.list(src)) {
20659
- src = src.substring(token.raw.length);
20660
- tokens.push(token);
20661
- continue;
20662
- }
20663
- if (token = this.tokenizer.html(src)) {
20664
- src = src.substring(token.raw.length);
20665
- tokens.push(token);
20666
- continue;
20667
- }
20668
- if (token = this.tokenizer.def(src)) {
20669
- src = src.substring(token.raw.length);
20670
- const lastToken = tokens.at(-1);
20671
- if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
20672
- lastToken.raw += "\n" + token.raw;
20673
- lastToken.text += "\n" + token.raw;
20674
- this.inlineQueue.at(-1).src = lastToken.text;
20675
- } else if (!this.tokens.links[token.tag]) {
20676
- this.tokens.links[token.tag] = {
20677
- href: token.href,
20678
- title: token.title
20679
- };
20680
- }
20681
- continue;
20682
- }
20683
- if (token = this.tokenizer.table(src)) {
20684
- src = src.substring(token.raw.length);
20685
- tokens.push(token);
20686
- continue;
20687
- }
20688
- if (token = this.tokenizer.lheading(src)) {
20689
- src = src.substring(token.raw.length);
20690
- tokens.push(token);
20691
- continue;
20692
- }
20693
- let cutSrc = src;
20694
- if (this.options.extensions?.startBlock) {
20695
- let startIndex = Infinity;
20696
- const tempSrc = src.slice(1);
20697
- let tempStart;
20698
- this.options.extensions.startBlock.forEach((getStartIndex) => {
20699
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
20700
- if (typeof tempStart === "number" && tempStart >= 0) {
20701
- startIndex = Math.min(startIndex, tempStart);
20702
- }
20703
- });
20704
- if (startIndex < Infinity && startIndex >= 0) {
20705
- cutSrc = src.substring(0, startIndex + 1);
20706
- }
20707
- }
20708
- if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
20709
- const lastToken = tokens.at(-1);
20710
- if (lastParagraphClipped && lastToken?.type === "paragraph") {
20711
- lastToken.raw += "\n" + token.raw;
20712
- lastToken.text += "\n" + token.text;
20713
- this.inlineQueue.pop();
20714
- this.inlineQueue.at(-1).src = lastToken.text;
20715
- } else {
20716
- tokens.push(token);
20717
- }
20718
- lastParagraphClipped = cutSrc.length !== src.length;
20719
- src = src.substring(token.raw.length);
20720
- continue;
20721
- }
20722
- if (token = this.tokenizer.text(src)) {
20723
- src = src.substring(token.raw.length);
20724
- const lastToken = tokens.at(-1);
20725
- if (lastToken?.type === "text") {
20726
- lastToken.raw += "\n" + token.raw;
20727
- lastToken.text += "\n" + token.text;
20728
- this.inlineQueue.pop();
20729
- this.inlineQueue.at(-1).src = lastToken.text;
20730
- } else {
20731
- tokens.push(token);
20732
- }
20733
- continue;
20734
- }
20735
- if (src) {
20736
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
20737
- if (this.options.silent) {
20738
- console.error(errMsg);
20739
- break;
20740
- } else {
20741
- throw new Error(errMsg);
20742
- }
20743
- }
20744
- }
20745
- this.state.top = true;
20746
- return tokens;
20747
- }
20748
- inline(src, tokens = []) {
20749
- this.inlineQueue.push({ src, tokens });
20750
- return tokens;
20751
- }
20752
- /**
20753
- * Lexing/Compiling
20754
- */
20755
- inlineTokens(src, tokens = []) {
20756
- let maskedSrc = src;
20757
- let match = null;
20758
- if (this.tokens.links) {
20759
- const links = Object.keys(this.tokens.links);
20760
- if (links.length > 0) {
20761
- while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
20762
- if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
20763
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
20764
- }
20765
- }
20766
- }
20767
- }
20768
- while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
20769
- maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
20770
- }
20771
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
20772
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
20773
- }
20774
- let keepPrevChar = false;
20775
- let prevChar = "";
20776
- while (src) {
20777
- if (!keepPrevChar) {
20778
- prevChar = "";
20779
- }
20780
- keepPrevChar = false;
20781
- let token;
20782
- if (this.options.extensions?.inline?.some((extTokenizer) => {
20783
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
20784
- src = src.substring(token.raw.length);
20785
- tokens.push(token);
20786
- return true;
20787
- }
20788
- return false;
20789
- })) {
20790
- continue;
20791
- }
20792
- if (token = this.tokenizer.escape(src)) {
20793
- src = src.substring(token.raw.length);
20794
- tokens.push(token);
20795
- continue;
20796
- }
20797
- if (token = this.tokenizer.tag(src)) {
20798
- src = src.substring(token.raw.length);
20799
- tokens.push(token);
20800
- continue;
20801
- }
20802
- if (token = this.tokenizer.link(src)) {
20803
- src = src.substring(token.raw.length);
20804
- tokens.push(token);
20805
- continue;
20806
- }
20807
- if (token = this.tokenizer.reflink(src, this.tokens.links)) {
20808
- src = src.substring(token.raw.length);
20809
- const lastToken = tokens.at(-1);
20810
- if (token.type === "text" && lastToken?.type === "text") {
20811
- lastToken.raw += token.raw;
20812
- lastToken.text += token.text;
20813
- } else {
20814
- tokens.push(token);
20815
- }
20816
- continue;
20817
- }
20818
- if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
20819
- src = src.substring(token.raw.length);
20820
- tokens.push(token);
20821
- continue;
20822
- }
20823
- if (token = this.tokenizer.codespan(src)) {
20824
- src = src.substring(token.raw.length);
20825
- tokens.push(token);
20826
- continue;
20827
- }
20828
- if (token = this.tokenizer.br(src)) {
20829
- src = src.substring(token.raw.length);
20830
- tokens.push(token);
20831
- continue;
20832
- }
20833
- if (token = this.tokenizer.del(src)) {
20834
- src = src.substring(token.raw.length);
20835
- tokens.push(token);
20836
- continue;
20837
- }
20838
- if (token = this.tokenizer.autolink(src)) {
20839
- src = src.substring(token.raw.length);
20840
- tokens.push(token);
20841
- continue;
20842
- }
20843
- if (!this.state.inLink && (token = this.tokenizer.url(src))) {
20844
- src = src.substring(token.raw.length);
20845
- tokens.push(token);
20846
- continue;
20847
- }
20848
- let cutSrc = src;
20849
- if (this.options.extensions?.startInline) {
20850
- let startIndex = Infinity;
20851
- const tempSrc = src.slice(1);
20852
- let tempStart;
20853
- this.options.extensions.startInline.forEach((getStartIndex) => {
20854
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
20855
- if (typeof tempStart === "number" && tempStart >= 0) {
20856
- startIndex = Math.min(startIndex, tempStart);
20857
- }
20858
- });
20859
- if (startIndex < Infinity && startIndex >= 0) {
20860
- cutSrc = src.substring(0, startIndex + 1);
20861
- }
20862
- }
20863
- if (token = this.tokenizer.inlineText(cutSrc)) {
20864
- src = src.substring(token.raw.length);
20865
- if (token.raw.slice(-1) !== "_") {
20866
- prevChar = token.raw.slice(-1);
20867
- }
20868
- keepPrevChar = true;
20869
- const lastToken = tokens.at(-1);
20870
- if (lastToken?.type === "text") {
20871
- lastToken.raw += token.raw;
20872
- lastToken.text += token.text;
20873
- } else {
20874
- tokens.push(token);
20875
- }
20876
- continue;
20877
- }
20878
- if (src) {
20879
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
20880
- if (this.options.silent) {
20881
- console.error(errMsg);
20882
- break;
20883
- } else {
20884
- throw new Error(errMsg);
20885
- }
20886
- }
20887
- }
20888
- return tokens;
20889
- }
20890
- };
20891
-
20892
- // src/Renderer.ts
20893
- var _Renderer = class {
20894
- options;
20895
- parser;
20896
- // set by the parser
20897
- constructor(options2) {
20898
- this.options = options2 || _defaults;
20899
- }
20900
- space(token) {
20901
- return "";
20902
- }
20903
- code({ text, lang, escaped }) {
20904
- const langString = (lang || "").match(other.notSpaceStart)?.[0];
20905
- const code = text.replace(other.endingNewline, "") + "\n";
20906
- if (!langString) {
20907
- return "<pre><code>" + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
20908
- }
20909
- return '<pre><code class="language-' + escape2(langString) + '">' + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
20910
- }
20911
- blockquote({ tokens }) {
20912
- const body = this.parser.parse(tokens);
20913
- return `<blockquote>
20914
- ${body}</blockquote>
20915
- `;
20916
- }
20917
- html({ text }) {
20918
- return text;
20919
- }
20920
- heading({ tokens, depth }) {
20921
- return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
20922
- `;
20923
- }
20924
- hr(token) {
20925
- return "<hr>\n";
20926
- }
20927
- list(token) {
20928
- const ordered = token.ordered;
20929
- const start = token.start;
20930
- let body = "";
20931
- for (let j = 0; j < token.items.length; j++) {
20932
- const item = token.items[j];
20933
- body += this.listitem(item);
20934
- }
20935
- const type = ordered ? "ol" : "ul";
20936
- const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
20937
- return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
20938
- }
20939
- listitem(item) {
20940
- let itemBody = "";
20941
- if (item.task) {
20942
- const checkbox = this.checkbox({ checked: !!item.checked });
20943
- if (item.loose) {
20944
- if (item.tokens[0]?.type === "paragraph") {
20945
- item.tokens[0].text = checkbox + " " + item.tokens[0].text;
20946
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
20947
- item.tokens[0].tokens[0].text = checkbox + " " + escape2(item.tokens[0].tokens[0].text);
20948
- item.tokens[0].tokens[0].escaped = true;
20949
- }
20950
- } else {
20951
- item.tokens.unshift({
20952
- type: "text",
20953
- raw: checkbox + " ",
20954
- text: checkbox + " ",
20955
- escaped: true
20956
- });
20957
- }
20958
- } else {
20959
- itemBody += checkbox + " ";
20960
- }
20961
- }
20962
- itemBody += this.parser.parse(item.tokens, !!item.loose);
20963
- return `<li>${itemBody}</li>
20964
- `;
20965
- }
20966
- checkbox({ checked }) {
20967
- return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
20968
- }
20969
- paragraph({ tokens }) {
20970
- return `<p>${this.parser.parseInline(tokens)}</p>
20971
- `;
20972
- }
20973
- table(token) {
20974
- let header = "";
20975
- let cell = "";
20976
- for (let j = 0; j < token.header.length; j++) {
20977
- cell += this.tablecell(token.header[j]);
20978
- }
20979
- header += this.tablerow({ text: cell });
20980
- let body = "";
20981
- for (let j = 0; j < token.rows.length; j++) {
20982
- const row = token.rows[j];
20983
- cell = "";
20984
- for (let k = 0; k < row.length; k++) {
20985
- cell += this.tablecell(row[k]);
20986
- }
20987
- body += this.tablerow({ text: cell });
20988
- }
20989
- if (body) body = `<tbody>${body}</tbody>`;
20990
- return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
20991
- }
20992
- tablerow({ text }) {
20993
- return `<tr>
20994
- ${text}</tr>
20995
- `;
20996
- }
20997
- tablecell(token) {
20998
- const content = this.parser.parseInline(token.tokens);
20999
- const type = token.header ? "th" : "td";
21000
- const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
21001
- return tag2 + content + `</${type}>
21002
- `;
21003
- }
21004
- /**
21005
- * span level renderer
21006
- */
21007
- strong({ tokens }) {
21008
- return `<strong>${this.parser.parseInline(tokens)}</strong>`;
21009
- }
21010
- em({ tokens }) {
21011
- return `<em>${this.parser.parseInline(tokens)}</em>`;
21012
- }
21013
- codespan({ text }) {
21014
- return `<code>${escape2(text, true)}</code>`;
21015
- }
21016
- br(token) {
21017
- return "<br>";
21018
- }
21019
- del({ tokens }) {
21020
- return `<del>${this.parser.parseInline(tokens)}</del>`;
21021
- }
21022
- link({ href, title, tokens }) {
21023
- const text = this.parser.parseInline(tokens);
21024
- const cleanHref = cleanUrl(href);
21025
- if (cleanHref === null) {
21026
- return text;
21027
- }
21028
- href = cleanHref;
21029
- let out = '<a href="' + href + '"';
21030
- if (title) {
21031
- out += ' title="' + escape2(title) + '"';
21032
- }
21033
- out += ">" + text + "</a>";
21034
- return out;
21035
- }
21036
- image({ href, title, text, tokens }) {
21037
- if (tokens) {
21038
- text = this.parser.parseInline(tokens, this.parser.textRenderer);
21039
- }
21040
- const cleanHref = cleanUrl(href);
21041
- if (cleanHref === null) {
21042
- return escape2(text);
21043
- }
21044
- href = cleanHref;
21045
- let out = `<img src="${href}" alt="${text}"`;
21046
- if (title) {
21047
- out += ` title="${escape2(title)}"`;
21048
- }
21049
- out += ">";
21050
- return out;
21051
- }
21052
- text(token) {
21053
- return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape2(token.text);
21054
- }
21055
- };
21056
-
21057
- // src/TextRenderer.ts
21058
- var _TextRenderer = class {
21059
- // no need for block level renderers
21060
- strong({ text }) {
21061
- return text;
21062
- }
21063
- em({ text }) {
21064
- return text;
21065
- }
21066
- codespan({ text }) {
21067
- return text;
21068
- }
21069
- del({ text }) {
21070
- return text;
21071
- }
21072
- html({ text }) {
21073
- return text;
21074
- }
21075
- text({ text }) {
21076
- return text;
21077
- }
21078
- link({ text }) {
21079
- return "" + text;
21080
- }
21081
- image({ text }) {
21082
- return "" + text;
21083
- }
21084
- br() {
21085
- return "";
21086
- }
21087
- };
21088
-
21089
- // src/Parser.ts
21090
- var _Parser = class __Parser {
21091
- options;
21092
- renderer;
21093
- textRenderer;
21094
- constructor(options2) {
21095
- this.options = options2 || _defaults;
21096
- this.options.renderer = this.options.renderer || new _Renderer();
21097
- this.renderer = this.options.renderer;
21098
- this.renderer.options = this.options;
21099
- this.renderer.parser = this;
21100
- this.textRenderer = new _TextRenderer();
21101
- }
21102
- /**
21103
- * Static Parse Method
21104
- */
21105
- static parse(tokens, options2) {
21106
- const parser2 = new __Parser(options2);
21107
- return parser2.parse(tokens);
21108
- }
21109
- /**
21110
- * Static Parse Inline Method
21111
- */
21112
- static parseInline(tokens, options2) {
21113
- const parser2 = new __Parser(options2);
21114
- return parser2.parseInline(tokens);
21115
- }
21116
- /**
21117
- * Parse Loop
21118
- */
21119
- parse(tokens, top = true) {
21120
- let out = "";
21121
- for (let i = 0; i < tokens.length; i++) {
21122
- const anyToken = tokens[i];
21123
- if (this.options.extensions?.renderers?.[anyToken.type]) {
21124
- const genericToken = anyToken;
21125
- const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
21126
- if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
21127
- out += ret || "";
21128
- continue;
21129
- }
21130
- }
21131
- const token = anyToken;
21132
- switch (token.type) {
21133
- case "space": {
21134
- out += this.renderer.space(token);
21135
- continue;
21136
- }
21137
- case "hr": {
21138
- out += this.renderer.hr(token);
21139
- continue;
21140
- }
21141
- case "heading": {
21142
- out += this.renderer.heading(token);
21143
- continue;
21144
- }
21145
- case "code": {
21146
- out += this.renderer.code(token);
21147
- continue;
21148
- }
21149
- case "table": {
21150
- out += this.renderer.table(token);
21151
- continue;
21152
- }
21153
- case "blockquote": {
21154
- out += this.renderer.blockquote(token);
21155
- continue;
21156
- }
21157
- case "list": {
21158
- out += this.renderer.list(token);
21159
- continue;
21160
- }
21161
- case "html": {
21162
- out += this.renderer.html(token);
21163
- continue;
21164
- }
21165
- case "paragraph": {
21166
- out += this.renderer.paragraph(token);
21167
- continue;
21168
- }
21169
- case "text": {
21170
- let textToken = token;
21171
- let body = this.renderer.text(textToken);
21172
- while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
21173
- textToken = tokens[++i];
21174
- body += "\n" + this.renderer.text(textToken);
21175
- }
21176
- if (top) {
21177
- out += this.renderer.paragraph({
21178
- type: "paragraph",
21179
- raw: body,
21180
- text: body,
21181
- tokens: [{ type: "text", raw: body, text: body, escaped: true }]
21182
- });
21183
- } else {
21184
- out += body;
21185
- }
21186
- continue;
21187
- }
21188
- default: {
21189
- const errMsg = 'Token with "' + token.type + '" type was not found.';
21190
- if (this.options.silent) {
21191
- console.error(errMsg);
21192
- return "";
21193
- } else {
21194
- throw new Error(errMsg);
21195
- }
21196
- }
21197
- }
21198
- }
21199
- return out;
21200
- }
21201
- /**
21202
- * Parse Inline Tokens
21203
- */
21204
- parseInline(tokens, renderer = this.renderer) {
21205
- let out = "";
21206
- for (let i = 0; i < tokens.length; i++) {
21207
- const anyToken = tokens[i];
21208
- if (this.options.extensions?.renderers?.[anyToken.type]) {
21209
- const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
21210
- if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
21211
- out += ret || "";
21212
- continue;
21213
- }
21214
- }
21215
- const token = anyToken;
21216
- switch (token.type) {
21217
- case "escape": {
21218
- out += renderer.text(token);
21219
- break;
21220
- }
21221
- case "html": {
21222
- out += renderer.html(token);
21223
- break;
21224
- }
21225
- case "link": {
21226
- out += renderer.link(token);
21227
- break;
21228
- }
21229
- case "image": {
21230
- out += renderer.image(token);
21231
- break;
21232
- }
21233
- case "strong": {
21234
- out += renderer.strong(token);
21235
- break;
21236
- }
21237
- case "em": {
21238
- out += renderer.em(token);
21239
- break;
21240
- }
21241
- case "codespan": {
21242
- out += renderer.codespan(token);
21243
- break;
21244
- }
21245
- case "br": {
21246
- out += renderer.br(token);
21247
- break;
21248
- }
21249
- case "del": {
21250
- out += renderer.del(token);
21251
- break;
21252
- }
21253
- case "text": {
21254
- out += renderer.text(token);
21255
- break;
21256
- }
21257
- default: {
21258
- const errMsg = 'Token with "' + token.type + '" type was not found.';
21259
- if (this.options.silent) {
21260
- console.error(errMsg);
21261
- return "";
21262
- } else {
21263
- throw new Error(errMsg);
21264
- }
21265
- }
19461
+ const indentedChild = childContent.split("\n").map((line) => line ? h2.indent(line) : "").join("\n");
19462
+ output.push(indentedChild);
21266
19463
  }
21267
- }
21268
- return out;
19464
+ });
21269
19465
  }
21270
- };
19466
+ return output.join("\n");
19467
+ }
21271
19468
 
21272
- // src/Hooks.ts
21273
- var _Hooks = class {
21274
- options;
21275
- block;
21276
- constructor(options2) {
21277
- this.options = options2 || _defaults;
21278
- }
21279
- static passThroughHooks = /* @__PURE__ */ new Set([
21280
- "preprocess",
21281
- "postprocess",
21282
- "processAllTokens"
21283
- ]);
21284
- /**
21285
- * Process markdown before marked
21286
- */
21287
- preprocess(markdown) {
21288
- return markdown;
19469
+ // src/MarkView.ts
19470
+ function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
19471
+ const { state } = editor;
19472
+ const { doc, tr } = state;
19473
+ const thisMark = checkMark;
19474
+ doc.descendants((node, pos) => {
19475
+ const from = tr.mapping.map(pos);
19476
+ const to = tr.mapping.map(pos) + node.nodeSize;
19477
+ let foundMark = null;
19478
+ node.marks.forEach((mark) => {
19479
+ if (mark !== thisMark) {
19480
+ return false;
19481
+ }
19482
+ foundMark = mark;
19483
+ });
19484
+ if (!foundMark) {
19485
+ return;
19486
+ }
19487
+ let needsUpdate = false;
19488
+ Object.keys(attrs).forEach((k) => {
19489
+ if (attrs[k] !== foundMark.attrs[k]) {
19490
+ needsUpdate = true;
19491
+ }
19492
+ });
19493
+ if (needsUpdate) {
19494
+ const updatedMark = checkMark.type.create({
19495
+ ...checkMark.attrs,
19496
+ ...attrs
19497
+ });
19498
+ tr.removeMark(from, to, checkMark.type);
19499
+ tr.addMark(from, to, updatedMark);
19500
+ }
19501
+ });
19502
+ if (tr.docChanged) {
19503
+ editor.view.dispatch(tr);
21289
19504
  }
21290
- /**
21291
- * Process HTML after marked is finished
21292
- */
21293
- postprocess(html2) {
21294
- return html2;
19505
+ }
19506
+
19507
+ // src/Node.ts
19508
+ var Node3 = class _Node extends Extendable {
19509
+ constructor() {
19510
+ super(...arguments);
19511
+ this.type = "node";
21295
19512
  }
21296
19513
  /**
21297
- * Process all tokens before walk tokens
19514
+ * Create a new Node instance
19515
+ * @param config - Node configuration object or a function that returns a configuration object
21298
19516
  */
21299
- processAllTokens(tokens) {
21300
- return tokens;
19517
+ static create(config = {}) {
19518
+ const resolvedConfig = typeof config === "function" ? config() : config;
19519
+ return new _Node(resolvedConfig);
21301
19520
  }
21302
- /**
21303
- * Provide function to tokenize markdown
21304
- */
21305
- provideLexer() {
21306
- return this.block ? _Lexer.lex : _Lexer.lexInline;
19521
+ configure(options) {
19522
+ return super.configure(options);
21307
19523
  }
21308
- /**
21309
- * Provide function to parse tokens
21310
- */
21311
- provideParser() {
21312
- return this.block ? _Parser.parse : _Parser.parseInline;
19524
+ extend(extendedConfig) {
19525
+ const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
19526
+ return super.extend(resolvedConfig);
21313
19527
  }
21314
19528
  };
21315
19529
 
21316
- // src/Instance.ts
21317
- var Marked = class {
21318
- defaults = _getDefaults();
21319
- options = this.setOptions;
21320
- parse = this.parseMarkdown(true);
21321
- parseInline = this.parseMarkdown(false);
21322
- Parser = _Parser;
21323
- Renderer = _Renderer;
21324
- TextRenderer = _TextRenderer;
21325
- Lexer = _Lexer;
21326
- Tokenizer = _Tokenizer;
21327
- Hooks = _Hooks;
21328
- constructor(...args) {
21329
- this.use(...args);
21330
- }
21331
- /**
21332
- * Run callback for every token
21333
- */
21334
- walkTokens(tokens, callback) {
21335
- let values = [];
21336
- for (const token of tokens) {
21337
- values = values.concat(callback.call(this, token));
21338
- switch (token.type) {
21339
- case "table": {
21340
- const tableToken = token;
21341
- for (const cell of tableToken.header) {
21342
- values = values.concat(this.walkTokens(cell.tokens, callback));
21343
- }
21344
- for (const row of tableToken.rows) {
21345
- for (const cell of row) {
21346
- values = values.concat(this.walkTokens(cell.tokens, callback));
21347
- }
21348
- }
21349
- break;
21350
- }
21351
- case "list": {
21352
- const listToken = token;
21353
- values = values.concat(this.walkTokens(listToken.items, callback));
21354
- break;
21355
- }
21356
- default: {
21357
- const genericToken = token;
21358
- if (this.defaults.extensions?.childTokens?.[genericToken.type]) {
21359
- this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
21360
- const tokens2 = genericToken[childTokens].flat(Infinity);
21361
- values = values.concat(this.walkTokens(tokens2, callback));
21362
- });
21363
- } else if (genericToken.tokens) {
21364
- values = values.concat(this.walkTokens(genericToken.tokens, callback));
21365
- }
21366
- }
21367
- }
21368
- }
21369
- return values;
21370
- }
21371
- use(...args) {
21372
- const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
21373
- args.forEach((pack) => {
21374
- const opts = { ...pack };
21375
- opts.async = this.defaults.async || opts.async || false;
21376
- if (pack.extensions) {
21377
- pack.extensions.forEach((ext) => {
21378
- if (!ext.name) {
21379
- throw new Error("extension name required");
21380
- }
21381
- if ("renderer" in ext) {
21382
- const prevRenderer = extensions.renderers[ext.name];
21383
- if (prevRenderer) {
21384
- extensions.renderers[ext.name] = function(...args2) {
21385
- let ret = ext.renderer.apply(this, args2);
21386
- if (ret === false) {
21387
- ret = prevRenderer.apply(this, args2);
21388
- }
21389
- return ret;
21390
- };
21391
- } else {
21392
- extensions.renderers[ext.name] = ext.renderer;
21393
- }
21394
- }
21395
- if ("tokenizer" in ext) {
21396
- if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
21397
- throw new Error("extension level must be 'block' or 'inline'");
21398
- }
21399
- const extLevel = extensions[ext.level];
21400
- if (extLevel) {
21401
- extLevel.unshift(ext.tokenizer);
21402
- } else {
21403
- extensions[ext.level] = [ext.tokenizer];
21404
- }
21405
- if (ext.start) {
21406
- if (ext.level === "block") {
21407
- if (extensions.startBlock) {
21408
- extensions.startBlock.push(ext.start);
21409
- } else {
21410
- extensions.startBlock = [ext.start];
21411
- }
21412
- } else if (ext.level === "inline") {
21413
- if (extensions.startInline) {
21414
- extensions.startInline.push(ext.start);
21415
- } else {
21416
- extensions.startInline = [ext.start];
21417
- }
21418
- }
21419
- }
21420
- }
21421
- if ("childTokens" in ext && ext.childTokens) {
21422
- extensions.childTokens[ext.name] = ext.childTokens;
21423
- }
21424
- });
21425
- opts.extensions = extensions;
21426
- }
21427
- if (pack.renderer) {
21428
- const renderer = this.defaults.renderer || new _Renderer(this.defaults);
21429
- for (const prop in pack.renderer) {
21430
- if (!(prop in renderer)) {
21431
- throw new Error(`renderer '${prop}' does not exist`);
21432
- }
21433
- if (["options", "parser"].includes(prop)) {
21434
- continue;
21435
- }
21436
- const rendererProp = prop;
21437
- const rendererFunc = pack.renderer[rendererProp];
21438
- const prevRenderer = renderer[rendererProp];
21439
- renderer[rendererProp] = (...args2) => {
21440
- let ret = rendererFunc.apply(renderer, args2);
21441
- if (ret === false) {
21442
- ret = prevRenderer.apply(renderer, args2);
21443
- }
21444
- return ret || "";
21445
- };
21446
- }
21447
- opts.renderer = renderer;
21448
- }
21449
- if (pack.tokenizer) {
21450
- const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
21451
- for (const prop in pack.tokenizer) {
21452
- if (!(prop in tokenizer)) {
21453
- throw new Error(`tokenizer '${prop}' does not exist`);
21454
- }
21455
- if (["options", "rules", "lexer"].includes(prop)) {
21456
- continue;
21457
- }
21458
- const tokenizerProp = prop;
21459
- const tokenizerFunc = pack.tokenizer[tokenizerProp];
21460
- const prevTokenizer = tokenizer[tokenizerProp];
21461
- tokenizer[tokenizerProp] = (...args2) => {
21462
- let ret = tokenizerFunc.apply(tokenizer, args2);
21463
- if (ret === false) {
21464
- ret = prevTokenizer.apply(tokenizer, args2);
21465
- }
21466
- return ret;
21467
- };
21468
- }
21469
- opts.tokenizer = tokenizer;
21470
- }
21471
- if (pack.hooks) {
21472
- const hooks = this.defaults.hooks || new _Hooks();
21473
- for (const prop in pack.hooks) {
21474
- if (!(prop in hooks)) {
21475
- throw new Error(`hook '${prop}' does not exist`);
21476
- }
21477
- if (["options", "block"].includes(prop)) {
21478
- continue;
21479
- }
21480
- const hooksProp = prop;
21481
- const hooksFunc = pack.hooks[hooksProp];
21482
- const prevHook = hooks[hooksProp];
21483
- if (_Hooks.passThroughHooks.has(prop)) {
21484
- hooks[hooksProp] = (arg) => {
21485
- if (this.defaults.async) {
21486
- return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
21487
- return prevHook.call(hooks, ret2);
21488
- });
21489
- }
21490
- const ret = hooksFunc.call(hooks, arg);
21491
- return prevHook.call(hooks, ret);
21492
- };
21493
- } else {
21494
- hooks[hooksProp] = (...args2) => {
21495
- let ret = hooksFunc.apply(hooks, args2);
21496
- if (ret === false) {
21497
- ret = prevHook.apply(hooks, args2);
21498
- }
21499
- return ret;
21500
- };
21501
- }
21502
- }
21503
- opts.hooks = hooks;
21504
- }
21505
- if (pack.walkTokens) {
21506
- const walkTokens2 = this.defaults.walkTokens;
21507
- const packWalktokens = pack.walkTokens;
21508
- opts.walkTokens = function(token) {
21509
- let values = [];
21510
- values.push(packWalktokens.call(this, token));
21511
- if (walkTokens2) {
21512
- values = values.concat(walkTokens2.call(this, token));
21513
- }
21514
- return values;
21515
- };
21516
- }
21517
- this.defaults = { ...this.defaults, ...opts };
21518
- });
21519
- return this;
21520
- }
21521
- setOptions(opt) {
21522
- this.defaults = { ...this.defaults, ...opt };
21523
- return this;
21524
- }
21525
- lexer(src, options2) {
21526
- return _Lexer.lex(src, options2 ?? this.defaults);
21527
- }
21528
- parser(tokens, options2) {
21529
- return _Parser.parse(tokens, options2 ?? this.defaults);
21530
- }
21531
- parseMarkdown(blockType) {
21532
- const parse2 = (src, options2) => {
21533
- const origOpt = { ...options2 };
21534
- const opt = { ...this.defaults, ...origOpt };
21535
- const throwError = this.onError(!!opt.silent, !!opt.async);
21536
- if (this.defaults.async === true && origOpt.async === false) {
21537
- return throwError(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."));
21538
- }
21539
- if (typeof src === "undefined" || src === null) {
21540
- return throwError(new Error("marked(): input parameter is undefined or null"));
21541
- }
21542
- if (typeof src !== "string") {
21543
- return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
21544
- }
21545
- if (opt.hooks) {
21546
- opt.hooks.options = opt;
21547
- opt.hooks.block = blockType;
21548
- }
21549
- const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
21550
- const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
21551
- if (opt.async) {
21552
- return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
19530
+ // src/pasteRules/markPasteRule.ts
19531
+ function markPasteRule(config) {
19532
+ return new PasteRule({
19533
+ find: config.find,
19534
+ handler: ({ state, range, match, pasteEvent }) => {
19535
+ const attributes = callOrReturn(config.getAttributes, void 0, match, pasteEvent);
19536
+ if (attributes === false || attributes === null) {
19537
+ return null;
21553
19538
  }
21554
- try {
21555
- if (opt.hooks) {
21556
- src = opt.hooks.preprocess(src);
21557
- }
21558
- let tokens = lexer2(src, opt);
21559
- if (opt.hooks) {
21560
- tokens = opt.hooks.processAllTokens(tokens);
21561
- }
21562
- if (opt.walkTokens) {
21563
- this.walkTokens(tokens, opt.walkTokens);
19539
+ const { tr } = state;
19540
+ const captureGroup = match[match.length - 1];
19541
+ const fullMatch = match[0];
19542
+ let markEnd = range.to;
19543
+ if (captureGroup) {
19544
+ const startSpaces = fullMatch.search(/\S/);
19545
+ const textStart = range.from + fullMatch.indexOf(captureGroup);
19546
+ const textEnd = textStart + captureGroup.length;
19547
+ const excludedMarks = getMarksBetween(range.from, range.to, state.doc).filter((item) => {
19548
+ const excluded = item.mark.type.excluded;
19549
+ return excluded.find((type) => type === config.type && type !== item.mark.type);
19550
+ }).filter((item) => item.to > textStart);
19551
+ if (excludedMarks.length) {
19552
+ return null;
21564
19553
  }
21565
- let html2 = parser2(tokens, opt);
21566
- if (opt.hooks) {
21567
- html2 = opt.hooks.postprocess(html2);
19554
+ if (textEnd < range.to) {
19555
+ tr.delete(textEnd, range.to);
21568
19556
  }
21569
- return html2;
21570
- } catch (e) {
21571
- return throwError(e);
21572
- }
21573
- };
21574
- return parse2;
21575
- }
21576
- onError(silent, async) {
21577
- return (e) => {
21578
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
21579
- if (silent) {
21580
- const msg = "<p>An error occurred:</p><pre>" + escape2(e.message + "", true) + "</pre>";
21581
- if (async) {
21582
- return Promise.resolve(msg);
19557
+ if (textStart > range.from) {
19558
+ tr.delete(range.from + startSpaces, textStart);
21583
19559
  }
21584
- return msg;
21585
- }
21586
- if (async) {
21587
- return Promise.reject(e);
19560
+ markEnd = range.from + startSpaces + captureGroup.length;
19561
+ tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
19562
+ tr.removeStoredMark(config.type);
21588
19563
  }
21589
- throw e;
21590
- };
21591
- }
21592
- };
21593
-
21594
- // src/marked.ts
21595
- var markedInstance = new Marked();
21596
- function marked(src, opt) {
21597
- return markedInstance.parse(src, opt);
19564
+ }
19565
+ });
21598
19566
  }
21599
- marked.options = marked.setOptions = function(options2) {
21600
- markedInstance.setOptions(options2);
21601
- marked.defaults = markedInstance.defaults;
21602
- changeDefaults(marked.defaults);
21603
- return marked;
21604
- };
21605
- marked.getDefaults = _getDefaults;
21606
- marked.defaults = _defaults;
21607
- marked.use = function(...args) {
21608
- markedInstance.use(...args);
21609
- marked.defaults = markedInstance.defaults;
21610
- changeDefaults(marked.defaults);
21611
- return marked;
21612
- };
21613
- marked.walkTokens = function(tokens, callback) {
21614
- return markedInstance.walkTokens(tokens, callback);
21615
- };
21616
- marked.parseInline = markedInstance.parseInline;
21617
- marked.Parser = _Parser;
21618
- marked.parser = _Parser.parse;
21619
- marked.Renderer = _Renderer;
21620
- marked.TextRenderer = _TextRenderer;
21621
- marked.Lexer = _Lexer;
21622
- marked.lexer = _Lexer.lex;
21623
- marked.Tokenizer = _Tokenizer;
21624
- marked.Hooks = _Hooks;
21625
- marked.parse = marked;
19567
+
19568
+ /**
19569
+ * marked v17.0.3 - a markdown parser
19570
+ * Copyright (c) 2018-2026, MarkedJS. (MIT License)
19571
+ * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
19572
+ * https://github.com/markedjs/marked
19573
+ */
19574
+
19575
+ /**
19576
+ * DO NOT EDIT THIS FILE
19577
+ * The code in this file is generated from files in ./src/
19578
+ */
19579
+
19580
+ function M(){return {async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}var T=M();function H(u){T=u;}var _={exec:()=>null};function k(u,e=""){let t=typeof u=="string"?u:u.source,n={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(m.caret,"$1"),t=t.replace(r,s),n},getRegex:()=>new RegExp(t,e)};return n}var Re=(()=>{try{return !!new RegExp("(?<=1)(?<!1)")}catch{return false}})(),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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:u=>new RegExp(`^( {0,3}${u})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}#`),htmlBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}>`)},Te=/^(?:[ \t]*(?:\n|$))+/,Oe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,we=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,I=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ye=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,N=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,re=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,se=k(re).replace(/bull/g,N).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(),Pe=k(re).replace(/bull/g,N).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(),Q=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Se=/^[^\n]+/,F=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,$e=k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",F).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),_e=k(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,N).getRegex(),q="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",j=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Le=k("^ {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",j).replace("tag",q).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ie=k(Q).replace("hr",I).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",q).getRegex(),Me=k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ie).getRegex(),U={blockquote:Me,code:Oe,def:$e,fences:we,heading:ye,hr:I,html:Le,lheading:se,list:_e,newline:Te,paragraph:ie,table:_,text:Se},te=k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",I).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",q).getRegex(),ze={...U,lheading:Pe,table:te,paragraph:k(Q).replace("hr",I).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",te).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",q).getRegex()},Ce={...U,html:k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",j).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:_,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(Q).replace("hr",I).replace("heading",` *#{1,6} *[^
19581
+ ]`).replace("lheading",se).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ae=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ie=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,oe=/^( {2,}|\\)\n(?!\s*$)/,Ee=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,v=/[\p{P}\p{S}]/u,K=/[\s\p{P}\p{S}]/u,ae=/[^\s\p{P}\p{S}]/u,Be=k(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,K).getRegex(),le=/(?!~)[\p{P}\p{S}]/u,De=/(?!~)[\s\p{P}\p{S}]/u,qe=/(?:[^\s\p{P}\p{S}]|~)/u,ue=/(?![*_])[\p{P}\p{S}]/u,ve=/(?![*_])[\s\p{P}\p{S}]/u,Ge=/(?:[^\s\p{P}\p{S}]|[*_])/u,He=k(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Re?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),pe=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ze=k(pe,"u").replace(/punct/g,v).getRegex(),Ne=k(pe,"u").replace(/punct/g,le).getRegex(),ce="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Qe=k(ce,"gu").replace(/notPunctSpace/g,ae).replace(/punctSpace/g,K).replace(/punct/g,v).getRegex(),Fe=k(ce,"gu").replace(/notPunctSpace/g,qe).replace(/punctSpace/g,De).replace(/punct/g,le).getRegex(),je=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ae).replace(/punctSpace/g,K).replace(/punct/g,v).getRegex(),Ue=k(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ue).getRegex(),Ke="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",We=k(Ke,"gu").replace(/notPunctSpace/g,Ge).replace(/punctSpace/g,ve).replace(/punct/g,ue).getRegex(),Xe=k(/\\(punct)/,"gu").replace(/punct/g,v).getRegex(),Je=k(/^<(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(),Ve=k(j).replace("(?:-->|$)","-->").getRegex(),Ye=k("^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",Ve).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),D=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,et=k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",D).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),he=k(/^!?\[(label)\]\[(ref)\]/).replace("label",D).replace("ref",F).getRegex(),ke=k(/^!?\[(ref)\](?:\[\])?/).replace("ref",F).getRegex(),tt$1=k("reflink|nolink(?!\\()","g").replace("reflink",he).replace("nolink",ke).getRegex(),ne=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,W={_backpedal:_,anyPunctuation:Xe,autolink:Je,blockSkip:He,br:oe,code:Ie,del:_,delLDelim:_,delRDelim:_,emStrongLDelim:Ze,emStrongRDelimAst:Qe,emStrongRDelimUnd:je,escape:Ae,link:et,nolink:ke,punctuation:Be,reflink:he,reflinkSearch:tt$1,tag:Ye,text:Ee,url:_},nt={...W,link:k(/^!?\[(label)\]\((.*?)\)/).replace("label",D).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",D).getRegex()},Z={...W,emStrongRDelimAst:Fe,emStrongLDelim:Ne,delLDelim:Ue,delRDelim:We,url:k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ne).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:k(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ne).getRegex()},rt={...Z,br:k(oe).replace("{2,}","*").getRegex(),text:k(Z.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},E={normal:U,gfm:ze,pedantic:Ce},z={normal:W,gfm:Z,breaks:rt,pedantic:nt};var st={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},de=u=>st[u];function O(u,e){if(e){if(m.escapeTest.test(u))return u.replace(m.escapeReplace,de)}else if(m.escapeTestNoEncode.test(u))return u.replace(m.escapeReplaceNoEncode,de);return u}function X(u){try{u=encodeURI(u).replace(m.percentDecode,"%");}catch{return null}return u}function J(u,e){let t=u.replace(m.findPipe,(i,s,a)=>{let o=false,l=s;for(;--l>=0&&a[l]==="\\";)o=!o;return o?"|":" |"}),n=t.split(m.splitPipe),r=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(;r<n.length;r++)n[r]=n[r].trim().replace(m.slashPipe,"|");return n}function C(u,e,t){let n=u.length;if(n===0)return "";let r=0;for(;r<n;){let i=u.charAt(n-r-1);if(i===e&&true)r++;else break}return u.slice(0,n-r)}function ge(u,e){if(u.indexOf(e[1])===-1)return -1;let t=0;for(let n=0;n<u.length;n++)if(u[n]==="\\")n++;else if(u[n]===e[0])t++;else if(u[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function fe(u,e=0){let t=e,n="";for(let r of u)if(r===" "){let i=4-t%4;n+=" ".repeat(i),t+=i;}else n+=r,t++;return n}function me(u,e,t,n,r){let i=e.href,s=e.title||null,a=u[1].replace(r.other.outputLinkReplace,"$1");n.state.inLink=true;let o={type:u[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:s,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=false,o}function it(u,e,t){let n=u.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(`
19582
+ `).map(i=>{let s=i.match(t.other.beginningSpace);if(s===null)return i;let[a]=s;return a.length>=r.length?i.slice(r.length):i}).join(`
19583
+ `)}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=t[0].replace(this.rules.other.codeRemoveIndent,"");return {type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:C(n,`
19584
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=it(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:r}}}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 r=C(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim());}return {type:"heading",raw:t[0],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:C(t[0],`
19585
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=C(t[0],`
19586
+ `).split(`
19587
+ `),r="",i="",s=[];for(;n.length>0;){let a=false,o=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))o.push(n[l]),a=true;else if(!a)o.push(n[l]);else break;n=n.slice(l);let p=o.join(`
19588
+ `),c=p.replace(this.rules.other.blockquoteSetextReplace,`
19589
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
19590
+ ${p}`:p,i=i?`${i}
19591
+ ${c}`:c;let d=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.blockTokens(c,s,true),this.lexer.state.top=d,n.length===0)break;let h=s.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let R=h,f=R.raw+`
19592
+ `+n.join(`
19593
+ `),S=this.blockquote(f);s[s.length-1]=S,r=r.substring(0,r.length-R.raw.length)+S.raw,i=i.substring(0,i.length-R.text.length)+S.text;break}else if(h?.type==="list"){let R=h,f=R.raw+`
19594
+ `+n.join(`
19595
+ `),S=this.list(f);s[s.length-1]=S,r=r.substring(0,r.length-h.raw.length)+S.raw,i=i.substring(0,i.length-R.raw.length)+S.raw,n=f.substring(s.at(-1).raw.length).split(`
19596
+ `);continue}}return {type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:false,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),a=false;for(;e;){let l=false,p="",c="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let d=fe(t[2].split(`
19597
+ `,1)[0],t[1].length),h=e.split(`
19598
+ `,1)[0],R=!d.trim(),f=0;if(this.options.pedantic?(f=2,c=d.trimStart()):R?f=t[1].length+1:(f=d.search(this.rules.other.nonSpaceChar),f=f>4?1:f,c=d.slice(f),f+=t[1].length),R&&this.rules.other.blankLine.test(h)&&(p+=h+`
19599
+ `,e=e.substring(h.length+1),l=true),!l){let S=this.rules.other.nextBulletRegex(f),V=this.rules.other.hrRegex(f),Y=this.rules.other.fencesBeginRegex(f),ee=this.rules.other.headingBeginRegex(f),xe=this.rules.other.htmlBeginRegex(f),be=this.rules.other.blockquoteBeginRegex(f);for(;e;){let G=e.split(`
19600
+ `,1)[0],A;if(h=G,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),A=h):A=h.replace(this.rules.other.tabCharGlobal," "),Y.test(h)||ee.test(h)||xe.test(h)||be.test(h)||S.test(h)||V.test(h))break;if(A.search(this.rules.other.nonSpaceChar)>=f||!h.trim())c+=`
19601
+ `+A.slice(f);else {if(R||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Y.test(d)||ee.test(d)||V.test(d))break;c+=`
19602
+ `+h;}R=!h.trim(),p+=G+`
19603
+ `,e=e.substring(G.length+1),d=A.slice(f);}}i.loose||(a?i.loose=true:this.rules.other.doubleBlankLine.test(p)&&(a=true)),i.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:false,text:c,tokens:[]}),i.raw+=p;}let o=i.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items){if(this.lexer.state.top=false,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let c={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=c.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=c.raw+l.tokens[0].raw,l.tokens[0].text=c.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(c)):l.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):l.tokens.unshift(c);}}if(!i.loose){let p=l.tokens.filter(d=>d.type==="space"),c=p.length>0&&p.some(d=>this.rules.other.anyLine.test(d.raw));i.loose=c;}}if(i.loose)for(let l of i.items){l.loose=true;for(let p of l.tokens)p.type==="text"&&(p.type="paragraph");}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return {type:"html",block:true,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return {type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=J(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
19604
+ `):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<n.length;a++)s.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:true,align:s.align[a]});for(let a of i)s.rows.push(J(a,s.header.length).map((o,l)=>({text:o,tokens:this.lexer.inline(o),header:false,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return {type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
19605
+ `?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=true:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,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 s=C(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else {let s=ge(t[2],"()");if(s===-2)return;if(s>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]="";}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3]);}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),me(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.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 r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return {type:"text",raw:s,text:s}}return me(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let s=[...r[0]].length-1,a,o,l=s,p=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(r=c.exec(t))!=null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){l+=o;continue}else if((r[5]||r[6])&&s%3&&!((s+o)%3)){p+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+p);let d=[...r[0]][0].length,h=e.slice(0,s+r.index+d+o);if(Math.min(s,o)%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," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(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 r=this.rules.inline.delLDelim.exec(e);if(!r)return;if(!(r[1]||"")||!n||this.rules.inline.punctuation.exec(n)){let s=[...r[0]].length-1,a,o,l=s,p=this.rules.inline.delRDelim;for(p.lastIndex=0,t=t.slice(-1*e.length+s);(r=p.exec(t))!=null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a||(o=[...a].length,o!==s))continue;if(r[3]||r[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let c=[...r[0]][0].length,d=e.slice(0,s+r.index+c+o),h=d.slice(s,-s);return {type:"del",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else {let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0];}return {type:"link",raw:t[0],text:n,href:r,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 u{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:false,inRawBlock:false,top:true};let t={other:m,block:E.normal,inline:z.normal};this.options.pedantic?(t.block=E.pedantic,t.inline=z.pedantic):this.options.gfm&&(t.block=E.gfm,this.options.breaks?t.inline=z.breaks:t.inline=z.gfm),this.tokenizer.rules=t;}static get rules(){return {block:E,inline:z}}static lex(e,t){return new u(t).lex(e)}static lexInline(e,t){return new u(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,`
19606
+ `),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=false){for(this.options.pedantic&&(e=e.replace(m.tabCharGlobal," ").replace(m.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(s=>(r=s.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),true):false))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let s=t.at(-1);r.raw.length===1&&s!==void 0?s.raw+=`
19607
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
19608
+ `)?"":`
19609
+ `)+r.raw,s.text+=`
19610
+ `+r.text,this.inlineQueue.at(-1).src=s.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 s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
19611
+ `)?"":`
19612
+ `)+r.raw,s.text+=`
19613
+ `+r.raw,this.inlineQueue.at(-1).src=s.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 s=1/0,a=e.slice(1),o;this.options.extensions.startBlock.forEach(l=>{o=l.call({lexer:this},a),typeof o=="number"&&o>=0&&(s=Math.min(s,o));}),s<1/0&&s>=0&&(i=e.substring(0,s+1));}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let s=t.at(-1);n&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
19614
+ `)?"":`
19615
+ `)+r.raw,s.text+=`
19616
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.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 s=t.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
19617
+ `)?"":`
19618
+ `)+r.raw,s.text+=`
19619
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=true,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)o.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+"["+"a".repeat(r[0].length-i-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let s=false,a="";for(;e;){s||(a=""),s=false;let o;if(this.options.extensions?.inline?.some(p=>(o=p.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),true):false))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let p=t.at(-1);o.type==="text"&&p?.type==="text"?(p.raw+=o.raw,p.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,a)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,a)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let l=e;if(this.options.extensions?.startInline){let p=1/0,c=e.slice(1),d;this.options.extensions.startInline.forEach(h=>{d=h.call({lexer:this},c),typeof d=="number"&&d>=0&&(p=Math.min(p,d));}),p<1/0&&p>=0&&(l=e.substring(0,p+1));}if(o=this.tokenizer.inlineText(l)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(a=o.raw.slice(-1)),s=true;let p=t.at(-1);p?.type==="text"?(p.raw+=o.raw,p.text+=o.text):t.push(o);continue}if(e){let p="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return t}};var y=class{options;parser;constructor(e){this.options=e||T;}space(e){return ""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(m.notSpaceStart)?.[0],i=e.replace(m.endingNewline,"")+`
19620
+ `;return r?'<pre><code class="language-'+O(r)+'">'+(n?i:O(i,true))+`</code></pre>
19621
+ `:"<pre><code>"+(n?i:O(i,true))+`</code></pre>
19622
+ `}blockquote({tokens:e}){return `<blockquote>
19623
+ ${this.parser.parse(e)}</blockquote>
19624
+ `}html({text:e}){return e}def(e){return ""}heading({tokens:e,depth:t}){return `<h${t}>${this.parser.parseInline(e)}</h${t}>
19625
+ `}hr(e){return `<hr>
19626
+ `}list(e){let t=e.ordered,n=e.start,r="";for(let a=0;a<e.items.length;a++){let o=e.items[a];r+=this.listitem(o);}let i=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return "<"+i+s+`>
19627
+ `+r+"</"+i+`>
19628
+ `}listitem(e){return `<li>${this.parser.parse(e.tokens)}</li>
19629
+ `}checkbox({checked:e}){return "<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return `<p>${this.parser.parseInline(e)}</p>
19630
+ `}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let s=e.rows[i];n="";for(let a=0;a<s.length;a++)n+=this.tablecell(s[a]);r+=this.tablerow({text:n});}return r&&(r=`<tbody>${r}</tbody>`),`<table>
19631
+ <thead>
19632
+ `+t+`</thead>
19633
+ `+r+`</table>
19634
+ `}tablerow({text:e}){return `<tr>
19635
+ ${e}</tr>
19636
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return (e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
19637
+ `}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,true)}</code>`}br(e){return "<br>"}del({tokens:e}){return `<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=X(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+O(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=X(e);if(i===null)return O(n);e=i;let s=`<img src="${e}" alt="${O(n)}"`;return t&&(s+=` title="${O(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:O(e.text)}};var $=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 u{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 $;}static parse(e,t){return new u(t).parse(e)}static parseInline(e,t){return new u(t).parseInline(e)}parse(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let s=r,a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(s.type)){t+=a||"";continue}}let i=r;switch(i.type){case "space":{t+=this.renderer.space(i);break}case "hr":{t+=this.renderer.hr(i);break}case "heading":{t+=this.renderer.heading(i);break}case "code":{t+=this.renderer.code(i);break}case "table":{t+=this.renderer.table(i);break}case "blockquote":{t+=this.renderer.blockquote(i);break}case "list":{t+=this.renderer.list(i);break}case "checkbox":{t+=this.renderer.checkbox(i);break}case "html":{t+=this.renderer.html(i);break}case "def":{t+=this.renderer.def(i);break}case "paragraph":{t+=this.renderer.paragraph(i);break}case "text":{t+=this.renderer.text(i);break}default:{let s='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return t}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=a||"";continue}}let s=i;switch(s.type){case "escape":{n+=t.text(s);break}case "html":{n+=t.html(s);break}case "link":{n+=t.link(s);break}case "image":{n+=t.image(s);break}case "checkbox":{n+=t.checkbox(s);break}case "strong":{n+=t.strong(s);break}case "em":{n+=t.em(s);break}case "codespan":{n+=t.codespan(s);break}case "br":{n+=t.br(s);break}case "del":{n+=t.del(s);break}case "text":{n+=t.text(s);break}default:{let a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}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(){return this.block?x.lex:x.lexInline}provideParser(){return this.block?b.parse:b.parseInline}};var B=class{defaults=M();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=b;Renderer=y;TextRenderer=$;Lexer=x;Tokenizer=w;Hooks=P;constructor(...e){this.use(...e);}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case "table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let a of s)n=n.concat(this.walkTokens(a.tokens,t));break}case "list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let a=i[s].flat(1/0);n=n.concat(this.walkTokens(a,t));}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)));}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||false,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...a){let o=i.renderer.apply(this,a);return o===false&&(o=s.apply(this,a)),o}:t.renderers[i.name]=i.renderer;}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]));}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens);}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new y(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,o=n.renderer[a],l=i[a];i[a]=(...p)=>{let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c||""};}r.renderer=i;}if(n.tokenizer){let i=this.defaults.tokenizer||new w(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,o=n.tokenizer[a],l=i[a];i[a]=(...p)=>{let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c};}r.tokenizer=i;}if(n.hooks){let i=this.defaults.hooks||new P;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,o=n.hooks[a],l=i[a];P.passThroughHooks.has(s)?i[a]=p=>{if(this.defaults.async&&P.passThroughHooksRespectAsync.has(s))return (async()=>{let d=await o.call(i,p);return l.call(i,d)})();let c=o.call(i,p);return l.call(i,c)}:i[a]=(...p)=>{if(this.defaults.async)return (async()=>{let d=await o.apply(i,p);return d===false&&(d=await l.apply(i,p)),d})();let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c};}r.hooks=i;}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(a){let o=[];return o.push(s.call(this,a)),i&&(o=o.concat(i.call(this,a))),o};}this.defaults={...this.defaults,...r};}),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,r)=>{let i={...r},s={...this.defaults,...i},a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===true&&i.async===false)return a(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 a(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return (async()=>{let o=s.hooks?await s.hooks.preprocess(n):n,p=await(s.hooks?await s.hooks.provideLexer():e?x.lex:x.lexInline)(o,s),c=s.hooks?await s.hooks.processAllTokens(p):p;s.walkTokens&&await Promise.all(this.walkTokens(c,s.walkTokens));let h=await(s.hooks?await s.hooks.provideParser():e?b.parse:b.parseInline)(c,s);return s.hooks?await s.hooks.postprocess(h):h})().catch(a);try{s.hooks&&(n=s.hooks.preprocess(n));let l=(s.hooks?s.hooks.provideLexer():e?x.lex:x.lexInline)(n,s);s.hooks&&(l=s.hooks.processAllTokens(l)),s.walkTokens&&this.walkTokens(l,s.walkTokens);let c=(s.hooks?s.hooks.provideParser():e?b.parse:b.parseInline)(l,s);return s.hooks&&(c=s.hooks.postprocess(c)),c}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
19638
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+O(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var L=new B;function g(u,e){return L.parse(u,e)}g.options=g.setOptions=function(u){return L.setOptions(u),g.defaults=L.defaults,H(g.defaults),g};g.getDefaults=M;g.defaults=T;g.use=function(...u){return L.use(...u),g.defaults=L.defaults,H(g.defaults),g};g.walkTokens=function(u,e){return L.walkTokens(u,e)};g.parseInline=L.parseInline;g.Parser=b;g.parser=b.parse;g.Renderer=y;g.TextRenderer=$;g.Lexer=x;g.lexer=x.lex;g.Tokenizer=w;g.Hooks=P;g.parse=g;
21626
19639
 
21627
19640
  // src/Extension.ts
21628
19641
 
@@ -21632,10 +19645,10 @@ function wrapInMarkdownBlock(prefix, content) {
21632
19645
  const output = lines.flatMap((line) => [line, ""]).map((line) => `${prefix}${line}`).join("\n");
21633
19646
  return output.slice(0, output.length - 1);
21634
19647
  }
21635
- function findMarksToClose(activeMarks, currentMarks) {
19648
+ function findMarksToClose(currentMarks, nextNode) {
21636
19649
  const marksToClose = [];
21637
- Array.from(activeMarks.keys()).forEach((markType) => {
21638
- if (!currentMarks.has(markType)) {
19650
+ Array.from(currentMarks.keys()).forEach((markType) => {
19651
+ if (!nextNode || !nextNode.marks || !nextNode.marks.map((mark) => mark.type).includes(markType)) {
21639
19652
  marksToClose.push(markType);
21640
19653
  }
21641
19654
  });
@@ -21721,7 +19734,7 @@ var MarkdownManager = class {
21721
19734
  this.extensions = [];
21722
19735
  this.lastParseResult = null;
21723
19736
  var _a, _b, _c, _d, _e;
21724
- this.markedInstance = (_a = options == null ? void 0 : options.marked) != null ? _a : marked;
19737
+ this.markedInstance = (_a = options == null ? void 0 : options.marked) != null ? _a : g;
21725
19738
  this.lexer = new this.markedInstance.Lexer();
21726
19739
  this.indentStyle = (_c = (_b = options == null ? void 0 : options.indentation) == null ? void 0 : _b.style) != null ? _c : "space";
21727
19740
  this.indentSize = (_e = (_d = options == null ? void 0 : options.indentation) == null ? void 0 : _d.size) != null ? _e : 2;
@@ -21880,10 +19893,20 @@ var MarkdownManager = class {
21880
19893
  if (!docOrContent) {
21881
19894
  return "";
21882
19895
  }
21883
- if (Array.isArray(docOrContent)) {
21884
- return this.renderNodes(docOrContent, docOrContent);
19896
+ const result = this.renderNodes(docOrContent, docOrContent);
19897
+ return this.isEmptyOutput(result) ? "" : result;
19898
+ }
19899
+ /**
19900
+ * Check if the markdown output represents an empty document.
19901
+ * Empty documents may contain only &nbsp; entities or non-breaking space characters
19902
+ * which are used by the Paragraph extension to preserve blank lines.
19903
+ */
19904
+ isEmptyOutput(markdown) {
19905
+ if (!markdown || markdown.trim() === "") {
19906
+ return true;
21885
19907
  }
21886
- return this.renderNodes(docOrContent, docOrContent);
19908
+ const cleanedOutput = markdown.replace(/&nbsp;/g, "").replace(/\u00A0/g, "").trim();
19909
+ return cleanedOutput === "";
21887
19910
  }
21888
19911
  /**
21889
19912
  * Parse markdown string into Tiptap JSON document using registered extension handlers.
@@ -22258,6 +20281,23 @@ var MarkdownManager = class {
22258
20281
  if (!html.trim()) {
22259
20282
  return null;
22260
20283
  }
20284
+ if (typeof window === "undefined") {
20285
+ if (token.block) {
20286
+ return {
20287
+ type: "paragraph",
20288
+ content: [
20289
+ {
20290
+ type: "text",
20291
+ text: html
20292
+ }
20293
+ ]
20294
+ };
20295
+ }
20296
+ return {
20297
+ type: "text",
20298
+ text: html
20299
+ };
20300
+ }
22261
20301
  try {
22262
20302
  const parsed = generateJSON(html, this.baseExtensions);
22263
20303
  if (parsed.type === "doc" && parsed.content) {
@@ -22303,7 +20343,9 @@ var MarkdownManager = class {
22303
20343
  index,
22304
20344
  level,
22305
20345
  parentType: parentNode == null ? void 0 : parentNode.type,
22306
- meta: {}
20346
+ meta: {
20347
+ parentAttrs: parentNode == null ? void 0 : parentNode.attrs
20348
+ }
22307
20349
  };
22308
20350
  const rendered = ((_a = handler.renderMarkdown) == null ? void 0 : _a.call(handler, node, helpers, context)) || "";
22309
20351
  return rendered;
@@ -22336,15 +20378,25 @@ var MarkdownManager = class {
22336
20378
  if (node.type === "text") {
22337
20379
  let textContent = node.text || "";
22338
20380
  const currentMarks = new Map((node.marks || []).map((mark) => [mark.type, mark]));
22339
- const marksToClose = findMarksToClose(activeMarks, currentMarks);
22340
20381
  const marksToOpen = findMarksToOpen(activeMarks, currentMarks);
20382
+ const marksToClose = findMarksToClose(currentMarks, nextNode);
20383
+ let middleTrailingWhitespace = "";
20384
+ if (marksToClose.length > 0) {
20385
+ const middleTrailingMatch = textContent.match(/(\s+)$/);
20386
+ if (middleTrailingMatch) {
20387
+ middleTrailingWhitespace = middleTrailingMatch[1];
20388
+ textContent = textContent.slice(0, -middleTrailingWhitespace.length);
20389
+ }
20390
+ }
22341
20391
  marksToClose.forEach((markType) => {
22342
- const mark = activeMarks.get(markType);
20392
+ const mark = currentMarks.get(markType);
22343
20393
  const closeMarkdown = this.getMarkClosing(markType, mark);
22344
20394
  if (closeMarkdown) {
22345
20395
  textContent += closeMarkdown;
22346
20396
  }
22347
- activeMarks.delete(markType);
20397
+ if (activeMarks.has(markType)) {
20398
+ activeMarks.delete(markType);
20399
+ }
22348
20400
  });
22349
20401
  let leadingWhitespace = "";
22350
20402
  if (marksToOpen.length > 0) {
@@ -22359,7 +20411,9 @@ var MarkdownManager = class {
22359
20411
  if (openMarkdown) {
22360
20412
  textContent = openMarkdown + textContent;
22361
20413
  }
22362
- activeMarks.set(type, mark);
20414
+ if (!marksToClose.includes(type)) {
20415
+ activeMarks.set(type, mark);
20416
+ }
22363
20417
  });
22364
20418
  textContent = leadingWhitespace + textContent;
22365
20419
  const marksToCloseAtEnd = findMarksToCloseAtEnd(
@@ -22385,6 +20439,7 @@ var MarkdownManager = class {
22385
20439
  activeMarks.delete(markType);
22386
20440
  });
22387
20441
  textContent += trailingWhitespace;
20442
+ textContent += middleTrailingWhitespace;
22388
20443
  result.push(textContent);
22389
20444
  } else {
22390
20445
  const marksToReopen = new Map(activeMarks);
@@ -25281,31 +23336,33 @@ function clickHandler(options) {
25281
23336
  if (!view.editable) {
25282
23337
  return false;
25283
23338
  }
23339
+ let link = null;
23340
+ if (event.target instanceof HTMLAnchorElement) {
23341
+ link = event.target;
23342
+ } else {
23343
+ const target = event.target;
23344
+ if (!target) {
23345
+ return false;
23346
+ }
23347
+ const root = options.editor.view.dom;
23348
+ link = target.closest("a");
23349
+ if (link && !root.contains(link)) {
23350
+ link = null;
23351
+ }
23352
+ }
23353
+ if (!link) {
23354
+ return false;
23355
+ }
25284
23356
  let handled = false;
25285
23357
  if (options.enableClickSelection) {
25286
23358
  const commandResult = options.editor.commands.extendMarkRange(options.type.name);
25287
23359
  handled = commandResult;
25288
23360
  }
25289
23361
  if (options.openOnClick) {
25290
- let link = null;
25291
- if (event.target instanceof HTMLAnchorElement) {
25292
- link = event.target;
25293
- } else {
25294
- let a = event.target;
25295
- const els = [];
25296
- while (a.nodeName !== "DIV") {
25297
- els.push(a);
25298
- a = a.parentNode;
25299
- }
25300
- link = els.find((value) => value.nodeName === "A");
25301
- }
25302
- if (!link) {
25303
- return handled;
25304
- }
25305
23362
  const attrs = getAttributes(view.state, options.type.name);
25306
- const href = (_a = link == null ? void 0 : link.href) != null ? _a : attrs.href;
25307
- const target = (_b = link == null ? void 0 : link.target) != null ? _b : attrs.target;
25308
- if (link && href) {
23363
+ const href = (_a = link.href) != null ? _a : attrs.href;
23364
+ const target = (_b = link.target) != null ? _b : attrs.target;
23365
+ if (href) {
25309
23366
  window.open(href, target);
25310
23367
  handled = true;
25311
23368
  }
@@ -25334,7 +23391,7 @@ function pasteHandler(options) {
25334
23391
  const link = find(textContent, { defaultProtocol: options.defaultProtocol }).find(
25335
23392
  (item) => item.isLink && item.value === textContent
25336
23393
  );
25337
- if (!textContent || !link || shouldAutoLink !== void 0 && !shouldAutoLink(link.href)) {
23394
+ if (!textContent || !link || shouldAutoLink !== void 0 && !shouldAutoLink(link.value)) {
25338
23395
  return false;
25339
23396
  }
25340
23397
  return options.editor.commands.setMark(options.type, {
@@ -25401,7 +23458,22 @@ var Link = Mark.create({
25401
23458
  },
25402
23459
  isAllowedUri: (url, ctx) => !!isAllowedUri(url, ctx.protocols),
25403
23460
  validate: (url) => !!url,
25404
- shouldAutoLink: (url) => !!url
23461
+ shouldAutoLink: (url) => {
23462
+ const hasProtocol = /^[a-z][a-z0-9+.-]*:\/\//i.test(url);
23463
+ const hasMaybeProtocol = /^[a-z][a-z0-9+.-]*:/i.test(url);
23464
+ if (hasProtocol || hasMaybeProtocol && !url.includes("@")) {
23465
+ return true;
23466
+ }
23467
+ const urlWithoutUserinfo = url.includes("@") ? url.split("@").pop() : url;
23468
+ const hostname = urlWithoutUserinfo.split(/[/?#:]/)[0];
23469
+ if (/^\d{1,3}(\.\d{1,3}){3}$/.test(hostname)) {
23470
+ return false;
23471
+ }
23472
+ if (!/\./.test(hostname)) {
23473
+ return false;
23474
+ }
23475
+ return true;
23476
+ }
25405
23477
  };
25406
23478
  },
25407
23479
  addAttributes() {
@@ -25420,6 +23492,9 @@ var Link = Mark.create({
25420
23492
  },
25421
23493
  class: {
25422
23494
  default: this.options.HTMLAttributes.class
23495
+ },
23496
+ title: {
23497
+ default: null
25423
23498
  }
25424
23499
  };
25425
23500
  },
@@ -25459,10 +23534,11 @@ var Link = Mark.create({
25459
23534
  });
25460
23535
  },
25461
23536
  renderMarkdown: (node, h) => {
25462
- var _a;
25463
- const href = ((_a = node.attrs) == null ? void 0 : _a.href) || "";
23537
+ var _a, _b, _c, _d;
23538
+ const href = (_b = (_a = node.attrs) == null ? void 0 : _a.href) != null ? _b : "";
23539
+ const title = (_d = (_c = node.attrs) == null ? void 0 : _c.title) != null ? _d : "";
25464
23540
  const text = h.renderChildren(node);
25465
- return `[${text}](${href})`;
23541
+ return title ? `[${text}](${href} "${title}")` : `[${text}](${href})`;
25466
23542
  },
25467
23543
  addCommands() {
25468
23544
  return {
@@ -25727,11 +23803,13 @@ var ListItem = Node3.create({
25727
23803
  node,
25728
23804
  h,
25729
23805
  (context) => {
23806
+ var _a, _b;
25730
23807
  if (context.parentType === "bulletList") {
25731
23808
  return "- ";
25732
23809
  }
25733
23810
  if (context.parentType === "orderedList") {
25734
- return `${context.index + 1}. `;
23811
+ const start = ((_b = (_a = context.meta) == null ? void 0 : _a.parentAttrs) == null ? void 0 : _b.start) || 1;
23812
+ return `${start + context.index}. `;
25735
23813
  }
25736
23814
  return "- ";
25737
23815
  },
@@ -26414,6 +24492,7 @@ var TaskItem = Node3.create({
26414
24492
  Object.entries(HTMLAttributes).forEach(([key, value]) => {
26415
24493
  listItem.setAttribute(key, value);
26416
24494
  });
24495
+ let prevRenderedAttributeKeys = new Set(Object.keys(HTMLAttributes));
26417
24496
  return {
26418
24497
  dom: listItem,
26419
24498
  contentDOM: content,
@@ -26424,6 +24503,31 @@ var TaskItem = Node3.create({
26424
24503
  listItem.dataset.checked = updatedNode.attrs.checked;
26425
24504
  checkbox.checked = updatedNode.attrs.checked;
26426
24505
  updateA11Y(updatedNode);
24506
+ const extensionAttributes = editor.extensionManager.attributes;
24507
+ const newHTMLAttributes = getRenderedAttributes(updatedNode, extensionAttributes);
24508
+ const newKeys = new Set(Object.keys(newHTMLAttributes));
24509
+ const staticAttrs = this.options.HTMLAttributes;
24510
+ prevRenderedAttributeKeys.forEach((key) => {
24511
+ if (!newKeys.has(key)) {
24512
+ if (key in staticAttrs) {
24513
+ listItem.setAttribute(key, staticAttrs[key]);
24514
+ } else {
24515
+ listItem.removeAttribute(key);
24516
+ }
24517
+ }
24518
+ });
24519
+ Object.entries(newHTMLAttributes).forEach(([key, value]) => {
24520
+ if (value === null || value === void 0) {
24521
+ if (key in staticAttrs) {
24522
+ listItem.setAttribute(key, staticAttrs[key]);
24523
+ } else {
24524
+ listItem.removeAttribute(key);
24525
+ }
24526
+ } else {
24527
+ listItem.setAttribute(key, value);
24528
+ }
24529
+ });
24530
+ prevRenderedAttributeKeys = newKeys;
26427
24531
  return true;
26428
24532
  }
26429
24533
  };
@@ -26597,6 +24701,8 @@ Extension.create({
26597
24701
  });
26598
24702
 
26599
24703
  // src/paragraph.ts
24704
+ var EMPTY_PARAGRAPH_MARKDOWN = "&nbsp;";
24705
+ var NBSP_CHAR = "\xA0";
26600
24706
  var Paragraph = Node3.create({
26601
24707
  name: "paragraph",
26602
24708
  priority: 1e3,
@@ -26618,18 +24724,21 @@ var Paragraph = Node3.create({
26618
24724
  if (tokens.length === 1 && tokens[0].type === "image") {
26619
24725
  return helpers.parseChildren([tokens[0]]);
26620
24726
  }
26621
- return helpers.createNode(
26622
- "paragraph",
26623
- void 0,
26624
- // no attributes for paragraph
26625
- helpers.parseInline(tokens)
26626
- );
24727
+ const content = helpers.parseInline(tokens);
24728
+ if (content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
24729
+ return helpers.createNode("paragraph", void 0, []);
24730
+ }
24731
+ return helpers.createNode("paragraph", void 0, content);
26627
24732
  },
26628
24733
  renderMarkdown: (node, h) => {
26629
- if (!node || !Array.isArray(node.content)) {
24734
+ if (!node) {
26630
24735
  return "";
26631
24736
  }
26632
- return h.renderChildren(node.content);
24737
+ const content = Array.isArray(node.content) ? node.content : [];
24738
+ if (content.length === 0) {
24739
+ return EMPTY_PARAGRAPH_MARKDOWN;
24740
+ }
24741
+ return h.renderChildren(content);
26633
24742
  },
26634
24743
  addCommands() {
26635
24744
  return {
@@ -27976,12 +26085,17 @@ var Gapcursor = Extension.create({
27976
26085
  };
27977
26086
  }
27978
26087
  });
26088
+ var DEFAULT_DATA_ATTRIBUTE = "placeholder";
26089
+ function preparePlaceholderAttribute(attr) {
26090
+ return attr.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
26091
+ }
27979
26092
  Extension.create({
27980
26093
  name: "placeholder",
27981
26094
  addOptions() {
27982
26095
  return {
27983
26096
  emptyEditorClass: "is-editor-empty",
27984
26097
  emptyNodeClass: "is-empty",
26098
+ dataAttribute: DEFAULT_DATA_ATTRIBUTE,
27985
26099
  placeholder: "Write something \u2026",
27986
26100
  showOnlyWhenEditable: true,
27987
26101
  showOnlyCurrent: true,
@@ -27989,6 +26103,7 @@ Extension.create({
27989
26103
  };
27990
26104
  },
27991
26105
  addProseMirrorPlugins() {
26106
+ const dataAttribute = this.options.dataAttribute ? `data-${preparePlaceholderAttribute(this.options.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;
27992
26107
  return [
27993
26108
  new Plugin({
27994
26109
  key: new PluginKey("placeholder"),
@@ -28011,7 +26126,7 @@ Extension.create({
28011
26126
  }
28012
26127
  const decoration = Decoration.node(pos, pos + node.nodeSize, {
28013
26128
  class: classes.join(" "),
28014
- "data-placeholder": typeof this.options.placeholder === "function" ? this.options.placeholder({
26129
+ [dataAttribute]: typeof this.options.placeholder === "function" ? this.options.placeholder({
28015
26130
  editor: this.editor,
28016
26131
  node,
28017
26132
  pos,