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