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