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