@8wave/ai-elements 0.112.0 → 0.114.0-beta.14
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/_chunks/Agent-D3ODaN3E.js +566 -0
- package/dist/_chunks/Agent-D3ODaN3E.js.map +1 -0
- package/dist/_chunks/{PkStreamingMarkdown-CRlRDGYl.js → PkStreamingMarkdown-CYOm47PX.js} +1276 -453
- package/dist/_chunks/PkStreamingMarkdown-CYOm47PX.js.map +1 -0
- package/dist/_chunks/{PkToolRequestGeolocation-BbxYKt-9.js → PkToolRequestGeolocation-BY7nXImb.js} +2 -2
- package/dist/_chunks/{PkToolRequestGeolocation-BbxYKt-9.js.map → PkToolRequestGeolocation-BY7nXImb.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-CTp2w60F.js → PkToolRequestOAuthConnection-DFOTALFt.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-CTp2w60F.js.map → PkToolRequestOAuthConnection-DFOTALFt.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-CNnt82aH.js → PkToolShowArtifact-DzHRWoru.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-CNnt82aH.js.map → PkToolShowArtifact-DzHRWoru.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-D77gyjQG.js → PkToolShowContactForm-1J6_1AA2.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-D77gyjQG.js.map → PkToolShowContactForm-1J6_1AA2.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-DP4LLAk3.js → PkToolShowForm-DmQYj3v1.js} +5 -5
- package/dist/_chunks/{PkToolShowForm-DP4LLAk3.js.map → PkToolShowForm-DmQYj3v1.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-Bwy0Ptmi.js → PkToolShowSources-BO8V5rlS.js} +3 -3
- package/dist/_chunks/{PkToolShowSources-Bwy0Ptmi.js.map → PkToolShowSources-BO8V5rlS.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-CFO8wV1b.js → PkToolShowSuggestedReply-CTWVG1Zk.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-CFO8wV1b.js.map → PkToolShowSuggestedReply-CTWVG1Zk.js.map} +1 -1
- package/dist/_chunks/{markdown-BRD-hDrH.js → markdown-JpLFzufn.js} +7 -7
- package/dist/_chunks/{markdown-BRD-hDrH.js.map → markdown-JpLFzufn.js.map} +1 -1
- package/dist/_chunks/url-validation-uLMZ5-AU.js.map +1 -1
- package/dist/ai-elements.es.js +2741 -2733
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotStepPayload.js +1 -1
- package/dist-vue/PkChatbotStepToolDetail.js +1 -1
- package/dist-vue/PkChatbotSteps.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/_chunks/Media-_HfFLHGD.js.map +1 -1
- package/dist-vue/_chunks/{PkChatbot-C11EVHnI.js → PkChatbot-BdvDl_Gw.js} +4 -4
- package/dist-vue/_chunks/{PkChatbot-C11EVHnI.js.map → PkChatbot-BdvDl_Gw.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-CacY4o02.js → PkChatbotEmptyState-DycCrfwz.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-CacY4o02.js.map → PkChatbotEmptyState-DycCrfwz.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-Dkz3SNAk.js → PkChatbotInput-BCuqLdkT.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotInput-Dkz3SNAk.js.map → PkChatbotInput-BCuqLdkT.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotMessages-PjKRDNYJ.js +776 -0
- package/dist-vue/_chunks/PkChatbotMessages-PjKRDNYJ.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotStepPayload-DU0W-eUp.js → PkChatbotStepPayload-CI98RiNv.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-DU0W-eUp.js.map → PkChatbotStepPayload-CI98RiNv.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-etlBryOg.js → PkChatbotStepToolDetail-B8zXJOdI.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-etlBryOg.js.map → PkChatbotStepToolDetail-B8zXJOdI.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotSteps-CL27pMFS.js +190 -0
- package/dist-vue/_chunks/{PkChatbotSteps-jW07Q-4x.js.map → PkChatbotSteps-CL27pMFS.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-DJnjuhjt.js → PkChatbotViewChat-CS-OSJfX.js} +6 -6
- package/dist-vue/_chunks/{PkChatbotViewChat-DJnjuhjt.js.map → PkChatbotViewChat-CS-OSJfX.js.map} +1 -1
- package/dist-vue/_chunks/PkStreamingMarkdown-B2iju0WK.js +3245 -0
- package/dist-vue/_chunks/PkStreamingMarkdown-B2iju0WK.js.map +1 -0
- package/dist-vue/_chunks/{PkToolShowArtifact-BnwU7CV2.js → PkToolShowArtifact-C0J71YF6.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-BnwU7CV2.js.map → PkToolShowArtifact-C0J71YF6.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-_x_dbiHn.js → PkToolShowContactForm-De3Od9mC.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-_x_dbiHn.js.map → PkToolShowContactForm-De3Od9mC.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-RtkI_sKL.js → PkToolShowDiagram-DmY_hhAS.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-RtkI_sKL.js.map → PkToolShowDiagram-DmY_hhAS.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowEmail-CRQjoJr1.js → PkToolShowEmail-D_Z15wCS.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowEmail-CRQjoJr1.js.map → PkToolShowEmail-D_Z15wCS.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-IPAkJIXh.js → PkToolShowForm-DUGysIxj.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowForm-IPAkJIXh.js.map → PkToolShowForm-DUGysIxj.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowMessage-joTzAg9N.js → PkToolShowMessage-e5_EI5mV.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowMessage-joTzAg9N.js.map → PkToolShowMessage-e5_EI5mV.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-tOYjd2bq.js → PkToolShowProductList-B3X7Svyc.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-tOYjd2bq.js.map → PkToolShowProductList-B3X7Svyc.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-gI947JOm.js → PkToolShowSources-BUjBSGc5.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowSources-gI947JOm.js.map → PkToolShowSources-BUjBSGc5.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-D3Xy4iUs.js → PkToolShowWebPages-DEih8h5k.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-D3Xy4iUs.js.map → PkToolShowWebPages-DEih8h5k.js.map} +1 -1
- package/dist-vue/_chunks/{PkUrl-BgMBemSz.js → PkUrl-3NH9t-WA.js} +2 -2
- package/dist-vue/_chunks/{PkUrl-BgMBemSz.js.map → PkUrl-3NH9t-WA.js.map} +1 -1
- package/dist-vue/_chunks/url-validation-uLMZ5-AU.js.map +1 -1
- package/dist-vue/_chunks/utils-BL4Ppr2R.js +184 -0
- package/dist-vue/_chunks/utils-BL4Ppr2R.js.map +1 -0
- package/dist-vue/apps/web-component/src/composables/useChatbotAuth.d.ts +1 -3
- package/dist-vue/composables.js +102 -93
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +26 -26
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/packages/auth/src/social-redirect-plugin.d.ts +18 -12
- package/dist-vue/packages/components/src/chat/markdownHtml.d.ts +20 -0
- package/dist-vue/packages/components/src/chat/utils.d.ts +9 -0
- package/dist-vue/packages/models/src/schema/AgentApiTool.d.ts +70 -0
- package/dist-vue/packages/models/src/schema/Lead.d.ts +13 -0
- package/dist-vue/packages/models/src/schema/Media.d.ts +0 -1
- package/dist-vue/packages/models/src/schema/ModelProvider.d.ts +1 -1
- package/package.json +2 -1
- package/dist/_chunks/Agent-DTLrWpzX.js +0 -460
- package/dist/_chunks/Agent-DTLrWpzX.js.map +0 -1
- package/dist/_chunks/Media-Cft7Pwrh.js +0 -108
- package/dist/_chunks/Media-Cft7Pwrh.js.map +0 -1
- package/dist/_chunks/PkStreamingMarkdown-CRlRDGYl.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotMessages-BD-vUak6.js +0 -776
- package/dist-vue/_chunks/PkChatbotMessages-BD-vUak6.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotSteps-jW07Q-4x.js +0 -190
- package/dist-vue/_chunks/PkStreamingMarkdown-BoEpwaYQ.js +0 -2430
- package/dist-vue/_chunks/PkStreamingMarkdown-BoEpwaYQ.js.map +0 -1
- package/dist-vue/_chunks/utils-h4C7rRcu.js +0 -177
- package/dist-vue/_chunks/utils-h4C7rRcu.js.map +0 -1
|
@@ -1,2430 +0,0 @@
|
|
|
1
|
-
import { n as e, t } from "./cdn-css-JUUNhyQ6.js";
|
|
2
|
-
import "./src-DT8FLE4_.js";
|
|
3
|
-
import { n } from "./url-validation-uLMZ5-AU.js";
|
|
4
|
-
import { c as r } from "./utils-h4C7rRcu.js";
|
|
5
|
-
import { computed as i, createElementBlock as a, defineComponent as o, inject as s, nextTick as c, onBeforeUnmount as l, onMounted as u, openBlock as d, provide as f, reactive as p, toRef as m, toValue as h, useTemplateRef as ee, watch as g } from "vue";
|
|
6
|
-
import { useI18n as te } from "vue-i18n";
|
|
7
|
-
import { refThrottled as ne } from "@vueuse/core";
|
|
8
|
-
//#region ../../packages/utils/src/citations.ts
|
|
9
|
-
var re = /[ \t]*\uE200[^\uE201]*\uE201/g, ie = /[ \t]*(?:cite|filecite|videocite|audiocite|imagecite|screenshot)(?:turn\d+[a-z]+\d+)+/gi, ae = /[\uE200-\uE20F]/g;
|
|
10
|
-
function oe(e) {
|
|
11
|
-
return e && e.replace(re, "").replace(ie, "").replace(ae, "");
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region ../../packages/composable/src/chatbot/useShortUrlResolver.ts
|
|
15
|
-
var se = /\/api\/r\/([A-Za-z0-9_-]{1,20})(?:[?#]|$)/, ce = /https?:\/\/[^\s)"'<>]*\/api\/r\/([A-Za-z0-9_-]{1,20})/g;
|
|
16
|
-
function _(e) {
|
|
17
|
-
return se.exec(e)?.[1];
|
|
18
|
-
}
|
|
19
|
-
function v(e) {
|
|
20
|
-
let t = p(/* @__PURE__ */ new Map()), n = p(/* @__PURE__ */ new Set()), r = /* @__PURE__ */ new Set(), a = !1;
|
|
21
|
-
async function o() {
|
|
22
|
-
a = !1;
|
|
23
|
-
let i = [...r];
|
|
24
|
-
if (r.clear(), i.length !== 0) try {
|
|
25
|
-
let n = await e(i);
|
|
26
|
-
for (let [e, r] of Object.entries(n)) t.set(e, r);
|
|
27
|
-
} catch {} finally {
|
|
28
|
-
for (let e of i) n.add(e);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function s(e) {
|
|
32
|
-
t.has(e) || r.has(e) || (r.add(e), a || (a = !0, queueMicrotask(o)));
|
|
33
|
-
}
|
|
34
|
-
function c(e) {
|
|
35
|
-
return i(() => {
|
|
36
|
-
let r = h(e), i = r ? _(r) : void 0;
|
|
37
|
-
if (!i) return {
|
|
38
|
-
url: r,
|
|
39
|
-
loading: !1
|
|
40
|
-
};
|
|
41
|
-
let a = t.get(i);
|
|
42
|
-
return a === void 0 ? (s(i), {
|
|
43
|
-
url: r,
|
|
44
|
-
loading: !n.has(i)
|
|
45
|
-
}) : {
|
|
46
|
-
url: a,
|
|
47
|
-
loading: !1
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function l(e) {
|
|
52
|
-
return i(() => {
|
|
53
|
-
let n = h(e) ?? "";
|
|
54
|
-
return n && n.replace(ce, (e, n) => {
|
|
55
|
-
let r = t.get(n);
|
|
56
|
-
return r === void 0 ? (s(n), e) : r;
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
resolve: c,
|
|
62
|
-
resolveText: l
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
var y = Symbol("shortUrlResolver");
|
|
66
|
-
function le(e) {
|
|
67
|
-
let t = v(e);
|
|
68
|
-
return f(y, t), t;
|
|
69
|
-
}
|
|
70
|
-
var ue = {
|
|
71
|
-
resolve: (e) => i(() => ({
|
|
72
|
-
url: h(e),
|
|
73
|
-
loading: !1
|
|
74
|
-
})),
|
|
75
|
-
resolveText: (e) => i(() => h(e) ?? "")
|
|
76
|
-
};
|
|
77
|
-
function de() {
|
|
78
|
-
return s(y, ue);
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region ../../node_modules/.pnpm/remend@1.3.1/node_modules/remend/dist/index.js
|
|
82
|
-
var fe = Object.defineProperty, pe = Object.defineProperties, me = Object.getOwnPropertyDescriptors, b = Object.getOwnPropertySymbols, he = Object.prototype.hasOwnProperty, ge = Object.prototype.propertyIsEnumerable, _e = (e, t, n) => t in e ? fe(e, t, {
|
|
83
|
-
enumerable: !0,
|
|
84
|
-
configurable: !0,
|
|
85
|
-
writable: !0,
|
|
86
|
-
value: n
|
|
87
|
-
}) : e[t] = n, ve = (e, t) => {
|
|
88
|
-
for (var n in t ||= {}) he.call(t, n) && _e(e, n, t[n]);
|
|
89
|
-
if (b) for (var n of b(t)) ge.call(t, n) && _e(e, n, t[n]);
|
|
90
|
-
return e;
|
|
91
|
-
}, x = (e, t) => pe(e, me(t)), ye = (e) => {
|
|
92
|
-
let t = new Uint8Array(e.length + 1), n = !1, r = !1, i = 0;
|
|
93
|
-
for (; i < e.length;) {
|
|
94
|
-
if (e[i] === "\\" && i + 1 < e.length && e[i + 1] === "`") {
|
|
95
|
-
let e = n || r ? 1 : 0;
|
|
96
|
-
t[i + 1] = e, t[i + 2] = e, i += 2;
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (e.substring(i, i + 3) === "```") {
|
|
100
|
-
r = !r;
|
|
101
|
-
let a = n || r ? 1 : 0, o = Math.min(i + 3, e.length);
|
|
102
|
-
for (let e = i + 1; e <= o; e += 1) t[e] = a;
|
|
103
|
-
i = o;
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
!r && e[i] === "`" && (n = !n), t[i + 1] = n || r ? 1 : 0, i += 1;
|
|
107
|
-
}
|
|
108
|
-
return t;
|
|
109
|
-
}, be = null, S = (e, t) => {
|
|
110
|
-
let n = be;
|
|
111
|
-
return (n === null || n.text !== e) && (n = {
|
|
112
|
-
text: e,
|
|
113
|
-
lookup: ye(e)
|
|
114
|
-
}, be = n), n.lookup[Math.min(t, e.length)] === 1;
|
|
115
|
-
}, xe = (e, t) => {
|
|
116
|
-
let n = e.substring(t, t + 3) === "```", r = t > 0 && e.substring(t - 1, t + 2) === "```", i = t > 1 && e.substring(t - 2, t + 1) === "```";
|
|
117
|
-
return n || r || i;
|
|
118
|
-
}, Se = (e) => {
|
|
119
|
-
let t = 0;
|
|
120
|
-
for (let n = 0; n < e.length; n += 1) {
|
|
121
|
-
if (e[n] === "\\" && n + 1 < e.length && e[n + 1] === "`") {
|
|
122
|
-
n += 1;
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
e[n] === "`" && !xe(e, n) && (t += 1);
|
|
126
|
-
}
|
|
127
|
-
return t;
|
|
128
|
-
}, C = (e, t) => {
|
|
129
|
-
let n = !1, r = !1, i = -1;
|
|
130
|
-
for (let a = 0; a < e.length; a += 1) {
|
|
131
|
-
if (e[a] === "\\" && a + 1 < e.length && e[a + 1] === "`") {
|
|
132
|
-
a += 1;
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (e.substring(a, a + 3) === "```") {
|
|
136
|
-
r = !r, a += 2;
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
if (!r && e[a] === "`") {
|
|
140
|
-
if (n) {
|
|
141
|
-
if (i < t && t < a) return !0;
|
|
142
|
-
n = !1, i = -1;
|
|
143
|
-
} else n = !0, i = a;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return !1;
|
|
147
|
-
}, Ce = /^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm, w = (e) => !e || typeof e != "string" || !e.includes(">") ? e : e.replace(Ce, (t, n, r, i) => S(e, i) ? t : `${n}\\>${r}`), we = /(\*\*)([^*]*\*?)$/, Te = /(__)([^_]*?)$/, Ee = /(\*\*\*)([^*]*?)$/, De = /(\*)([^*]*?)$/, Oe = /(_)([^_]*?)$/, ke = /(`)([^`]*?)$/, Ae = /(~~)([^~]*?)$/, T = /^[\s_~*`]*$/, je = /^[\s]*[-*+][\s]+$/, Me = /[\p{L}\p{N}_]/u, Ne = /^```[^`\n]*```?$/, Pe = /^\*{4,}$/, Fe = /(__)([^_]+)_$/, Ie = /(~~)([^~]+)~$/, Le = /~~/g, E = (e) => {
|
|
148
|
-
if (!e) return !1;
|
|
149
|
-
let t = e.charCodeAt(0);
|
|
150
|
-
return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || t === 95 || Me.test(e);
|
|
151
|
-
}, Re = (e, t) => {
|
|
152
|
-
let n = 1;
|
|
153
|
-
for (let r = t - 1; r >= 0; --r) if (e[r] === "]") n += 1;
|
|
154
|
-
else if (e[r] === "[" && (--n, n === 0)) return r;
|
|
155
|
-
return -1;
|
|
156
|
-
}, ze = (e, t) => {
|
|
157
|
-
let n = 1;
|
|
158
|
-
for (let r = t + 1; r < e.length; r += 1) if (e[r] === "[") n += 1;
|
|
159
|
-
else if (e[r] === "]" && (--n, n === 0)) return r;
|
|
160
|
-
return -1;
|
|
161
|
-
}, Be = (e) => e === "inlineLatex" || e === "blockLatex", Ve = (e, t) => t === "[" && e === "none" ? "blockLatex" : t === "]" && e === "blockLatex" ? "none" : t === "(" && e === "none" ? "inlineLatex" : t === ")" && e === "inlineLatex" ? "none" : null, He = (e, t) => t ? e === "blockDollar" ? "none" : "blockDollar" : e === "blockDollar" ? e : e === "inlineDollar" ? "none" : "inlineDollar", D = (e, t) => {
|
|
162
|
-
let n = "none";
|
|
163
|
-
for (let r = 0; r < e.length && r < t; r += 1) {
|
|
164
|
-
if (e[r] === "\\" && e[r + 1] === "$") {
|
|
165
|
-
r += 1;
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
if (e[r] === "\\") {
|
|
169
|
-
let t = Ve(n, e[r + 1]);
|
|
170
|
-
if (t !== null) {
|
|
171
|
-
n = t, r += 1;
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (e[r] === "$" && !Be(n)) {
|
|
176
|
-
let t = e[r + 1] === "$";
|
|
177
|
-
n = He(n, t), t && (r += 1);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return n !== "none";
|
|
181
|
-
}, Ue = (e, t) => {
|
|
182
|
-
for (let n = t; n < e.length; n += 1) {
|
|
183
|
-
if (e[n] === ")") return !0;
|
|
184
|
-
if (e[n] === "\n") return !1;
|
|
185
|
-
}
|
|
186
|
-
return !1;
|
|
187
|
-
}, We = (e, t) => {
|
|
188
|
-
for (let n = t - 1; n >= 0; --n) {
|
|
189
|
-
if (e[n] === ")") return !1;
|
|
190
|
-
if (e[n] === "(") return n > 0 && e[n - 1] === "]" && Ue(e, t);
|
|
191
|
-
if (e[n] === "\n") return !1;
|
|
192
|
-
}
|
|
193
|
-
return !1;
|
|
194
|
-
}, Ge = (e, t) => {
|
|
195
|
-
for (let n = t - 1; n >= 0; --n) {
|
|
196
|
-
if (e[n] === ">") return !1;
|
|
197
|
-
if (e[n] === "<") {
|
|
198
|
-
let t = n + 1 < e.length ? e[n + 1] : "";
|
|
199
|
-
return t >= "a" && t <= "z" || t >= "A" && t <= "Z" || t === "/";
|
|
200
|
-
}
|
|
201
|
-
if (e[n] === "\n") return !1;
|
|
202
|
-
}
|
|
203
|
-
return !1;
|
|
204
|
-
}, O = (e, t, n) => {
|
|
205
|
-
let r = 0;
|
|
206
|
-
for (let n = t - 1; n >= 0; --n) if (e[n] === "\n") {
|
|
207
|
-
r = n + 1;
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
let i = e.length;
|
|
211
|
-
for (let n = t; n < e.length; n += 1) if (e[n] === "\n") {
|
|
212
|
-
i = n;
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
let a = e.substring(r, i), o = 0, s = !1;
|
|
216
|
-
for (let e of a) if (e === n) o += 1;
|
|
217
|
-
else if (e !== " " && e !== " ") {
|
|
218
|
-
s = !0;
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
return o >= 3 && !s;
|
|
222
|
-
}, Ke = (e) => e.includes("$") || e.includes("\\(") || e.includes("\\["), qe = (e, t, n, r) => n === "\\" || Ke(e) && D(e, t) ? !0 : n !== "*" && r === "*" ? (t < e.length - 2 ? e[t + 2] : "") !== "*" : n === "*" || (!n || n === " " || n === " " || n === "\n") && (!r || r === " " || r === " " || r === "\n"), k = (e) => e === " " || e === " " || e === "\n", Je = (e, t) => !!(e && t && E(e) && E(t)), Ye = (e, t, n, r) => {
|
|
223
|
-
let i = Je(e, t), a = !!t && !k(t), o = !!e && !k(e);
|
|
224
|
-
return i && n % 2 == 0 && !r ? { count: !1 } : o && n % 2 == 1 || a ? {
|
|
225
|
-
count: !0,
|
|
226
|
-
inWordAsteriskChain: i
|
|
227
|
-
} : { count: !1 };
|
|
228
|
-
}, Xe = (e) => {
|
|
229
|
-
let t = 0, n = !1, r = !1, i = e.length;
|
|
230
|
-
for (let a = 0; a < i; a += 1) {
|
|
231
|
-
if (e[a] === "`" && a + 2 < i && e[a + 1] === "`" && e[a + 2] === "`") {
|
|
232
|
-
n = !n, a += 2;
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (n) continue;
|
|
236
|
-
if (e[a] !== "*") {
|
|
237
|
-
E(e[a]) || (r = !1);
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
let o = a > 0 ? e[a - 1] : "", s = a < i - 1 ? e[a + 1] : "";
|
|
241
|
-
if (qe(e, a, o, s)) continue;
|
|
242
|
-
let c = Ye(o, s, t, r);
|
|
243
|
-
c.count && (t += 1, r = c.inWordAsteriskChain);
|
|
244
|
-
}
|
|
245
|
-
return t;
|
|
246
|
-
}, Ze = (e, t, n, r) => !!(n === "\\" || Ke(e) && D(e, t) || We(e, t) || Ge(e, t) || n === "_" || r === "_" || n && r && E(n) && E(r)), Qe = (e) => {
|
|
247
|
-
let t = 0, n = !1, r = e.length;
|
|
248
|
-
for (let i = 0; i < r; i += 1) {
|
|
249
|
-
if (e[i] === "`" && i + 2 < r && e[i + 1] === "`" && e[i + 2] === "`") {
|
|
250
|
-
n = !n, i += 2;
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
if (n || e[i] !== "_") continue;
|
|
254
|
-
let a = i > 0 ? e[i - 1] : "", o = i < r - 1 ? e[i + 1] : "";
|
|
255
|
-
Ze(e, i, a, o) || (t += 1);
|
|
256
|
-
}
|
|
257
|
-
return t;
|
|
258
|
-
}, $e = (e) => {
|
|
259
|
-
let t = 0, n = 0, r = !1;
|
|
260
|
-
for (let i = 0; i < e.length; i += 1) {
|
|
261
|
-
if (e[i] === "`" && i + 2 < e.length && e[i + 1] === "`" && e[i + 2] === "`") {
|
|
262
|
-
n >= 3 && (t += Math.floor(n / 3)), n = 0, r = !r, i += 2;
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
r || (e[i] === "*" ? n += 1 : (n >= 3 && (t += Math.floor(n / 3)), n = 0));
|
|
266
|
-
}
|
|
267
|
-
return n >= 3 && (t += Math.floor(n / 3)), t;
|
|
268
|
-
}, et = (e) => {
|
|
269
|
-
let t = 0, n = !1;
|
|
270
|
-
for (let r = 0; r < e.length; r += 1) {
|
|
271
|
-
if (e[r] === "`" && r + 2 < e.length && e[r + 1] === "`" && e[r + 2] === "`") {
|
|
272
|
-
n = !n, r += 2;
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
n || e[r] === "*" && r + 1 < e.length && e[r + 1] === "*" && (t += 1, r += 1);
|
|
276
|
-
}
|
|
277
|
-
return t;
|
|
278
|
-
}, tt = (e) => {
|
|
279
|
-
let t = 0, n = !1;
|
|
280
|
-
for (let r = 0; r < e.length; r += 1) {
|
|
281
|
-
if (e[r] === "`" && r + 2 < e.length && e[r + 1] === "`" && e[r + 2] === "`") {
|
|
282
|
-
n = !n, r += 2;
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
n || e[r] === "_" && r + 1 < e.length && e[r + 1] === "_" && (t += 1, r += 1);
|
|
286
|
-
}
|
|
287
|
-
return t;
|
|
288
|
-
}, nt = (e, t, n) => {
|
|
289
|
-
if (!t || T.test(t)) return !0;
|
|
290
|
-
let r = e.substring(0, n).lastIndexOf("\n"), i = r === -1 ? 0 : r + 1, a = e.substring(i, n);
|
|
291
|
-
return je.test(a) && t.includes("\n") ? !0 : O(e, n, "*");
|
|
292
|
-
}, rt = (e) => {
|
|
293
|
-
let t = e.match(we);
|
|
294
|
-
if (!t) return e;
|
|
295
|
-
let n = t[2], r = e.lastIndexOf(t[1]);
|
|
296
|
-
return S(e, r) || C(e, r) || nt(e, n, r) ? e : et(e) % 2 == 1 ? n.endsWith("*") ? `${e}*` : `${e}**` : e;
|
|
297
|
-
}, it = (e, t, n) => {
|
|
298
|
-
if (!t || T.test(t)) return !0;
|
|
299
|
-
let r = e.substring(0, n).lastIndexOf("\n"), i = r === -1 ? 0 : r + 1, a = e.substring(i, n);
|
|
300
|
-
return je.test(a) && t.includes("\n") ? !0 : O(e, n, "_");
|
|
301
|
-
}, at = (e) => {
|
|
302
|
-
let t = e.match(Te);
|
|
303
|
-
if (!t) {
|
|
304
|
-
let t = e.match(Fe);
|
|
305
|
-
if (t) {
|
|
306
|
-
let n = e.lastIndexOf(t[1]);
|
|
307
|
-
if (!(S(e, n) || C(e, n)) && tt(e) % 2 == 1) return `${e}_`;
|
|
308
|
-
}
|
|
309
|
-
return e;
|
|
310
|
-
}
|
|
311
|
-
let n = t[2], r = e.lastIndexOf(t[1]);
|
|
312
|
-
return S(e, r) || C(e, r) || it(e, n, r) ? e : tt(e) % 2 == 1 ? `${e}__` : e;
|
|
313
|
-
}, ot = (e) => {
|
|
314
|
-
let t = !1;
|
|
315
|
-
for (let n = 0; n < e.length; n += 1) {
|
|
316
|
-
if (e[n] === "`" && n + 2 < e.length && e[n + 1] === "`" && e[n + 2] === "`") {
|
|
317
|
-
t = !t, n += 2;
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
if (!t && e[n] === "*" && e[n - 1] !== "*" && e[n + 1] !== "*" && e[n - 1] !== "\\" && !D(e, n)) {
|
|
321
|
-
let t = n > 0 ? e[n - 1] : "", r = n < e.length - 1 ? e[n + 1] : "", i = !t || k(t), a = !r || k(r);
|
|
322
|
-
if (i && a || t && r && E(t) && E(r) || a) continue;
|
|
323
|
-
return n;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return -1;
|
|
327
|
-
}, st = (e) => {
|
|
328
|
-
if (!e.match(De)) return e;
|
|
329
|
-
let t = ot(e);
|
|
330
|
-
if (t === -1 || S(e, t) || C(e, t)) return e;
|
|
331
|
-
let n = e.substring(t + 1);
|
|
332
|
-
return !n || T.test(n) ? e : Xe(e) % 2 == 1 ? `${e}*` : e;
|
|
333
|
-
}, ct = (e) => {
|
|
334
|
-
let t = !1;
|
|
335
|
-
for (let n = 0; n < e.length; n += 1) {
|
|
336
|
-
if (e[n] === "`" && n + 2 < e.length && e[n + 1] === "`" && e[n + 2] === "`") {
|
|
337
|
-
t = !t, n += 2;
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
|
-
if (!t && e[n] === "_" && e[n - 1] !== "_" && e[n + 1] !== "_" && e[n - 1] !== "\\" && !D(e, n) && !We(e, n)) {
|
|
341
|
-
let t = n > 0 ? e[n - 1] : "", r = n < e.length - 1 ? e[n + 1] : "";
|
|
342
|
-
if (t && r && E(t) && E(r)) continue;
|
|
343
|
-
return n;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return -1;
|
|
347
|
-
}, lt = (e) => {
|
|
348
|
-
let t = e.length;
|
|
349
|
-
for (; t > 0 && e[t - 1] === "\n";) --t;
|
|
350
|
-
return t < e.length ? `${e.slice(0, t)}_${e.slice(t)}` : `${e}_`;
|
|
351
|
-
}, ut = (e) => {
|
|
352
|
-
if (!e.endsWith("**")) return null;
|
|
353
|
-
let t = e.slice(0, -2);
|
|
354
|
-
if (et(t) % 2 != 1) return null;
|
|
355
|
-
let n = t.indexOf("**"), r = ct(t);
|
|
356
|
-
return n !== -1 && r !== -1 && n < r ? `${t}_**` : null;
|
|
357
|
-
}, dt = (e) => {
|
|
358
|
-
if (!e.match(Oe)) return e;
|
|
359
|
-
let t = ct(e);
|
|
360
|
-
if (t === -1) return e;
|
|
361
|
-
let n = e.substring(t + 1);
|
|
362
|
-
if (!n || T.test(n) || S(e, t) || C(e, t)) return e;
|
|
363
|
-
if (Qe(e) % 2 == 1) {
|
|
364
|
-
let t = ut(e);
|
|
365
|
-
return t === null ? lt(e) : t;
|
|
366
|
-
}
|
|
367
|
-
return e;
|
|
368
|
-
}, ft = (e) => {
|
|
369
|
-
let t = et(e), n = Xe(e);
|
|
370
|
-
return t % 2 == 0 && n % 2 == 0;
|
|
371
|
-
}, pt = (e, t, n) => !t || T.test(t) || S(e, n) || C(e, n) ? !0 : O(e, n, "*"), mt = (e) => {
|
|
372
|
-
if (Pe.test(e)) return e;
|
|
373
|
-
let t = e.match(Ee);
|
|
374
|
-
if (!t) return e;
|
|
375
|
-
let n = t[2];
|
|
376
|
-
return pt(e, n, e.lastIndexOf(t[1])) ? e : $e(e) % 2 == 1 ? ft(e) ? e : `${e}***` : e;
|
|
377
|
-
}, ht = /<[a-zA-Z/][^>]*$/, gt = (e) => {
|
|
378
|
-
let t = e.match(ht);
|
|
379
|
-
return !t || t.index === void 0 || S(e, t.index) ? e : e.substring(0, t.index).trimEnd();
|
|
380
|
-
}, _t = (e) => !e.match(Ne) || e.includes("\n") ? null : e.endsWith("``") && !e.endsWith("```") ? `${e}\`` : e, vt = (e) => (e.match(/```/g) || []).length % 2 == 1, yt = (e) => {
|
|
381
|
-
let t = _t(e);
|
|
382
|
-
if (t !== null) return t;
|
|
383
|
-
let n = e.match(ke);
|
|
384
|
-
if (n && !vt(e)) {
|
|
385
|
-
let t = n[2];
|
|
386
|
-
if (!t || T.test(t)) return e;
|
|
387
|
-
if (Se(e) % 2 == 1) return `${e}\``;
|
|
388
|
-
}
|
|
389
|
-
return e;
|
|
390
|
-
}, bt = (e, t) => t >= 2 && e.substring(t - 2, t + 1) === "```" || t >= 1 && e.substring(t - 1, t + 2) === "```" || t <= e.length - 3 && e.substring(t, t + 3) === "```", xt = (e) => {
|
|
391
|
-
let t = 0, n = !1;
|
|
392
|
-
for (let r = 0; r < e.length - 1; r += 1) e[r] === "`" && !bt(e, r) && (n = !n), !n && e[r] === "$" && e[r + 1] === "$" && (t += 1, r += 1);
|
|
393
|
-
return t;
|
|
394
|
-
}, St = (e) => {
|
|
395
|
-
let t = 0, n = !1;
|
|
396
|
-
for (let r = 0; r < e.length; r += 1) {
|
|
397
|
-
if (e[r] === "\\") {
|
|
398
|
-
r += 1;
|
|
399
|
-
continue;
|
|
400
|
-
}
|
|
401
|
-
if (e[r] === "`" && !bt(e, r)) {
|
|
402
|
-
n = !n;
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
!n && e[r] === "$" && (r + 1 < e.length && e[r + 1] === "$" ? r += 1 : t += 1);
|
|
406
|
-
}
|
|
407
|
-
return t;
|
|
408
|
-
}, Ct = (e) => {
|
|
409
|
-
if (e.endsWith("$") && !e.endsWith("$$")) return `${e}$`;
|
|
410
|
-
let t = e.indexOf("$$");
|
|
411
|
-
return t !== -1 && e.indexOf("\n", t) !== -1 && !e.endsWith("\n") ? `${e}
|
|
412
|
-
$$` : `${e}$$`;
|
|
413
|
-
}, wt = (e) => xt(e) % 2 == 0 ? e : Ct(e), Tt = (e) => St(e) % 2 == 1 ? `${e}$` : e, Et = (e, t, n) => {
|
|
414
|
-
if (e.substring(t + 2).includes(")")) return null;
|
|
415
|
-
let r = Re(e, t);
|
|
416
|
-
if (r === -1 || S(e, r)) return null;
|
|
417
|
-
let i = r > 0 && e[r - 1] === "!", a = i ? r - 1 : r, o = e.substring(0, a);
|
|
418
|
-
if (i) return o;
|
|
419
|
-
let s = e.substring(r + 1, t);
|
|
420
|
-
return n === "text-only" ? `${o}${s}` : `${o}[${s}](streamdown:incomplete-link)`;
|
|
421
|
-
}, Dt = (e, t) => {
|
|
422
|
-
for (let n = 0; n < t; n++) if (e[n] === "[" && !S(e, n)) {
|
|
423
|
-
if (n > 0 && e[n - 1] === "!") continue;
|
|
424
|
-
let t = ze(e, n);
|
|
425
|
-
if (t === -1) return n;
|
|
426
|
-
if (t + 1 < e.length && e[t + 1] === "(") {
|
|
427
|
-
let r = e.indexOf(")", t + 2);
|
|
428
|
-
r !== -1 && (n = r);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
return t;
|
|
432
|
-
}, Ot = (e, t, n) => {
|
|
433
|
-
let r = t > 0 && e[t - 1] === "!", i = r ? t - 1 : t;
|
|
434
|
-
if (!e.substring(t + 1).includes("]")) {
|
|
435
|
-
let a = e.substring(0, i);
|
|
436
|
-
if (r) return a;
|
|
437
|
-
if (n === "text-only") {
|
|
438
|
-
let n = Dt(e, t);
|
|
439
|
-
return e.substring(0, n) + e.substring(n + 1);
|
|
440
|
-
}
|
|
441
|
-
return `${e}](streamdown:incomplete-link)`;
|
|
442
|
-
}
|
|
443
|
-
if (ze(e, t) === -1) {
|
|
444
|
-
let a = e.substring(0, i);
|
|
445
|
-
if (r) return a;
|
|
446
|
-
if (n === "text-only") {
|
|
447
|
-
let n = Dt(e, t);
|
|
448
|
-
return e.substring(0, n) + e.substring(n + 1);
|
|
449
|
-
}
|
|
450
|
-
return `${e}](streamdown:incomplete-link)`;
|
|
451
|
-
}
|
|
452
|
-
return null;
|
|
453
|
-
}, kt = (e, t = "protocol") => {
|
|
454
|
-
let n = e.lastIndexOf("](");
|
|
455
|
-
if (n !== -1 && !S(e, n)) {
|
|
456
|
-
let r = Et(e, n, t);
|
|
457
|
-
if (r !== null) return r;
|
|
458
|
-
}
|
|
459
|
-
for (let n = e.length - 1; n >= 0; --n) if (e[n] === "[" && !S(e, n)) {
|
|
460
|
-
let r = Ot(e, n, t);
|
|
461
|
-
if (r !== null) return r;
|
|
462
|
-
}
|
|
463
|
-
return e;
|
|
464
|
-
}, At = /^-{1,2}$/, jt = /^[\s]*-{1,2}[\s]+$/, Mt = /^={1,2}$/, Nt = /^[\s]*={1,2}[\s]+$/, Pt = (e) => {
|
|
465
|
-
if (!e || typeof e != "string") return e;
|
|
466
|
-
let t = e.lastIndexOf("\n");
|
|
467
|
-
if (t === -1) return e;
|
|
468
|
-
let n = e.substring(t + 1), r = e.substring(0, t), i = n.trim();
|
|
469
|
-
if (At.test(i) && !n.match(jt)) {
|
|
470
|
-
let t = r.split("\n").at(-1);
|
|
471
|
-
if (t && t.trim().length > 0) return `${e}\u200B`;
|
|
472
|
-
}
|
|
473
|
-
if (Mt.test(i) && !n.match(Nt)) {
|
|
474
|
-
let t = r.split("\n").at(-1);
|
|
475
|
-
if (t && t.trim().length > 0) return `${e}\u200B`;
|
|
476
|
-
}
|
|
477
|
-
return e;
|
|
478
|
-
}, Ft = /([\p{L}\p{N}_])~(?!~)(?=[\p{L}\p{N}_])/gu, It = (e) => !e || typeof e != "string" || !e.includes("~") ? e : e.replace(Ft, (t, n, r) => S(e, r + n.length) ? t : `${n}\\~`), Lt = (e) => {
|
|
479
|
-
let t = e.match(Ae);
|
|
480
|
-
if (t) {
|
|
481
|
-
let n = t[2];
|
|
482
|
-
if (!n || T.test(n)) return e;
|
|
483
|
-
let r = e.lastIndexOf(t[1]);
|
|
484
|
-
if (S(e, r) || C(e, r)) return e;
|
|
485
|
-
if (e.match(Le)?.length % 2 == 1) return `${e}~~`;
|
|
486
|
-
} else {
|
|
487
|
-
let t = e.match(Ie);
|
|
488
|
-
if (t) {
|
|
489
|
-
let n = e.lastIndexOf(t[0].slice(0, 2));
|
|
490
|
-
if (S(e, n) || C(e, n)) return e;
|
|
491
|
-
if (e.match(Le)?.length % 2 == 1) return `${e}~`;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return e;
|
|
495
|
-
}, Rt = (e) => e !== !1, zt = (e) => e === !0, A = {
|
|
496
|
-
SINGLE_TILDE: 0,
|
|
497
|
-
COMPARISON_OPERATORS: 5,
|
|
498
|
-
HTML_TAGS: 10,
|
|
499
|
-
SETEXT_HEADINGS: 15,
|
|
500
|
-
LINKS: 20,
|
|
501
|
-
BOLD_ITALIC: 30,
|
|
502
|
-
BOLD: 35,
|
|
503
|
-
ITALIC_DOUBLE_UNDERSCORE: 40,
|
|
504
|
-
ITALIC_SINGLE_ASTERISK: 41,
|
|
505
|
-
ITALIC_SINGLE_UNDERSCORE: 42,
|
|
506
|
-
INLINE_CODE: 50,
|
|
507
|
-
STRIKETHROUGH: 60,
|
|
508
|
-
KATEX: 70,
|
|
509
|
-
INLINE_KATEX: 75,
|
|
510
|
-
DEFAULT: 100
|
|
511
|
-
}, Bt = [
|
|
512
|
-
{
|
|
513
|
-
handler: {
|
|
514
|
-
name: "singleTilde",
|
|
515
|
-
handle: It,
|
|
516
|
-
priority: A.SINGLE_TILDE
|
|
517
|
-
},
|
|
518
|
-
optionKey: "singleTilde"
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
handler: {
|
|
522
|
-
name: "comparisonOperators",
|
|
523
|
-
handle: w,
|
|
524
|
-
priority: A.COMPARISON_OPERATORS
|
|
525
|
-
},
|
|
526
|
-
optionKey: "comparisonOperators"
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
handler: {
|
|
530
|
-
name: "htmlTags",
|
|
531
|
-
handle: gt,
|
|
532
|
-
priority: A.HTML_TAGS
|
|
533
|
-
},
|
|
534
|
-
optionKey: "htmlTags"
|
|
535
|
-
},
|
|
536
|
-
{
|
|
537
|
-
handler: {
|
|
538
|
-
name: "setextHeadings",
|
|
539
|
-
handle: Pt,
|
|
540
|
-
priority: A.SETEXT_HEADINGS
|
|
541
|
-
},
|
|
542
|
-
optionKey: "setextHeadings"
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
handler: {
|
|
546
|
-
name: "links",
|
|
547
|
-
handle: kt,
|
|
548
|
-
priority: A.LINKS
|
|
549
|
-
},
|
|
550
|
-
optionKey: "links",
|
|
551
|
-
earlyReturn: (e) => e.endsWith("](streamdown:incomplete-link)")
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
handler: {
|
|
555
|
-
name: "boldItalic",
|
|
556
|
-
handle: mt,
|
|
557
|
-
priority: A.BOLD_ITALIC
|
|
558
|
-
},
|
|
559
|
-
optionKey: "boldItalic"
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
handler: {
|
|
563
|
-
name: "bold",
|
|
564
|
-
handle: rt,
|
|
565
|
-
priority: A.BOLD
|
|
566
|
-
},
|
|
567
|
-
optionKey: "bold"
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
handler: {
|
|
571
|
-
name: "italicDoubleUnderscore",
|
|
572
|
-
handle: at,
|
|
573
|
-
priority: A.ITALIC_DOUBLE_UNDERSCORE
|
|
574
|
-
},
|
|
575
|
-
optionKey: "italic"
|
|
576
|
-
},
|
|
577
|
-
{
|
|
578
|
-
handler: {
|
|
579
|
-
name: "italicSingleAsterisk",
|
|
580
|
-
handle: st,
|
|
581
|
-
priority: A.ITALIC_SINGLE_ASTERISK
|
|
582
|
-
},
|
|
583
|
-
optionKey: "italic"
|
|
584
|
-
},
|
|
585
|
-
{
|
|
586
|
-
handler: {
|
|
587
|
-
name: "italicSingleUnderscore",
|
|
588
|
-
handle: dt,
|
|
589
|
-
priority: A.ITALIC_SINGLE_UNDERSCORE
|
|
590
|
-
},
|
|
591
|
-
optionKey: "italic"
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
handler: {
|
|
595
|
-
name: "inlineCode",
|
|
596
|
-
handle: yt,
|
|
597
|
-
priority: A.INLINE_CODE
|
|
598
|
-
},
|
|
599
|
-
optionKey: "inlineCode"
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
handler: {
|
|
603
|
-
name: "strikethrough",
|
|
604
|
-
handle: Lt,
|
|
605
|
-
priority: A.STRIKETHROUGH
|
|
606
|
-
},
|
|
607
|
-
optionKey: "strikethrough"
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
handler: {
|
|
611
|
-
name: "katex",
|
|
612
|
-
handle: wt,
|
|
613
|
-
priority: A.KATEX
|
|
614
|
-
},
|
|
615
|
-
optionKey: "katex"
|
|
616
|
-
},
|
|
617
|
-
{
|
|
618
|
-
handler: {
|
|
619
|
-
name: "inlineKatex",
|
|
620
|
-
handle: Tt,
|
|
621
|
-
priority: A.INLINE_KATEX
|
|
622
|
-
},
|
|
623
|
-
optionKey: "inlineKatex"
|
|
624
|
-
}
|
|
625
|
-
], Vt = (e) => {
|
|
626
|
-
let t = e?.linkMode ?? "protocol";
|
|
627
|
-
return Bt.filter(({ handler: t, optionKey: n }) => t.name === "links" ? Rt(e?.links) || Rt(e?.images) : t.name === "inlineKatex" ? zt(e?.inlineKatex) : Rt(e?.[n])).map(({ handler: e, earlyReturn: n }) => e.name === "links" ? {
|
|
628
|
-
handler: x(ve({}, e), { handle: (e) => kt(e, t) }),
|
|
629
|
-
earlyReturn: t === "protocol" ? n : void 0
|
|
630
|
-
} : {
|
|
631
|
-
handler: e,
|
|
632
|
-
earlyReturn: n
|
|
633
|
-
});
|
|
634
|
-
}, Ht = (e, t) => {
|
|
635
|
-
if (!e || typeof e != "string") return e;
|
|
636
|
-
let n = e.endsWith(" ") && !e.endsWith(" ") ? e.slice(0, -1) : e, r = Vt(t), i = (t?.handlers ?? []).map((e) => ({
|
|
637
|
-
handler: x(ve({}, e), { priority: e.priority ?? A.DEFAULT }),
|
|
638
|
-
earlyReturn: void 0
|
|
639
|
-
})), a = [...r, ...i].sort((e, t) => (e.handler.priority ?? 0) - (t.handler.priority ?? 0));
|
|
640
|
-
for (let { handler: e, earlyReturn: t } of a) if (n = e.handle(n), t != null && t(n)) return n;
|
|
641
|
-
return n;
|
|
642
|
-
};
|
|
643
|
-
//#endregion
|
|
644
|
-
//#region ../../node_modules/.pnpm/marked@18.0.14/node_modules/marked/lib/marked.esm.js
|
|
645
|
-
function Ut() {
|
|
646
|
-
return {
|
|
647
|
-
async: !1,
|
|
648
|
-
breaks: !1,
|
|
649
|
-
extensions: null,
|
|
650
|
-
gfm: !0,
|
|
651
|
-
hooks: null,
|
|
652
|
-
pedantic: !1,
|
|
653
|
-
renderer: null,
|
|
654
|
-
silent: !1,
|
|
655
|
-
tokenizer: null,
|
|
656
|
-
walkTokens: null
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
var j = Ut();
|
|
660
|
-
function Wt(e) {
|
|
661
|
-
j = e;
|
|
662
|
-
}
|
|
663
|
-
var M = { exec: () => null };
|
|
664
|
-
function N(e) {
|
|
665
|
-
let t = [];
|
|
666
|
-
return (n) => {
|
|
667
|
-
let r = Math.max(0, Math.min(3, n - 1)), i = t[r];
|
|
668
|
-
return i || (i = e(r), t[r] = i), i;
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
function P(e, t = "") {
|
|
672
|
-
let n = typeof e == "string" ? e : e.source, r = {
|
|
673
|
-
replace: (e, t) => {
|
|
674
|
-
let i = typeof t == "string" ? t : t.source;
|
|
675
|
-
return i = i.replace(F.caret, "$1"), n = n.replace(e, i), r;
|
|
676
|
-
},
|
|
677
|
-
getRegex: () => new RegExp(n, t)
|
|
678
|
-
};
|
|
679
|
-
return r;
|
|
680
|
-
}
|
|
681
|
-
var Gt = ((e = "") => {
|
|
682
|
-
try {
|
|
683
|
-
return !!RegExp("(?<=1)(?<!1)" + e);
|
|
684
|
-
} catch {
|
|
685
|
-
return !1;
|
|
686
|
-
}
|
|
687
|
-
})(), F = {
|
|
688
|
-
codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm,
|
|
689
|
-
outputLinkReplace: /\\([\[\]])/g,
|
|
690
|
-
indentCodeCompensation: /^(\s+)(?:```)/,
|
|
691
|
-
beginningSpace: /^\s+/,
|
|
692
|
-
endingHash: /#$/,
|
|
693
|
-
startingSpaceChar: /^ /,
|
|
694
|
-
endingSpaceChar: / $/,
|
|
695
|
-
endingSpaceTabChar: /[ \t]$/,
|
|
696
|
-
nonSpaceChar: /[^ ]/,
|
|
697
|
-
newLineCharGlobal: /\n/g,
|
|
698
|
-
tabCharGlobal: /\t/g,
|
|
699
|
-
leadingSpaceTab: /^[ \t]+/,
|
|
700
|
-
multipleSpaceGlobal: /\s+/g,
|
|
701
|
-
blankLine: /^[ \t]*$/,
|
|
702
|
-
doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
|
|
703
|
-
blockquoteStart: /^ {0,3}>/,
|
|
704
|
-
blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
|
|
705
|
-
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
|
|
706
|
-
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
|
|
707
|
-
listIsTask: /^\[[ xX]\] +\S/,
|
|
708
|
-
listReplaceTask: /^\[[ xX]\] +/,
|
|
709
|
-
listTaskCheckbox: /\[[ xX]\]/,
|
|
710
|
-
anyLine: /\n.*\n/,
|
|
711
|
-
hrefBrackets: /^<(.*)>$/,
|
|
712
|
-
tableDelimiter: /[:|]/,
|
|
713
|
-
tableAlignChars: /^\||\| *$/g,
|
|
714
|
-
tableRowBlankLine: /\n[ \t]*$/,
|
|
715
|
-
tableAlignRight: /^ *-+: *$/,
|
|
716
|
-
tableAlignCenter: /^ *:-+: *$/,
|
|
717
|
-
tableAlignLeft: /^ *:-+ *$/,
|
|
718
|
-
startATag: /^<a /i,
|
|
719
|
-
endATag: /^<\/a>/i,
|
|
720
|
-
startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
|
|
721
|
-
endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
|
|
722
|
-
startAngleBracket: /^</,
|
|
723
|
-
endAngleBracket: />$/,
|
|
724
|
-
pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
|
|
725
|
-
unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
|
|
726
|
-
numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,
|
|
727
|
-
escapeTest: /[&<>"']/,
|
|
728
|
-
escapeReplace: /[&<>"']/g,
|
|
729
|
-
escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
|
|
730
|
-
escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
|
|
731
|
-
caret: /(^|[^\[])\^/g,
|
|
732
|
-
percentDecode: /%25/g,
|
|
733
|
-
findPipe: /\|/g,
|
|
734
|
-
splitPipe: / \|/,
|
|
735
|
-
slashPipe: /\\\|/g,
|
|
736
|
-
carriageReturn: /\r\n|\r/g,
|
|
737
|
-
spaceLine: /^ +$/gm,
|
|
738
|
-
notSpaceStart: /^\S*/,
|
|
739
|
-
endingNewline: /\n$/,
|
|
740
|
-
listItemRegex: (e) => RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
741
|
-
nextBulletRegex: N((e) => RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),
|
|
742
|
-
hrRegex: N((e) => RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),
|
|
743
|
-
fencesBeginRegex: N((e) => RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),
|
|
744
|
-
headingBeginRegex: N((e) => RegExp(`^ {0,${e}}#`)),
|
|
745
|
-
htmlBeginRegex: N((e) => RegExp(`^ {0,${e}}(?:</?(?:${L})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`, "i")),
|
|
746
|
-
blockquoteBeginRegex: N((e) => RegExp(`^ {0,${e}}>`))
|
|
747
|
-
}, Kt = /^(?:[ \t]*(?:\n|$))+/, qt = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Jt = /^ {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+|$)/, Yt = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Xt = / {0,3}(?:[*+-]|\d{1,9}[.)])/, Zt = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, Qt = P(Zt).replace(/bull/g, Xt).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}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), $t = P(Zt).replace(/bull/g, Xt).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}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), en = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/, tn = /^[^\n]+/, nn = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, rn = P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", nn).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), an = P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, Xt).getRegex(), L = "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", on = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, sn = P("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", on).replace("tag", L).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), cn = (e) => P(en).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|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", e).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex(), ln = cn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/), un = cn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/), dn = {
|
|
748
|
-
blockquote: P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", un).getRegex(),
|
|
749
|
-
code: qt,
|
|
750
|
-
def: rn,
|
|
751
|
-
fences: Jt,
|
|
752
|
-
heading: Yt,
|
|
753
|
-
hr: I,
|
|
754
|
-
html: sn,
|
|
755
|
-
lheading: Qt,
|
|
756
|
-
list: an,
|
|
757
|
-
newline: Kt,
|
|
758
|
-
paragraph: ln,
|
|
759
|
-
table: M,
|
|
760
|
-
text: tn
|
|
761
|
-
}, fn = P("^ *([^\\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|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex(), pn = {
|
|
762
|
-
...dn,
|
|
763
|
-
lheading: $t,
|
|
764
|
-
table: fn,
|
|
765
|
-
paragraph: P(en).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", fn).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex()
|
|
766
|
-
}, mn = {
|
|
767
|
-
...dn,
|
|
768
|
-
html: P("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", on).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(),
|
|
769
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
770
|
-
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
771
|
-
fences: M,
|
|
772
|
-
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
773
|
-
paragraph: P(en).replace("hr", I).replace("heading", " *#{1,6} *[^\n]").replace("lheading", Qt).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
774
|
-
}, hn = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, gn = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, _n = /^( {2,}|\\)\n(?!\s*$)[ \t]*/, vn = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, R = /[\p{P}\p{S}]/u, z = /[\s\p{P}\p{S}]/u, B = /[^\s\p{P}\p{S}]/u, yn = P(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, z).getRegex(), bn = /[\p{Pi}\p{Ps}"']/u, xn = /(?!~)[\p{P}\p{S}]/u, Sn = /(?!~)[\s\p{P}\p{S}]/u, Cn = /(?:[^\s\p{P}\p{S}]|~)/u, wn = P(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Gt ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), Tn = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, En = P(Tn, "u").replace(/punct/g, R).getRegex(), Dn = P(Tn, "u").replace(/punct/g, xn).getRegex(), On = P(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/, "u").replace(/openQuote/g, bn).replace(/punct/g, R).getRegex(), kn = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", An = P(kn, "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), jn = P(kn, "gu").replace(/notPunctSpace/g, Cn).replace(/punctSpace/g, Sn).replace(/punct/g, xn).getRegex(), Mn = P("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Nn = P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Pn = P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Fn = P(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, R).getRegex(), In = P("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, B).replace(/punctSpace/g, z).replace(/punct/g, R).getRegex(), Ln = P(/\\(punct)/, "gu").replace(/punct/g, R).getRegex(), Rn = P(/^<(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(), zn = P(on).replace("(?:-->|$)", "-->").getRegex(), Bn = P("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", zn).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Vn = /\[(?:\\[\s\S]|[^\[\]\\])*\]/, V = P(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", Vn).getRegex(), Hn = P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", V).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Un = P(/^!?\[(label)\]\[(ref)\]/).replace("label", V).replace("ref", nn).getRegex(), Wn = P(/^!?\[(ref)\](?:\[\])?/).replace("ref", nn).getRegex(), Gn = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/, Kn = P(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", Vn).getRegex(), qn = P("reflink|nolink(?!\\()", "g").replace("reflink", P(/^!?\[(label)\]\[(ref)\]/).replace("label", Kn).replace("ref", Gn).getRegex()).replace("nolink", P(/^!?\[(ref)\](?:\[\])?/).replace("ref", Gn).getRegex()).getRegex(), Jn = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, Yn = P(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), Xn = {
|
|
775
|
-
_backpedal: M,
|
|
776
|
-
anyPunctuation: Ln,
|
|
777
|
-
autolink: Rn,
|
|
778
|
-
blockSkip: wn,
|
|
779
|
-
br: _n,
|
|
780
|
-
code: gn,
|
|
781
|
-
del: M,
|
|
782
|
-
delLDelim: M,
|
|
783
|
-
delRDelim: M,
|
|
784
|
-
emStrongLDelim: En,
|
|
785
|
-
emStrongRDelimAst: An,
|
|
786
|
-
emStrongRDelimUnd: Nn,
|
|
787
|
-
escape: hn,
|
|
788
|
-
link: Hn,
|
|
789
|
-
nolink: Wn,
|
|
790
|
-
punctuation: yn,
|
|
791
|
-
reflink: Un,
|
|
792
|
-
reflinkSearch: qn,
|
|
793
|
-
tag: Bn,
|
|
794
|
-
text: vn,
|
|
795
|
-
url: M
|
|
796
|
-
}, Zn = {
|
|
797
|
-
...Xn,
|
|
798
|
-
emStrongLDelim: On,
|
|
799
|
-
emStrongRDelimAst: Mn,
|
|
800
|
-
emStrongRDelimUnd: Pn,
|
|
801
|
-
link: P(/^!?\[(label)\]\((.*?)\)/).replace("label", V).getRegex(),
|
|
802
|
-
reflink: P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", V).getRegex()
|
|
803
|
-
}, Qn = {
|
|
804
|
-
...Xn,
|
|
805
|
-
emStrongRDelimAst: jn,
|
|
806
|
-
emStrongLDelim: Dn,
|
|
807
|
-
delLDelim: Fn,
|
|
808
|
-
delRDelim: In,
|
|
809
|
-
url: P(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", Yn).replace("protocol", Jn).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),
|
|
810
|
-
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
811
|
-
del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
|
|
812
|
-
text: P(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", Jn).replace(/emailProtocol/g, /(?:mailto|xmpp):/).getRegex()
|
|
813
|
-
}, $n = {
|
|
814
|
-
...Qn,
|
|
815
|
-
br: P(_n).replace("{2,}", "*").getRegex(),
|
|
816
|
-
text: P(Qn.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
817
|
-
}, H = {
|
|
818
|
-
normal: dn,
|
|
819
|
-
gfm: pn,
|
|
820
|
-
pedantic: mn
|
|
821
|
-
}, U = {
|
|
822
|
-
normal: Xn,
|
|
823
|
-
gfm: Qn,
|
|
824
|
-
breaks: $n,
|
|
825
|
-
pedantic: Zn
|
|
826
|
-
}, er = {
|
|
827
|
-
"&": "&",
|
|
828
|
-
"<": "<",
|
|
829
|
-
">": ">",
|
|
830
|
-
"\"": """,
|
|
831
|
-
"'": "'"
|
|
832
|
-
}, tr = (e) => er[e];
|
|
833
|
-
function W(e, t) {
|
|
834
|
-
if (t) {
|
|
835
|
-
if (F.escapeTest.test(e)) return e.replace(F.escapeReplace, tr);
|
|
836
|
-
} else if (F.escapeTestNoEncode.test(e)) return e.replace(F.escapeReplaceNoEncode, tr);
|
|
837
|
-
return e;
|
|
838
|
-
}
|
|
839
|
-
function nr(e) {
|
|
840
|
-
return e.replace(F.numericCharacterReference, (e, t, n) => {
|
|
841
|
-
let r = t === void 0 ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
|
|
842
|
-
return r === 0 || r > 1114111 || r >= 55296 && r <= 57343 ? "�" : String.fromCodePoint(r);
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
function rr(e) {
|
|
846
|
-
try {
|
|
847
|
-
e = encodeURI(e).replace(F.percentDecode, "%");
|
|
848
|
-
} catch {
|
|
849
|
-
return null;
|
|
850
|
-
}
|
|
851
|
-
return e;
|
|
852
|
-
}
|
|
853
|
-
function ir(e, t) {
|
|
854
|
-
let n = e.replace(F.findPipe, (e, t, n) => {
|
|
855
|
-
let r = !1, i = t;
|
|
856
|
-
for (; --i >= 0 && n[i] === "\\";) r = !r;
|
|
857
|
-
return r ? "|" : " |";
|
|
858
|
-
}).split(F.splitPipe), r = 0;
|
|
859
|
-
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t) {
|
|
860
|
-
if (n.length > t) n.splice(t);
|
|
861
|
-
else for (; n.length < t;) n.push("");
|
|
862
|
-
}
|
|
863
|
-
for (; r < n.length; r++) n[r] = n[r].trim().replace(F.slashPipe, "|");
|
|
864
|
-
return n;
|
|
865
|
-
}
|
|
866
|
-
function G(e, t, n) {
|
|
867
|
-
let r = e.length;
|
|
868
|
-
if (r === 0) return "";
|
|
869
|
-
let i = 0;
|
|
870
|
-
for (; i < r;) {
|
|
871
|
-
let a = e.charAt(r - i - 1);
|
|
872
|
-
if (a === t && !n) i++;
|
|
873
|
-
else if (a !== t && n) i++;
|
|
874
|
-
else break;
|
|
875
|
-
}
|
|
876
|
-
return e.slice(0, r - i);
|
|
877
|
-
}
|
|
878
|
-
function ar(e) {
|
|
879
|
-
let t = e.split("\n"), n = t.length - 1;
|
|
880
|
-
for (; n >= 0 && F.blankLine.test(t[n]);) n--;
|
|
881
|
-
return t.length - n <= 2 ? e : t.slice(0, n + 1).join("\n");
|
|
882
|
-
}
|
|
883
|
-
function K(e) {
|
|
884
|
-
return e.trim().toLowerCase().toUpperCase().toLowerCase();
|
|
885
|
-
}
|
|
886
|
-
function or(e, t) {
|
|
887
|
-
if (e.indexOf(t[1]) === -1) return -1;
|
|
888
|
-
let n = 0;
|
|
889
|
-
for (let r = 0; r < e.length; r++) if (e[r] === "\\") r++;
|
|
890
|
-
else if (e[r] === t[0]) n++;
|
|
891
|
-
else if (e[r] === t[1] && (n--, n < 0)) return r;
|
|
892
|
-
return n > 0 ? -2 : -1;
|
|
893
|
-
}
|
|
894
|
-
function sr(e, t = 0) {
|
|
895
|
-
let n = t, r = "";
|
|
896
|
-
for (let t of e) if (t === " ") {
|
|
897
|
-
let e = 4 - n % 4;
|
|
898
|
-
r += " ".repeat(e), n += e;
|
|
899
|
-
} else r += t, n++;
|
|
900
|
-
return r;
|
|
901
|
-
}
|
|
902
|
-
function cr(e, t, n, r, i) {
|
|
903
|
-
let a = t.href, o = t.title || null, s = e[1].replace(i.other.outputLinkReplace, "$1"), c = e[0].charAt(0) === "!";
|
|
904
|
-
r.state.inLink = !0;
|
|
905
|
-
let l = r.state.linkEmitted, u = r.state.inRawBlock;
|
|
906
|
-
r.state.linkEmitted = !1;
|
|
907
|
-
let d = r.inlineTokens(s), f = r.state.linkEmitted;
|
|
908
|
-
if (r.state.linkEmitted = l, r.state.inLink = !1, !c) {
|
|
909
|
-
if (f) {
|
|
910
|
-
r.state.inRawBlock = u;
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
r.state.linkEmitted = !0;
|
|
914
|
-
}
|
|
915
|
-
return {
|
|
916
|
-
type: c ? "image" : "link",
|
|
917
|
-
raw: n,
|
|
918
|
-
href: a,
|
|
919
|
-
title: o,
|
|
920
|
-
text: s,
|
|
921
|
-
tokens: d
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
function lr(e, t, n) {
|
|
925
|
-
let r = e.match(n.other.indentCodeCompensation);
|
|
926
|
-
if (r === null) return t;
|
|
927
|
-
let i = r[1];
|
|
928
|
-
return t.split("\n").map((e) => {
|
|
929
|
-
let t = e.match(n.other.beginningSpace);
|
|
930
|
-
if (t === null) return e;
|
|
931
|
-
let [r] = t;
|
|
932
|
-
return e.slice(Math.min(r.length, i.length));
|
|
933
|
-
}).join("\n");
|
|
934
|
-
}
|
|
935
|
-
function ur(e, t, n, r) {
|
|
936
|
-
if (!t.includes("<")) return !1;
|
|
937
|
-
for (let i = 0; i < t.length; i++) {
|
|
938
|
-
if (t[i] === "\\") {
|
|
939
|
-
i++;
|
|
940
|
-
continue;
|
|
941
|
-
}
|
|
942
|
-
if (t[i] === "`") {
|
|
943
|
-
let e = r.inline.code.exec(t.slice(i));
|
|
944
|
-
if (e) {
|
|
945
|
-
i += e[0].length - 1;
|
|
946
|
-
continue;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
if (t[i] !== "<") continue;
|
|
950
|
-
let a = e.slice(n + i), o = r.inline.tag.exec(a) || r.inline.autolink.exec(a);
|
|
951
|
-
if (o) {
|
|
952
|
-
if (o[0].length > t.length - i) return !0;
|
|
953
|
-
i += o[0].length - 1;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
return !1;
|
|
957
|
-
}
|
|
958
|
-
var q = class {
|
|
959
|
-
options;
|
|
960
|
-
rules;
|
|
961
|
-
lexer;
|
|
962
|
-
constructor(e) {
|
|
963
|
-
this.options = e || j;
|
|
964
|
-
}
|
|
965
|
-
space(e) {
|
|
966
|
-
let t = this.rules.block.newline.exec(e);
|
|
967
|
-
if (t && t[0].length > 0) return {
|
|
968
|
-
type: "space",
|
|
969
|
-
raw: t[0]
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
code(e) {
|
|
973
|
-
let t = this.rules.block.code.exec(e);
|
|
974
|
-
if (t) {
|
|
975
|
-
let e = this.options.pedantic ? t[0] : ar(t[0]);
|
|
976
|
-
return {
|
|
977
|
-
type: "code",
|
|
978
|
-
raw: e,
|
|
979
|
-
codeBlockStyle: "indented",
|
|
980
|
-
text: e.replace(this.rules.other.codeRemoveIndent, "")
|
|
981
|
-
};
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
fences(e) {
|
|
985
|
-
let t = this.rules.block.fences.exec(e);
|
|
986
|
-
if (t) {
|
|
987
|
-
let e = t[0], n = lr(e, t[3] || "", this.rules);
|
|
988
|
-
return {
|
|
989
|
-
type: "code",
|
|
990
|
-
raw: e,
|
|
991
|
-
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
|
|
992
|
-
text: n
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
heading(e) {
|
|
997
|
-
let t = this.rules.block.heading.exec(e);
|
|
998
|
-
if (t) {
|
|
999
|
-
let e = t[2].trim();
|
|
1000
|
-
if (this.rules.other.endingHash.test(e)) {
|
|
1001
|
-
let t = G(e, "#");
|
|
1002
|
-
(this.options.pedantic || !t || this.rules.other.endingSpaceTabChar.test(t)) && (e = t.trim());
|
|
1003
|
-
}
|
|
1004
|
-
return {
|
|
1005
|
-
type: "heading",
|
|
1006
|
-
raw: G(t[0], "\n"),
|
|
1007
|
-
depth: t[1].length,
|
|
1008
|
-
text: e,
|
|
1009
|
-
tokens: this.lexer.inline(e)
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
hr(e) {
|
|
1014
|
-
let t = this.rules.block.hr.exec(e);
|
|
1015
|
-
if (t) return {
|
|
1016
|
-
type: "hr",
|
|
1017
|
-
raw: G(t[0], "\n")
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
blockquote(e) {
|
|
1021
|
-
let t = this.rules.block.blockquote.exec(e);
|
|
1022
|
-
if (t) {
|
|
1023
|
-
let e = G(t[0], "\n").split("\n"), n = "", r = "", i = [];
|
|
1024
|
-
for (; e.length > 0;) {
|
|
1025
|
-
let t = !1, a = [], o = 0;
|
|
1026
|
-
for (; o < e.length; o++) if (this.rules.other.blockquoteStart.test(e[o])) a.push(e[o]), t = !0;
|
|
1027
|
-
else if (!t) a.push(e[o]);
|
|
1028
|
-
else break;
|
|
1029
|
-
e = e.slice(o);
|
|
1030
|
-
let s = a.join("\n"), c = s.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1031
|
-
n = n ? `${n}
|
|
1032
|
-
${s}` : s, r = r ? `${r}
|
|
1033
|
-
${c}` : c;
|
|
1034
|
-
let l = this.lexer.state.top;
|
|
1035
|
-
if (this.lexer.state.top = !0, this.lexer.blockTokens(c, i, !0), this.lexer.state.top = l, e.length === 0) break;
|
|
1036
|
-
let u = i.at(-1);
|
|
1037
|
-
if (u?.type === "code") break;
|
|
1038
|
-
if (u?.type === "blockquote") {
|
|
1039
|
-
let t = u, a = e.join("\n"), o = t.raw + "\n" + a.replace(this.rules.other.blockquoteSetextReplace2, ""), s = this.blockquote(o);
|
|
1040
|
-
i[i.length - 1] = s;
|
|
1041
|
-
let c = o.substring(s.raw.length).replace(/^\n/, ""), l = c ? c.split("\n").length : 0, d = l ? e.slice(0, -l) : e;
|
|
1042
|
-
d.length > 0 && (n = `${n}
|
|
1043
|
-
${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
|
|
1044
|
-
break;
|
|
1045
|
-
}
|
|
1046
|
-
if (u?.type === "list") {
|
|
1047
|
-
let t = u, a = t.raw + "\n" + e.join("\n"), o = this.list(a);
|
|
1048
|
-
i[i.length - 1] = o, n = n.substring(0, n.length - u.raw.length) + o.raw, r = r.substring(0, r.length - t.raw.length) + o.raw, e = a.substring(i.at(-1).raw.length).split("\n");
|
|
1049
|
-
continue;
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
return {
|
|
1053
|
-
type: "blockquote",
|
|
1054
|
-
raw: n,
|
|
1055
|
-
tokens: i,
|
|
1056
|
-
text: r
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
list(e) {
|
|
1061
|
-
let t = this.rules.block.list.exec(e);
|
|
1062
|
-
if (t) {
|
|
1063
|
-
let n = t[1].trim(), r = n.length > 1, i = {
|
|
1064
|
-
type: "list",
|
|
1065
|
-
raw: "",
|
|
1066
|
-
ordered: r,
|
|
1067
|
-
start: r ? +n.slice(0, -1) : "",
|
|
1068
|
-
loose: !1,
|
|
1069
|
-
items: []
|
|
1070
|
-
};
|
|
1071
|
-
n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
|
|
1072
|
-
let a = this.rules.other.listItemRegex(n), o = !1;
|
|
1073
|
-
for (; e;) {
|
|
1074
|
-
let n = !1, r = "", s = "";
|
|
1075
|
-
if (!(t = a.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
1076
|
-
r = t[0], e = e.substring(r.length);
|
|
1077
|
-
let c = t[2].split("\n", 1)[0], l = t[1].length, u = this.options.pedantic ? sr(c, l) : c.replace(this.rules.other.leadingSpaceTab, (e) => sr(e, l)), d = e.split("\n", 1)[0], f = !u.trim(), p = 0;
|
|
1078
|
-
if (this.options.pedantic ? (p = 2, s = u.trimStart()) : f ? p = l + 1 : (p = u.search(this.rules.other.nonSpaceChar), p = p > 4 ? 1 : p, s = u.slice(p), p += l), f && this.rules.other.blankLine.test(d) && (r += d + "\n", e = e.substring(d.length + 1), n = !0), !n) {
|
|
1079
|
-
let t = this.rules.other.nextBulletRegex(p), n = this.rules.other.hrRegex(p), i = this.rules.other.fencesBeginRegex(p), a = this.rules.other.headingBeginRegex(p), o = this.rules.other.htmlBeginRegex(p), c = this.rules.other.blockquoteBeginRegex(p);
|
|
1080
|
-
for (; e;) {
|
|
1081
|
-
let l = e.split("\n", 1)[0], m;
|
|
1082
|
-
if (d = l, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), m = d) : m = d.replace(this.rules.other.leadingSpaceTab, (e) => e.replace(this.rules.other.tabCharGlobal, " ")), i.test(d) || a.test(d) || o.test(d) || c.test(d) || t.test(d) || n.test(d)) break;
|
|
1083
|
-
if (m.search(this.rules.other.nonSpaceChar) >= p || !d.trim()) s += "\n" + m.slice(p);
|
|
1084
|
-
else {
|
|
1085
|
-
if (f || u.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || i.test(u) || a.test(u) || n.test(u)) break;
|
|
1086
|
-
s += "\n" + d;
|
|
1087
|
-
}
|
|
1088
|
-
f = !d.trim(), r += l + "\n", e = e.substring(l.length + 1), u = m.slice(p);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
i.loose || (o ? i.loose = !0 : this.rules.other.doubleBlankLine.test(r) && (o = !0)), i.items.push({
|
|
1092
|
-
type: "list_item",
|
|
1093
|
-
raw: r,
|
|
1094
|
-
task: !!this.options.gfm && this.rules.other.listIsTask.test(s),
|
|
1095
|
-
loose: !1,
|
|
1096
|
-
text: s,
|
|
1097
|
-
tokens: []
|
|
1098
|
-
}), i.raw += r;
|
|
1099
|
-
}
|
|
1100
|
-
let s = i.items.at(-1);
|
|
1101
|
-
if (s) s.raw = s.raw.trimEnd(), s.text = s.text.trimEnd();
|
|
1102
|
-
else return;
|
|
1103
|
-
i.raw = i.raw.trimEnd();
|
|
1104
|
-
for (let e of i.items) if (this.lexer.state.top = !1, e.tokens = this.lexer.blockTokens(e.text, []), !i.loose) {
|
|
1105
|
-
let t = e.tokens.filter((e) => e.type === "space");
|
|
1106
|
-
i.loose = t.length > 0 && t.some((e) => this.rules.other.anyLine.test(e.raw));
|
|
1107
|
-
}
|
|
1108
|
-
for (let e of i.items) {
|
|
1109
|
-
let t = e.tokens[0];
|
|
1110
|
-
if (e.task && (t?.type === "text" || t?.type === "paragraph")) {
|
|
1111
|
-
e.text = e.text.replace(this.rules.other.listReplaceTask, ""), t.raw = t.raw.replace(this.rules.other.listReplaceTask, ""), t.text = t.text.replace(this.rules.other.listReplaceTask, "");
|
|
1112
|
-
for (let e = this.lexer.inlineQueue.length - 1; e >= 0; e--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)) {
|
|
1113
|
-
this.lexer.inlineQueue[e].src = this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask, "");
|
|
1114
|
-
break;
|
|
1115
|
-
}
|
|
1116
|
-
let n = this.rules.other.listTaskCheckbox.exec(e.raw);
|
|
1117
|
-
if (n) {
|
|
1118
|
-
let t = {
|
|
1119
|
-
type: "checkbox",
|
|
1120
|
-
raw: n[0] + " ",
|
|
1121
|
-
checked: n[0] !== "[ ]"
|
|
1122
|
-
};
|
|
1123
|
-
e.checked = t.checked, i.loose ? e.tokens[0] && ["paragraph", "text"].includes(e.tokens[0].type) && "tokens" in e.tokens[0] && e.tokens[0].tokens ? (e.tokens[0].raw = t.raw + e.tokens[0].raw, e.tokens[0].text = t.raw + e.tokens[0].text, e.tokens[0].tokens.unshift(t)) : e.tokens.unshift({
|
|
1124
|
-
type: "paragraph",
|
|
1125
|
-
raw: t.raw,
|
|
1126
|
-
text: t.raw,
|
|
1127
|
-
tokens: [t]
|
|
1128
|
-
}) : e.tokens.unshift(t);
|
|
1129
|
-
}
|
|
1130
|
-
} else e.task &&= !1;
|
|
1131
|
-
}
|
|
1132
|
-
if (i.loose) for (let e of i.items) {
|
|
1133
|
-
e.loose = !0;
|
|
1134
|
-
for (let t of e.tokens) t.type === "text" && (t.type = "paragraph");
|
|
1135
|
-
}
|
|
1136
|
-
return i;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
html(e) {
|
|
1140
|
-
let t = this.rules.block.html.exec(e);
|
|
1141
|
-
if (t) {
|
|
1142
|
-
let e = ar(t[0]);
|
|
1143
|
-
return {
|
|
1144
|
-
type: "html",
|
|
1145
|
-
block: !0,
|
|
1146
|
-
raw: e,
|
|
1147
|
-
pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
|
|
1148
|
-
text: e
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
def(e) {
|
|
1153
|
-
let t = this.rules.block.def.exec(e);
|
|
1154
|
-
if (t) {
|
|
1155
|
-
let e = K(t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), n = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
1156
|
-
return {
|
|
1157
|
-
type: "def",
|
|
1158
|
-
tag: e,
|
|
1159
|
-
raw: G(t[0], "\n"),
|
|
1160
|
-
href: n,
|
|
1161
|
-
title: r
|
|
1162
|
-
};
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
table(e) {
|
|
1166
|
-
let t = this.rules.block.table.exec(e);
|
|
1167
|
-
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
1168
|
-
let n = ir(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], a = {
|
|
1169
|
-
type: "table",
|
|
1170
|
-
raw: G(t[0], "\n"),
|
|
1171
|
-
header: [],
|
|
1172
|
-
align: [],
|
|
1173
|
-
rows: []
|
|
1174
|
-
};
|
|
1175
|
-
if (n.length === r.length) {
|
|
1176
|
-
for (let e of r) this.rules.other.tableAlignRight.test(e) ? a.align.push("right") : this.rules.other.tableAlignCenter.test(e) ? a.align.push("center") : this.rules.other.tableAlignLeft.test(e) ? a.align.push("left") : a.align.push(null);
|
|
1177
|
-
for (let e = 0; e < n.length; e++) a.header.push({
|
|
1178
|
-
text: n[e],
|
|
1179
|
-
tokens: this.lexer.inline(n[e]),
|
|
1180
|
-
header: !0,
|
|
1181
|
-
align: a.align[e]
|
|
1182
|
-
});
|
|
1183
|
-
for (let e of i) a.rows.push(ir(e, a.header.length).map((e, t) => ({
|
|
1184
|
-
text: e,
|
|
1185
|
-
tokens: this.lexer.inline(e),
|
|
1186
|
-
header: !1,
|
|
1187
|
-
align: a.align[t]
|
|
1188
|
-
})));
|
|
1189
|
-
return a;
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
lheading(e) {
|
|
1193
|
-
let t = this.rules.block.lheading.exec(e);
|
|
1194
|
-
if (t) {
|
|
1195
|
-
let e = t[1].trim();
|
|
1196
|
-
return {
|
|
1197
|
-
type: "heading",
|
|
1198
|
-
raw: G(t[0], "\n"),
|
|
1199
|
-
depth: t[2].charAt(0) === "=" ? 1 : 2,
|
|
1200
|
-
text: e,
|
|
1201
|
-
tokens: this.lexer.inline(e)
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
paragraph(e) {
|
|
1206
|
-
let t = this.rules.block.paragraph.exec(e);
|
|
1207
|
-
if (t) {
|
|
1208
|
-
let e = t[1].charAt(t[1].length - 1) === "\n" ? t[1].slice(0, -1) : t[1];
|
|
1209
|
-
return {
|
|
1210
|
-
type: "paragraph",
|
|
1211
|
-
raw: t[0],
|
|
1212
|
-
text: e,
|
|
1213
|
-
tokens: this.lexer.inline(e)
|
|
1214
|
-
};
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
text(e) {
|
|
1218
|
-
let t = this.rules.block.text.exec(e);
|
|
1219
|
-
if (t) return {
|
|
1220
|
-
type: "text",
|
|
1221
|
-
raw: t[0],
|
|
1222
|
-
text: t[0],
|
|
1223
|
-
tokens: this.lexer.inline(t[0])
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
escape(e) {
|
|
1227
|
-
let t = this.rules.inline.escape.exec(e);
|
|
1228
|
-
if (t) return {
|
|
1229
|
-
type: "escape",
|
|
1230
|
-
raw: t[0],
|
|
1231
|
-
text: t[1]
|
|
1232
|
-
};
|
|
1233
|
-
}
|
|
1234
|
-
tag(e) {
|
|
1235
|
-
let t = this.rules.inline.tag.exec(e);
|
|
1236
|
-
if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
|
|
1237
|
-
type: "html",
|
|
1238
|
-
raw: t[0],
|
|
1239
|
-
inLink: this.lexer.state.inLink,
|
|
1240
|
-
inRawBlock: this.lexer.state.inRawBlock,
|
|
1241
|
-
block: !1,
|
|
1242
|
-
text: t[0]
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
|
-
link(e) {
|
|
1246
|
-
let t = this.rules.inline.link.exec(e);
|
|
1247
|
-
if (t) {
|
|
1248
|
-
let n = t[0].charAt(0) === "!" ? 2 : 1;
|
|
1249
|
-
if (!this.options.pedantic && ur(e, t[1], n, this.rules)) return;
|
|
1250
|
-
let r = t[2].trim();
|
|
1251
|
-
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
|
|
1252
|
-
if (!this.rules.other.endAngleBracket.test(r)) return;
|
|
1253
|
-
let e = G(r.slice(0, -1), "\\");
|
|
1254
|
-
if ((r.length - e.length) % 2 == 0) return;
|
|
1255
|
-
} else {
|
|
1256
|
-
let e = or(t[2], "()");
|
|
1257
|
-
if (e === -2) return;
|
|
1258
|
-
if (e > -1) {
|
|
1259
|
-
let n = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + e;
|
|
1260
|
-
t[2] = t[2].substring(0, e), t[0] = t[0].substring(0, n).trim(), t[3] = "";
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
let i = t[2], a = "";
|
|
1264
|
-
if (this.options.pedantic) {
|
|
1265
|
-
let e = this.rules.other.pedanticHrefTitle.exec(i);
|
|
1266
|
-
e && (i = e[1], a = e[3]);
|
|
1267
|
-
} else a = t[3] ? t[3].slice(1, -1) : "";
|
|
1268
|
-
return i = i.trim(), this.rules.other.startAngleBracket.test(i) && (i = this.options.pedantic && !this.rules.other.endAngleBracket.test(r) ? i.slice(1) : i.slice(1, -1)), cr(t, {
|
|
1269
|
-
href: i && i.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
1270
|
-
title: a && a.replace(this.rules.inline.anyPunctuation, "$1")
|
|
1271
|
-
}, t[0], this.lexer, this.rules);
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
reflink(e, t) {
|
|
1275
|
-
let n;
|
|
1276
|
-
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
1277
|
-
let r = n[0].charAt(0) === "!" ? 2 : 1;
|
|
1278
|
-
if (!this.options.pedantic && ur(e, n[1], r, this.rules)) return;
|
|
1279
|
-
let i = t[K((n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "))];
|
|
1280
|
-
if (!i) {
|
|
1281
|
-
let e = n[0].charAt(0);
|
|
1282
|
-
return {
|
|
1283
|
-
type: "text",
|
|
1284
|
-
raw: e,
|
|
1285
|
-
text: e
|
|
1286
|
-
};
|
|
1287
|
-
}
|
|
1288
|
-
return cr(n, i, n[0], this.lexer, this.rules);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
emStrong(e, t, n = "") {
|
|
1292
|
-
let r = this.rules.inline.emStrongLDelim.exec(e);
|
|
1293
|
-
if (!(!r || !r[1] && !r[2] && !r[3] && !r[4] || r[4] && n.match(this.rules.other.unicodeAlphaNumeric)) && (!(r[1] || r[3]) || !n || this.rules.inline.punctuation.exec(n))) {
|
|
1294
|
-
let i = [...r[0]].length - 1, a, o, s = i, c = 0, l = r[0][0], u = n === l, d = l === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
1295
|
-
for (d.lastIndex = 0, t = t.slice(-1 * e.length + i); (r = d.exec(t)) !== null;) {
|
|
1296
|
-
if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a) continue;
|
|
1297
|
-
if (o = [...a].length, r[3] || r[4]) {
|
|
1298
|
-
s += o;
|
|
1299
|
-
continue;
|
|
1300
|
-
}
|
|
1301
|
-
if (r[5] || r[6]) {
|
|
1302
|
-
if (i % 3 && !((i + o) % 3)) {
|
|
1303
|
-
c += o;
|
|
1304
|
-
continue;
|
|
1305
|
-
}
|
|
1306
|
-
if (u) break;
|
|
1307
|
-
}
|
|
1308
|
-
if (s -= o, s > 0) continue;
|
|
1309
|
-
o = Math.min(o, o + s + c);
|
|
1310
|
-
let t = [...r[0]][0].length, n = e.slice(0, i + r.index + t + o);
|
|
1311
|
-
if (Math.min(i, o) % 2) {
|
|
1312
|
-
let e = n.slice(1, -1);
|
|
1313
|
-
return {
|
|
1314
|
-
type: "em",
|
|
1315
|
-
raw: n,
|
|
1316
|
-
text: e,
|
|
1317
|
-
tokens: this.lexer.inlineTokens(e)
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
let l = n.slice(2, -2);
|
|
1321
|
-
return {
|
|
1322
|
-
type: "strong",
|
|
1323
|
-
raw: n,
|
|
1324
|
-
text: l,
|
|
1325
|
-
tokens: this.lexer.inlineTokens(l)
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
codespan(e) {
|
|
1331
|
-
let t = this.rules.inline.code.exec(e);
|
|
1332
|
-
if (t) {
|
|
1333
|
-
let e = t[2].replace(this.rules.other.newLineCharGlobal, " "), n = this.rules.other.nonSpaceChar.test(e), r = this.rules.other.startingSpaceChar.test(e) && this.rules.other.endingSpaceChar.test(e);
|
|
1334
|
-
return n && r && (e = e.substring(1, e.length - 1)), {
|
|
1335
|
-
type: "codespan",
|
|
1336
|
-
raw: t[0],
|
|
1337
|
-
text: e
|
|
1338
|
-
};
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
br(e) {
|
|
1342
|
-
let t = this.rules.inline.br.exec(e);
|
|
1343
|
-
if (t) return {
|
|
1344
|
-
type: "br",
|
|
1345
|
-
raw: t[0]
|
|
1346
|
-
};
|
|
1347
|
-
}
|
|
1348
|
-
del(e, t, n = "") {
|
|
1349
|
-
let r = this.rules.inline.delLDelim.exec(e);
|
|
1350
|
-
if (r && (!r[1] || !n || this.rules.inline.punctuation.exec(n))) {
|
|
1351
|
-
let n = [...r[0]].length - 1, i, a, o = n, s = this.rules.inline.delRDelim;
|
|
1352
|
-
for (s.lastIndex = 0, t = t.slice(-1 * e.length + n); (r = s.exec(t)) !== null;) {
|
|
1353
|
-
if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i || (a = [...i].length, a !== n)) continue;
|
|
1354
|
-
if (r[3] || r[4]) {
|
|
1355
|
-
o += a;
|
|
1356
|
-
continue;
|
|
1357
|
-
}
|
|
1358
|
-
if (o -= a, o > 0) continue;
|
|
1359
|
-
a = Math.min(a, a + o);
|
|
1360
|
-
let t = [...r[0]][0].length, s = e.slice(0, n + r.index + t + a), c = s.slice(n, -n);
|
|
1361
|
-
return {
|
|
1362
|
-
type: "del",
|
|
1363
|
-
raw: s,
|
|
1364
|
-
text: c,
|
|
1365
|
-
tokens: this.lexer.inlineTokens(c)
|
|
1366
|
-
};
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
autolink(e) {
|
|
1371
|
-
let t = this.rules.inline.autolink.exec(e);
|
|
1372
|
-
if (t) {
|
|
1373
|
-
let e, n;
|
|
1374
|
-
return t[2] === "@" ? (e = t[1], n = "mailto:" + e) : (e = t[1], n = e), {
|
|
1375
|
-
type: "link",
|
|
1376
|
-
raw: t[0],
|
|
1377
|
-
text: e,
|
|
1378
|
-
href: n,
|
|
1379
|
-
autolink: !0,
|
|
1380
|
-
tokens: [{
|
|
1381
|
-
type: "text",
|
|
1382
|
-
raw: e,
|
|
1383
|
-
text: e
|
|
1384
|
-
}]
|
|
1385
|
-
};
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
url(e) {
|
|
1389
|
-
let t;
|
|
1390
|
-
if (t = this.rules.inline.url.exec(e)) {
|
|
1391
|
-
let e, n;
|
|
1392
|
-
if (t[2] === "@") e = t[0], n = "mailto:" + e;
|
|
1393
|
-
else {
|
|
1394
|
-
let r;
|
|
1395
|
-
do
|
|
1396
|
-
r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
1397
|
-
while (r !== t[0]);
|
|
1398
|
-
e = t[0], n = t[1] === "www." ? "http://" + t[0] : t[0];
|
|
1399
|
-
}
|
|
1400
|
-
return {
|
|
1401
|
-
type: "link",
|
|
1402
|
-
raw: t[0],
|
|
1403
|
-
text: e,
|
|
1404
|
-
href: n,
|
|
1405
|
-
autolink: !0,
|
|
1406
|
-
tokens: [{
|
|
1407
|
-
type: "text",
|
|
1408
|
-
raw: e,
|
|
1409
|
-
text: e
|
|
1410
|
-
}]
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
inlineText(e) {
|
|
1415
|
-
let t = this.rules.inline.text.exec(e);
|
|
1416
|
-
if (t) {
|
|
1417
|
-
let e = this.lexer.state.inRawBlock;
|
|
1418
|
-
return {
|
|
1419
|
-
type: "text",
|
|
1420
|
-
raw: t[0],
|
|
1421
|
-
text: e ? t[0] : nr(t[0]),
|
|
1422
|
-
escaped: e
|
|
1423
|
-
};
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
}, J = class e {
|
|
1427
|
-
tokens;
|
|
1428
|
-
options;
|
|
1429
|
-
state;
|
|
1430
|
-
inlineQueue;
|
|
1431
|
-
tokenizer;
|
|
1432
|
-
constructor(e) {
|
|
1433
|
-
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || j, this.options.tokenizer = this.options.tokenizer || new q(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
1434
|
-
inLink: !1,
|
|
1435
|
-
inRawBlock: !1,
|
|
1436
|
-
linkEmitted: !1,
|
|
1437
|
-
top: !0
|
|
1438
|
-
};
|
|
1439
|
-
let t = {
|
|
1440
|
-
other: F,
|
|
1441
|
-
block: H.normal,
|
|
1442
|
-
inline: U.normal
|
|
1443
|
-
};
|
|
1444
|
-
this.options.pedantic ? (t.block = H.pedantic, t.inline = U.pedantic) : this.options.gfm && (t.block = H.gfm, t.inline = this.options.breaks ? U.breaks : U.gfm), this.tokenizer.rules = t;
|
|
1445
|
-
}
|
|
1446
|
-
static get rules() {
|
|
1447
|
-
return {
|
|
1448
|
-
block: H,
|
|
1449
|
-
inline: U
|
|
1450
|
-
};
|
|
1451
|
-
}
|
|
1452
|
-
static lex(t, n) {
|
|
1453
|
-
return new e(n).lex(t);
|
|
1454
|
-
}
|
|
1455
|
-
static lexInline(t, n) {
|
|
1456
|
-
return new e(n).inlineTokens(t);
|
|
1457
|
-
}
|
|
1458
|
-
lex(e) {
|
|
1459
|
-
e = e.replace(F.carriageReturn, "\n"), this.blockTokens(e, this.tokens);
|
|
1460
|
-
for (let e = 0; e < this.inlineQueue.length; e++) {
|
|
1461
|
-
let t = this.inlineQueue[e];
|
|
1462
|
-
this.inlineTokens(t.src, t.tokens);
|
|
1463
|
-
}
|
|
1464
|
-
return this.inlineQueue = [], this.tokens;
|
|
1465
|
-
}
|
|
1466
|
-
blockTokens(e, t = [], n = !1) {
|
|
1467
|
-
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(F.tabCharGlobal, " ").replace(F.spaceLine, ""));
|
|
1468
|
-
let r = 1 / 0;
|
|
1469
|
-
for (; e;) {
|
|
1470
|
-
if (e.length < r) r = e.length;
|
|
1471
|
-
else {
|
|
1472
|
-
this.infiniteLoopError(e.charCodeAt(0));
|
|
1473
|
-
break;
|
|
1474
|
-
}
|
|
1475
|
-
let i;
|
|
1476
|
-
if (this.options.extensions?.block?.some((n) => (i = n.call({ lexer: this }, e, t)) ? (e = e.substring(i.raw.length), t.push(i), !0) : !1)) continue;
|
|
1477
|
-
if (i = this.tokenizer.space(e)) {
|
|
1478
|
-
e = e.substring(i.raw.length);
|
|
1479
|
-
let n = t.at(-1);
|
|
1480
|
-
i.raw.length === 1 && n !== void 0 ? n.raw += "\n" : t.push(i);
|
|
1481
|
-
continue;
|
|
1482
|
-
}
|
|
1483
|
-
if (i = this.tokenizer.code(e)) {
|
|
1484
|
-
e = e.substring(i.raw.length);
|
|
1485
|
-
let n = t.at(-1);
|
|
1486
|
-
n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.text, this.inlineQueue.at(-1).src = n.text) : t.push(i);
|
|
1487
|
-
continue;
|
|
1488
|
-
}
|
|
1489
|
-
if (i = this.tokenizer.fences(e)) {
|
|
1490
|
-
e = e.substring(i.raw.length), t.push(i);
|
|
1491
|
-
continue;
|
|
1492
|
-
}
|
|
1493
|
-
if (i = this.tokenizer.heading(e)) {
|
|
1494
|
-
e = e.substring(i.raw.length), t.push(i);
|
|
1495
|
-
continue;
|
|
1496
|
-
}
|
|
1497
|
-
if (i = this.tokenizer.hr(e)) {
|
|
1498
|
-
e = e.substring(i.raw.length), t.push(i);
|
|
1499
|
-
continue;
|
|
1500
|
-
}
|
|
1501
|
-
if (i = this.tokenizer.blockquote(e)) {
|
|
1502
|
-
e = e.substring(i.raw.length), t.push(i);
|
|
1503
|
-
continue;
|
|
1504
|
-
}
|
|
1505
|
-
if (i = this.tokenizer.list(e)) {
|
|
1506
|
-
e = e.substring(i.raw.length), t.push(i);
|
|
1507
|
-
continue;
|
|
1508
|
-
}
|
|
1509
|
-
if (i = this.tokenizer.html(e)) {
|
|
1510
|
-
e = e.substring(i.raw.length), t.push(i);
|
|
1511
|
-
continue;
|
|
1512
|
-
}
|
|
1513
|
-
if (i = this.tokenizer.def(e)) {
|
|
1514
|
-
e = e.substring(i.raw.length);
|
|
1515
|
-
let n = t.at(-1);
|
|
1516
|
-
n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.raw, this.inlineQueue.at(-1).src = n.text) : this.tokens.links[i.tag] || (this.tokens.links[i.tag] = {
|
|
1517
|
-
href: i.href,
|
|
1518
|
-
title: i.title
|
|
1519
|
-
}, t.push(i));
|
|
1520
|
-
continue;
|
|
1521
|
-
}
|
|
1522
|
-
if (i = this.tokenizer.table(e)) {
|
|
1523
|
-
e = e.substring(i.raw.length), t.push(i);
|
|
1524
|
-
continue;
|
|
1525
|
-
}
|
|
1526
|
-
if (i = this.tokenizer.lheading(e)) {
|
|
1527
|
-
e = e.substring(i.raw.length), t.push(i);
|
|
1528
|
-
continue;
|
|
1529
|
-
}
|
|
1530
|
-
let a = e;
|
|
1531
|
-
if (this.options.extensions?.startBlock) {
|
|
1532
|
-
let t = 1 / 0, n = e.slice(1), r;
|
|
1533
|
-
this.options.extensions.startBlock.forEach((e) => {
|
|
1534
|
-
r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r));
|
|
1535
|
-
}), t < 1 / 0 && t >= 0 && (a = e.substring(0, t + 1));
|
|
1536
|
-
}
|
|
1537
|
-
if (this.state.top && (i = this.tokenizer.paragraph(a))) {
|
|
1538
|
-
let r = t.at(-1);
|
|
1539
|
-
n && r?.type === "paragraph" ? (r.raw += (r.raw.endsWith("\n") ? "" : "\n") + i.raw, r.text += "\n" + i.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = r.text) : t.push(i), n = a.length !== e.length, e = e.substring(i.raw.length);
|
|
1540
|
-
continue;
|
|
1541
|
-
}
|
|
1542
|
-
if (i = this.tokenizer.text(e)) {
|
|
1543
|
-
e = e.substring(i.raw.length);
|
|
1544
|
-
let n = t.at(-1);
|
|
1545
|
-
n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = n.text) : t.push(i);
|
|
1546
|
-
continue;
|
|
1547
|
-
}
|
|
1548
|
-
if (e) {
|
|
1549
|
-
this.infiniteLoopError(e.charCodeAt(0));
|
|
1550
|
-
break;
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
return this.state.top = !0, t;
|
|
1554
|
-
}
|
|
1555
|
-
inline(e, t = []) {
|
|
1556
|
-
return this.inlineQueue.push({
|
|
1557
|
-
src: e,
|
|
1558
|
-
tokens: t
|
|
1559
|
-
}), t;
|
|
1560
|
-
}
|
|
1561
|
-
linkInText(e) {
|
|
1562
|
-
if (!e.includes("[")) return !1;
|
|
1563
|
-
let t = this.tokenizer.rules.inline.link;
|
|
1564
|
-
for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t.test(n[0]) && e.charAt(n.index - 1) !== "!") return !0;
|
|
1565
|
-
for (let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
|
|
1566
|
-
let e = t[0], n = e.lastIndexOf("[");
|
|
1567
|
-
if (e.charAt(0) !== "!" && Object.hasOwn(this.tokens.links, K(e.slice(n + 1, -1))) && !(n > 1 && this.linkInText(e.slice(1, n - 1)))) return !0;
|
|
1568
|
-
}
|
|
1569
|
-
return !1;
|
|
1570
|
-
}
|
|
1571
|
-
inlineTokens(e, t = []) {
|
|
1572
|
-
this.tokenizer.lexer = this;
|
|
1573
|
-
let n = e;
|
|
1574
|
-
if (this.tokens.links && e.includes("[")) {
|
|
1575
|
-
let e = this.tokenizer.rules.inline.reflinkSearch, t = (n) => {
|
|
1576
|
-
let r = n.lastIndexOf("[");
|
|
1577
|
-
if (!Object.hasOwn(this.tokens.links, K(n.slice(r + 1, -1)))) return n;
|
|
1578
|
-
if (r > 1 && n.charAt(0) !== "!") {
|
|
1579
|
-
let i = n.slice(1, r - 1);
|
|
1580
|
-
if (this.linkInText(i)) return "[" + i.replace(e, t) + "][" + "a".repeat(n.length - r - 2) + "]";
|
|
1581
|
-
}
|
|
1582
|
-
return "[" + "a".repeat(n.length - 2) + "]";
|
|
1583
|
-
};
|
|
1584
|
-
n = n.replace(e, t);
|
|
1585
|
-
}
|
|
1586
|
-
n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (e) => "+".repeat(e.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (e, t, n) => {
|
|
1587
|
-
let r = n ? n.length : 0;
|
|
1588
|
-
return e.slice(0, r) + "[" + "a".repeat(e.length - r - 2) + "]";
|
|
1589
|
-
}), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
1590
|
-
let r = !1, i = "", a = 1 / 0;
|
|
1591
|
-
for (; e;) {
|
|
1592
|
-
if (e.length < a) a = e.length;
|
|
1593
|
-
else {
|
|
1594
|
-
this.infiniteLoopError(e.charCodeAt(0));
|
|
1595
|
-
break;
|
|
1596
|
-
}
|
|
1597
|
-
r || (i = ""), r = !1;
|
|
1598
|
-
let o;
|
|
1599
|
-
if (this.options.extensions?.inline?.some((n) => (o = n.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), !0) : !1)) continue;
|
|
1600
|
-
if (o = this.tokenizer.escape(e)) {
|
|
1601
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1602
|
-
continue;
|
|
1603
|
-
}
|
|
1604
|
-
if (o = this.tokenizer.tag(e)) {
|
|
1605
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1606
|
-
continue;
|
|
1607
|
-
}
|
|
1608
|
-
if (o = this.tokenizer.link(e)) {
|
|
1609
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1610
|
-
continue;
|
|
1611
|
-
}
|
|
1612
|
-
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
1613
|
-
e = e.substring(o.raw.length);
|
|
1614
|
-
let n = t.at(-1);
|
|
1615
|
-
o.type === "text" && n?.type === "text" ? (n.raw += o.raw, n.text += o.text) : t.push(o);
|
|
1616
|
-
continue;
|
|
1617
|
-
}
|
|
1618
|
-
if (o = this.tokenizer.emStrong(e, n, i)) {
|
|
1619
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1620
|
-
continue;
|
|
1621
|
-
}
|
|
1622
|
-
if (o = this.tokenizer.codespan(e)) {
|
|
1623
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1624
|
-
continue;
|
|
1625
|
-
}
|
|
1626
|
-
if (o = this.tokenizer.br(e)) {
|
|
1627
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1628
|
-
continue;
|
|
1629
|
-
}
|
|
1630
|
-
if (o = this.tokenizer.del(e, n, i)) {
|
|
1631
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1632
|
-
continue;
|
|
1633
|
-
}
|
|
1634
|
-
if (o = this.tokenizer.autolink(e)) {
|
|
1635
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1636
|
-
continue;
|
|
1637
|
-
}
|
|
1638
|
-
if (!this.state.inLink && (o = this.tokenizer.url(e))) {
|
|
1639
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
1640
|
-
continue;
|
|
1641
|
-
}
|
|
1642
|
-
let s = e;
|
|
1643
|
-
if (this.options.extensions?.startInline) {
|
|
1644
|
-
let t = 1 / 0, n = e.slice(1), r;
|
|
1645
|
-
this.options.extensions.startInline.forEach((e) => {
|
|
1646
|
-
r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r));
|
|
1647
|
-
}), t < 1 / 0 && t >= 0 && (s = e.substring(0, t + 1));
|
|
1648
|
-
}
|
|
1649
|
-
if (o = this.tokenizer.inlineText(s)) {
|
|
1650
|
-
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (i = o.raw.slice(-1)), r = !0;
|
|
1651
|
-
let n = t.at(-1);
|
|
1652
|
-
n?.type === "text" ? (n.raw += o.raw, n.text += o.text) : t.push(o);
|
|
1653
|
-
continue;
|
|
1654
|
-
}
|
|
1655
|
-
if (e) {
|
|
1656
|
-
this.infiniteLoopError(e.charCodeAt(0));
|
|
1657
|
-
break;
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
return t;
|
|
1661
|
-
}
|
|
1662
|
-
infiniteLoopError(e) {
|
|
1663
|
-
let t = "Infinite loop on byte: " + e;
|
|
1664
|
-
if (this.options.silent) console.error(t);
|
|
1665
|
-
else throw Error(t);
|
|
1666
|
-
}
|
|
1667
|
-
}, Y = class {
|
|
1668
|
-
options;
|
|
1669
|
-
parser;
|
|
1670
|
-
constructor(e) {
|
|
1671
|
-
this.options = e || j;
|
|
1672
|
-
}
|
|
1673
|
-
space(e) {
|
|
1674
|
-
return "";
|
|
1675
|
-
}
|
|
1676
|
-
code({ text: e, lang: t, escaped: n }) {
|
|
1677
|
-
let r = (t || "").match(F.notSpaceStart)?.[0], i = e ? e.replace(F.endingNewline, "") + "\n" : "";
|
|
1678
|
-
return r ? "<pre><code class=\"language-" + W(r) + "\">" + (n ? i : W(i, !0)) + "</code></pre>\n" : "<pre><code>" + (n ? i : W(i, !0)) + "</code></pre>\n";
|
|
1679
|
-
}
|
|
1680
|
-
blockquote({ tokens: e }) {
|
|
1681
|
-
return `<blockquote>
|
|
1682
|
-
${this.parser.parse(e)}</blockquote>
|
|
1683
|
-
`;
|
|
1684
|
-
}
|
|
1685
|
-
html({ text: e }) {
|
|
1686
|
-
return e;
|
|
1687
|
-
}
|
|
1688
|
-
def(e) {
|
|
1689
|
-
return "";
|
|
1690
|
-
}
|
|
1691
|
-
heading({ tokens: e, depth: t }) {
|
|
1692
|
-
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
1693
|
-
`;
|
|
1694
|
-
}
|
|
1695
|
-
hr(e) {
|
|
1696
|
-
return "<hr>\n";
|
|
1697
|
-
}
|
|
1698
|
-
list(e) {
|
|
1699
|
-
let t = e.ordered, n = e.start, r = "";
|
|
1700
|
-
for (let t = 0; t < e.items.length; t++) {
|
|
1701
|
-
let n = e.items[t];
|
|
1702
|
-
r += this.listitem(n);
|
|
1703
|
-
}
|
|
1704
|
-
let i = t ? "ol" : "ul", a = t && n !== 1 ? " start=\"" + n + "\"" : "";
|
|
1705
|
-
return "<" + i + a + ">\n" + r + "</" + i + ">\n";
|
|
1706
|
-
}
|
|
1707
|
-
listitem(e) {
|
|
1708
|
-
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
1709
|
-
`;
|
|
1710
|
-
}
|
|
1711
|
-
checkbox({ checked: e }) {
|
|
1712
|
-
return "<input " + (e ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\"> ";
|
|
1713
|
-
}
|
|
1714
|
-
paragraph({ tokens: e }) {
|
|
1715
|
-
return `<p>${this.parser.parseInline(e)}</p>
|
|
1716
|
-
`;
|
|
1717
|
-
}
|
|
1718
|
-
table(e) {
|
|
1719
|
-
let t = "", n = "";
|
|
1720
|
-
for (let t = 0; t < e.header.length; t++) n += this.tablecell(e.header[t]);
|
|
1721
|
-
t += this.tablerow({ text: n });
|
|
1722
|
-
let r = "";
|
|
1723
|
-
for (let t = 0; t < e.rows.length; t++) {
|
|
1724
|
-
let i = e.rows[t];
|
|
1725
|
-
n = "";
|
|
1726
|
-
for (let e = 0; e < i.length; e++) n += this.tablecell(i[e]);
|
|
1727
|
-
r += this.tablerow({ text: n });
|
|
1728
|
-
}
|
|
1729
|
-
return r &&= `<tbody>${r}</tbody>`, "<table>\n<thead>\n" + t + "</thead>\n" + r + "</table>\n";
|
|
1730
|
-
}
|
|
1731
|
-
tablerow({ text: e }) {
|
|
1732
|
-
return `<tr>
|
|
1733
|
-
${e}</tr>
|
|
1734
|
-
`;
|
|
1735
|
-
}
|
|
1736
|
-
tablecell(e) {
|
|
1737
|
-
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
1738
|
-
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
1739
|
-
`;
|
|
1740
|
-
}
|
|
1741
|
-
strong({ tokens: e }) {
|
|
1742
|
-
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
1743
|
-
}
|
|
1744
|
-
em({ tokens: e }) {
|
|
1745
|
-
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
1746
|
-
}
|
|
1747
|
-
codespan({ text: e }) {
|
|
1748
|
-
return `<code>${W(e, !0)}</code>`;
|
|
1749
|
-
}
|
|
1750
|
-
br(e) {
|
|
1751
|
-
return "<br>";
|
|
1752
|
-
}
|
|
1753
|
-
del({ tokens: e }) {
|
|
1754
|
-
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
1755
|
-
}
|
|
1756
|
-
link({ href: e, title: t, text: n, tokens: r, autolink: i }) {
|
|
1757
|
-
let a = i ? W(n, !0) : this.parser.parseInline(r), o = rr(e);
|
|
1758
|
-
if (o === null) return a;
|
|
1759
|
-
e = W(o, i);
|
|
1760
|
-
let s = "<a href=\"" + e + "\"";
|
|
1761
|
-
return t && (s += " title=\"" + W(t) + "\""), s += ">" + a + "</a>", s;
|
|
1762
|
-
}
|
|
1763
|
-
image({ href: e, title: t, text: n, tokens: r }) {
|
|
1764
|
-
r && (n = this.parser.parseInline(r, this.parser.textRenderer));
|
|
1765
|
-
let i = rr(e);
|
|
1766
|
-
if (i === null) return W(n);
|
|
1767
|
-
e = i;
|
|
1768
|
-
let a = `<img src="${W(e)}" alt="${W(n)}"`;
|
|
1769
|
-
return t && (a += ` title="${W(t)}"`), a += ">", a;
|
|
1770
|
-
}
|
|
1771
|
-
text(e) {
|
|
1772
|
-
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : W(e.text);
|
|
1773
|
-
}
|
|
1774
|
-
}, dr = class {
|
|
1775
|
-
strong({ text: e }) {
|
|
1776
|
-
return e;
|
|
1777
|
-
}
|
|
1778
|
-
em({ text: e }) {
|
|
1779
|
-
return e;
|
|
1780
|
-
}
|
|
1781
|
-
codespan({ text: e }) {
|
|
1782
|
-
return e;
|
|
1783
|
-
}
|
|
1784
|
-
del({ text: e }) {
|
|
1785
|
-
return e;
|
|
1786
|
-
}
|
|
1787
|
-
html({ text: e }) {
|
|
1788
|
-
return e;
|
|
1789
|
-
}
|
|
1790
|
-
text({ text: e }) {
|
|
1791
|
-
return e;
|
|
1792
|
-
}
|
|
1793
|
-
link({ text: e }) {
|
|
1794
|
-
return "" + e;
|
|
1795
|
-
}
|
|
1796
|
-
image({ text: e }) {
|
|
1797
|
-
return "" + e;
|
|
1798
|
-
}
|
|
1799
|
-
br() {
|
|
1800
|
-
return "";
|
|
1801
|
-
}
|
|
1802
|
-
checkbox({ raw: e }) {
|
|
1803
|
-
return e;
|
|
1804
|
-
}
|
|
1805
|
-
}, X = class e {
|
|
1806
|
-
options;
|
|
1807
|
-
renderer;
|
|
1808
|
-
textRenderer;
|
|
1809
|
-
constructor(e) {
|
|
1810
|
-
this.options = e || j, 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 dr();
|
|
1811
|
-
}
|
|
1812
|
-
static parse(t, n) {
|
|
1813
|
-
return new e(n).parse(t);
|
|
1814
|
-
}
|
|
1815
|
-
static parseInline(t, n) {
|
|
1816
|
-
return new e(n).parseInline(t);
|
|
1817
|
-
}
|
|
1818
|
-
parse(e) {
|
|
1819
|
-
this.renderer.parser = this;
|
|
1820
|
-
let t = "";
|
|
1821
|
-
for (let n = 0; n < e.length; n++) {
|
|
1822
|
-
let r = e[n];
|
|
1823
|
-
if (this.options.extensions?.renderers?.[r.type]) {
|
|
1824
|
-
let e = r, n = this.options.extensions.renderers[e.type].call({ parser: this }, e);
|
|
1825
|
-
if (n !== !1 || ![
|
|
1826
|
-
"space",
|
|
1827
|
-
"hr",
|
|
1828
|
-
"heading",
|
|
1829
|
-
"code",
|
|
1830
|
-
"table",
|
|
1831
|
-
"blockquote",
|
|
1832
|
-
"list",
|
|
1833
|
-
"checkbox",
|
|
1834
|
-
"html",
|
|
1835
|
-
"def",
|
|
1836
|
-
"paragraph",
|
|
1837
|
-
"text"
|
|
1838
|
-
].includes(e.type)) {
|
|
1839
|
-
t += n || "";
|
|
1840
|
-
continue;
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
let i = r;
|
|
1844
|
-
switch (i.type) {
|
|
1845
|
-
case "space":
|
|
1846
|
-
t += this.renderer.space(i);
|
|
1847
|
-
break;
|
|
1848
|
-
case "hr":
|
|
1849
|
-
t += this.renderer.hr(i);
|
|
1850
|
-
break;
|
|
1851
|
-
case "heading":
|
|
1852
|
-
t += this.renderer.heading(i);
|
|
1853
|
-
break;
|
|
1854
|
-
case "code":
|
|
1855
|
-
t += this.renderer.code(i);
|
|
1856
|
-
break;
|
|
1857
|
-
case "table":
|
|
1858
|
-
t += this.renderer.table(i);
|
|
1859
|
-
break;
|
|
1860
|
-
case "blockquote":
|
|
1861
|
-
t += this.renderer.blockquote(i);
|
|
1862
|
-
break;
|
|
1863
|
-
case "list":
|
|
1864
|
-
t += this.renderer.list(i);
|
|
1865
|
-
break;
|
|
1866
|
-
case "checkbox":
|
|
1867
|
-
t += this.renderer.checkbox(i);
|
|
1868
|
-
break;
|
|
1869
|
-
case "html":
|
|
1870
|
-
t += this.renderer.html(i);
|
|
1871
|
-
break;
|
|
1872
|
-
case "def":
|
|
1873
|
-
t += this.renderer.def(i);
|
|
1874
|
-
break;
|
|
1875
|
-
case "paragraph":
|
|
1876
|
-
t += this.renderer.paragraph(i);
|
|
1877
|
-
break;
|
|
1878
|
-
case "text":
|
|
1879
|
-
t += this.renderer.text(i);
|
|
1880
|
-
break;
|
|
1881
|
-
default: {
|
|
1882
|
-
let e = "Token with \"" + i.type + "\" type was not found.";
|
|
1883
|
-
if (this.options.silent) return console.error(e), "";
|
|
1884
|
-
throw Error(e);
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
return t;
|
|
1889
|
-
}
|
|
1890
|
-
parseInline(e, t = this.renderer) {
|
|
1891
|
-
this.renderer.parser = this;
|
|
1892
|
-
let n = "";
|
|
1893
|
-
for (let r = 0; r < e.length; r++) {
|
|
1894
|
-
let i = e[r];
|
|
1895
|
-
if (this.options.extensions?.renderers?.[i.type]) {
|
|
1896
|
-
let e = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
1897
|
-
if (e !== !1 || ![
|
|
1898
|
-
"escape",
|
|
1899
|
-
"html",
|
|
1900
|
-
"link",
|
|
1901
|
-
"image",
|
|
1902
|
-
"checkbox",
|
|
1903
|
-
"strong",
|
|
1904
|
-
"em",
|
|
1905
|
-
"codespan",
|
|
1906
|
-
"br",
|
|
1907
|
-
"del",
|
|
1908
|
-
"text"
|
|
1909
|
-
].includes(i.type)) {
|
|
1910
|
-
n += e || "";
|
|
1911
|
-
continue;
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
let a = i;
|
|
1915
|
-
switch (a.type) {
|
|
1916
|
-
case "escape":
|
|
1917
|
-
n += t.text(a);
|
|
1918
|
-
break;
|
|
1919
|
-
case "html":
|
|
1920
|
-
n += t.html(a);
|
|
1921
|
-
break;
|
|
1922
|
-
case "link":
|
|
1923
|
-
n += t.link(a);
|
|
1924
|
-
break;
|
|
1925
|
-
case "image":
|
|
1926
|
-
n += t.image(a);
|
|
1927
|
-
break;
|
|
1928
|
-
case "checkbox":
|
|
1929
|
-
n += t.checkbox(a);
|
|
1930
|
-
break;
|
|
1931
|
-
case "strong":
|
|
1932
|
-
n += t.strong(a);
|
|
1933
|
-
break;
|
|
1934
|
-
case "em":
|
|
1935
|
-
n += t.em(a);
|
|
1936
|
-
break;
|
|
1937
|
-
case "codespan":
|
|
1938
|
-
n += t.codespan(a);
|
|
1939
|
-
break;
|
|
1940
|
-
case "br":
|
|
1941
|
-
n += t.br(a);
|
|
1942
|
-
break;
|
|
1943
|
-
case "del":
|
|
1944
|
-
n += t.del(a);
|
|
1945
|
-
break;
|
|
1946
|
-
case "text":
|
|
1947
|
-
n += t.text(a);
|
|
1948
|
-
break;
|
|
1949
|
-
default: {
|
|
1950
|
-
let e = "Token with \"" + a.type + "\" type was not found.";
|
|
1951
|
-
if (this.options.silent) return console.error(e), "";
|
|
1952
|
-
throw Error(e);
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
return n;
|
|
1957
|
-
}
|
|
1958
|
-
}, Z = class {
|
|
1959
|
-
options;
|
|
1960
|
-
block;
|
|
1961
|
-
constructor(e) {
|
|
1962
|
-
this.options = e || j;
|
|
1963
|
-
}
|
|
1964
|
-
static passThroughHooks = /* @__PURE__ */ new Set([
|
|
1965
|
-
"preprocess",
|
|
1966
|
-
"postprocess",
|
|
1967
|
-
"processAllTokens",
|
|
1968
|
-
"emStrongMask"
|
|
1969
|
-
]);
|
|
1970
|
-
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set([
|
|
1971
|
-
"preprocess",
|
|
1972
|
-
"postprocess",
|
|
1973
|
-
"processAllTokens"
|
|
1974
|
-
]);
|
|
1975
|
-
preprocess(e) {
|
|
1976
|
-
return e;
|
|
1977
|
-
}
|
|
1978
|
-
postprocess(e) {
|
|
1979
|
-
return e;
|
|
1980
|
-
}
|
|
1981
|
-
processAllTokens(e) {
|
|
1982
|
-
return e;
|
|
1983
|
-
}
|
|
1984
|
-
emStrongMask(e) {
|
|
1985
|
-
return e;
|
|
1986
|
-
}
|
|
1987
|
-
provideLexer(e = this.block) {
|
|
1988
|
-
return e ? J.lex : J.lexInline;
|
|
1989
|
-
}
|
|
1990
|
-
provideParser(e = this.block) {
|
|
1991
|
-
return e ? X.parse : X.parseInline;
|
|
1992
|
-
}
|
|
1993
|
-
}, Q = new class {
|
|
1994
|
-
defaults = Ut();
|
|
1995
|
-
options = this.setOptions;
|
|
1996
|
-
parse = this.parseMarkdown(!0);
|
|
1997
|
-
parseInline = this.parseMarkdown(!1);
|
|
1998
|
-
Parser = X;
|
|
1999
|
-
Renderer = Y;
|
|
2000
|
-
TextRenderer = dr;
|
|
2001
|
-
Lexer = J;
|
|
2002
|
-
Tokenizer = q;
|
|
2003
|
-
Hooks = Z;
|
|
2004
|
-
constructor(...e) {
|
|
2005
|
-
this.use(...e);
|
|
2006
|
-
}
|
|
2007
|
-
walkTokens(e, t) {
|
|
2008
|
-
let n = [];
|
|
2009
|
-
for (let r of e) switch (n = n.concat(t.call(this, r)), r.type) {
|
|
2010
|
-
case "table": {
|
|
2011
|
-
let e = r;
|
|
2012
|
-
for (let r of e.header) n = n.concat(this.walkTokens(r.tokens, t));
|
|
2013
|
-
for (let r of e.rows) for (let e of r) n = n.concat(this.walkTokens(e.tokens, t));
|
|
2014
|
-
break;
|
|
2015
|
-
}
|
|
2016
|
-
case "list": {
|
|
2017
|
-
let e = r;
|
|
2018
|
-
n = n.concat(this.walkTokens(e.items, t));
|
|
2019
|
-
break;
|
|
2020
|
-
}
|
|
2021
|
-
default: {
|
|
2022
|
-
let e = r;
|
|
2023
|
-
this.defaults.extensions?.childTokens?.[e.type] ? this.defaults.extensions.childTokens[e.type].forEach((r) => {
|
|
2024
|
-
let i = e[r].flat(1 / 0);
|
|
2025
|
-
n = n.concat(this.walkTokens(i, t));
|
|
2026
|
-
}) : e.tokens && (n = n.concat(this.walkTokens(e.tokens, t)));
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
return n;
|
|
2030
|
-
}
|
|
2031
|
-
use(...e) {
|
|
2032
|
-
let t = this.defaults.extensions || {
|
|
2033
|
-
renderers: {},
|
|
2034
|
-
childTokens: {}
|
|
2035
|
-
};
|
|
2036
|
-
return e.forEach((e) => {
|
|
2037
|
-
let n = { ...e };
|
|
2038
|
-
if (n.async = this.defaults.async || n.async || !1, e.extensions && (e.extensions.forEach((e) => {
|
|
2039
|
-
if (!e.name) throw Error("extension name required");
|
|
2040
|
-
if ("renderer" in e) {
|
|
2041
|
-
let n = t.renderers[e.name];
|
|
2042
|
-
n ? t.renderers[e.name] = function(...t) {
|
|
2043
|
-
let r = e.renderer.apply(this, t);
|
|
2044
|
-
return r === !1 && (r = n.apply(this, t)), r;
|
|
2045
|
-
} : t.renderers[e.name] = e.renderer;
|
|
2046
|
-
}
|
|
2047
|
-
if ("tokenizer" in e) {
|
|
2048
|
-
if (!e.level || e.level !== "block" && e.level !== "inline") throw Error("extension level must be 'block' or 'inline'");
|
|
2049
|
-
let n = t[e.level];
|
|
2050
|
-
n ? n.unshift(e.tokenizer) : t[e.level] = [e.tokenizer], e.start && (e.level === "block" ? t.startBlock ? t.startBlock.push(e.start) : t.startBlock = [e.start] : e.level === "inline" && (t.startInline ? t.startInline.push(e.start) : t.startInline = [e.start]));
|
|
2051
|
-
}
|
|
2052
|
-
"childTokens" in e && e.childTokens && (t.childTokens[e.name] = e.childTokens);
|
|
2053
|
-
}), n.extensions = t), e.renderer) {
|
|
2054
|
-
let t = this.defaults.renderer || new Y(this.defaults);
|
|
2055
|
-
for (let n in e.renderer) {
|
|
2056
|
-
if (!(n in t)) throw Error(`renderer '${n}' does not exist`);
|
|
2057
|
-
if (["options", "parser"].includes(n)) continue;
|
|
2058
|
-
let r = n, i = e.renderer[r], a = t[r];
|
|
2059
|
-
t[r] = (...e) => {
|
|
2060
|
-
let n = i.apply(t, e);
|
|
2061
|
-
return n === !1 && (n = a.apply(t, e)), n || "";
|
|
2062
|
-
};
|
|
2063
|
-
}
|
|
2064
|
-
n.renderer = t;
|
|
2065
|
-
}
|
|
2066
|
-
if (e.tokenizer) {
|
|
2067
|
-
let t = this.defaults.tokenizer || new q(this.defaults);
|
|
2068
|
-
for (let n in e.tokenizer) {
|
|
2069
|
-
if (!(n in t)) throw Error(`tokenizer '${n}' does not exist`);
|
|
2070
|
-
if ([
|
|
2071
|
-
"options",
|
|
2072
|
-
"rules",
|
|
2073
|
-
"lexer"
|
|
2074
|
-
].includes(n)) continue;
|
|
2075
|
-
let r = n, i = e.tokenizer[r], a = t[r];
|
|
2076
|
-
t[r] = (...e) => {
|
|
2077
|
-
let n = i.apply(t, e);
|
|
2078
|
-
return n === !1 && (n = a.apply(t, e)), n;
|
|
2079
|
-
};
|
|
2080
|
-
}
|
|
2081
|
-
n.tokenizer = t;
|
|
2082
|
-
}
|
|
2083
|
-
if (e.hooks) {
|
|
2084
|
-
let t = this.defaults.hooks || new Z();
|
|
2085
|
-
for (let n in e.hooks) {
|
|
2086
|
-
if (!(n in t)) throw Error(`hook '${n}' does not exist`);
|
|
2087
|
-
if (["options", "block"].includes(n)) continue;
|
|
2088
|
-
let r = n, i = e.hooks[r], a = t[r];
|
|
2089
|
-
t[r] = Z.passThroughHooks.has(n) ? (e) => {
|
|
2090
|
-
if (this.defaults.async && Z.passThroughHooksRespectAsync.has(n)) return (async () => {
|
|
2091
|
-
let n = await i.call(t, e);
|
|
2092
|
-
return a.call(t, n);
|
|
2093
|
-
})();
|
|
2094
|
-
let r = i.call(t, e);
|
|
2095
|
-
return a.call(t, r);
|
|
2096
|
-
} : (...e) => {
|
|
2097
|
-
if (this.defaults.async) return (async () => {
|
|
2098
|
-
let n = await i.apply(t, e);
|
|
2099
|
-
return n === !1 && (n = await a.apply(t, e)), n;
|
|
2100
|
-
})();
|
|
2101
|
-
let n = i.apply(t, e);
|
|
2102
|
-
return n === !1 && (n = a.apply(t, e)), n;
|
|
2103
|
-
};
|
|
2104
|
-
}
|
|
2105
|
-
n.hooks = t;
|
|
2106
|
-
}
|
|
2107
|
-
if (e.walkTokens) {
|
|
2108
|
-
let t = this.defaults.walkTokens, r = e.walkTokens;
|
|
2109
|
-
n.walkTokens = function(e) {
|
|
2110
|
-
let n = [];
|
|
2111
|
-
return n.push(r.call(this, e)), t && (n = n.concat(t.call(this, e))), n;
|
|
2112
|
-
};
|
|
2113
|
-
}
|
|
2114
|
-
this.defaults = {
|
|
2115
|
-
...this.defaults,
|
|
2116
|
-
...n
|
|
2117
|
-
};
|
|
2118
|
-
}), this;
|
|
2119
|
-
}
|
|
2120
|
-
setOptions(e) {
|
|
2121
|
-
return this.defaults = {
|
|
2122
|
-
...this.defaults,
|
|
2123
|
-
...e
|
|
2124
|
-
}, this;
|
|
2125
|
-
}
|
|
2126
|
-
lexer(e, t) {
|
|
2127
|
-
return J.lex(e, t ?? this.defaults);
|
|
2128
|
-
}
|
|
2129
|
-
parser(e, t) {
|
|
2130
|
-
return X.parse(e, t ?? this.defaults);
|
|
2131
|
-
}
|
|
2132
|
-
parseMarkdown(e) {
|
|
2133
|
-
return (t, n) => {
|
|
2134
|
-
let r = { ...n }, i = {
|
|
2135
|
-
...this.defaults,
|
|
2136
|
-
...r
|
|
2137
|
-
}, a = this.onError(!!i.silent, !!i.async);
|
|
2138
|
-
if (this.defaults.async === !0 && r.async === !1) return a(/* @__PURE__ */ Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
2139
|
-
if (typeof t > "u" || t === null) return a(/* @__PURE__ */ Error("marked(): input parameter is undefined or null"));
|
|
2140
|
-
if (typeof t != "string") return a(/* @__PURE__ */ Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
|
|
2141
|
-
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
|
|
2142
|
-
let n = i.hooks ? await i.hooks.preprocess(t) : t, r = await (i.hooks ? await i.hooks.provideLexer(e) : e ? J.lex : J.lexInline)(n, i), a = i.hooks ? await i.hooks.processAllTokens(r) : r;
|
|
2143
|
-
i.walkTokens && await Promise.all(this.walkTokens(a, i.walkTokens));
|
|
2144
|
-
let o = await (i.hooks ? await i.hooks.provideParser(e) : e ? X.parse : X.parseInline)(a, i);
|
|
2145
|
-
return i.hooks ? await i.hooks.postprocess(o) : o;
|
|
2146
|
-
})().catch(a);
|
|
2147
|
-
try {
|
|
2148
|
-
i.hooks && (t = i.hooks.preprocess(t));
|
|
2149
|
-
let n = (i.hooks ? i.hooks.provideLexer(e) : e ? J.lex : J.lexInline)(t, i);
|
|
2150
|
-
i.hooks && (n = i.hooks.processAllTokens(n)), i.walkTokens && this.walkTokens(n, i.walkTokens);
|
|
2151
|
-
let r = (i.hooks ? i.hooks.provideParser(e) : e ? X.parse : X.parseInline)(n, i);
|
|
2152
|
-
return i.hooks && (r = i.hooks.postprocess(r)), r;
|
|
2153
|
-
} catch (e) {
|
|
2154
|
-
return a(e);
|
|
2155
|
-
}
|
|
2156
|
-
};
|
|
2157
|
-
}
|
|
2158
|
-
onError(e, t) {
|
|
2159
|
-
return (n) => {
|
|
2160
|
-
if (n.message += "\nPlease report this to https://github.com/markedjs/marked.", e) {
|
|
2161
|
-
let e = "<p>An error occurred:</p><pre>" + W(n.message + "", !0) + "</pre>";
|
|
2162
|
-
return t ? Promise.resolve(e) : e;
|
|
2163
|
-
}
|
|
2164
|
-
if (t) return Promise.reject(n);
|
|
2165
|
-
throw n;
|
|
2166
|
-
};
|
|
2167
|
-
}
|
|
2168
|
-
}();
|
|
2169
|
-
function $(e, t) {
|
|
2170
|
-
return Q.parse(e, t);
|
|
2171
|
-
}
|
|
2172
|
-
$.options = $.setOptions = function(e) {
|
|
2173
|
-
return Q.setOptions(e), $.defaults = Q.defaults, Wt($.defaults), $;
|
|
2174
|
-
}, $.getDefaults = Ut, $.defaults = j;
|
|
2175
|
-
function fr(...e) {
|
|
2176
|
-
return Q.use(...e), $.defaults = Q.defaults, Wt($.defaults), $;
|
|
2177
|
-
}
|
|
2178
|
-
$.use = fr, $.walkTokens = function(e, t) {
|
|
2179
|
-
return Q.walkTokens(e, t);
|
|
2180
|
-
}, $.parseInline = Q.parseInline, $.Parser = X, $.parser = X.parse, $.Renderer = Y, $.TextRenderer = dr, $.Lexer = J, $.lexer = J.lex, $.Tokenizer = q, $.Hooks = Z, $.parse = $, $.options, $.setOptions, $.walkTokens, $.parseInline, X.parse, J.lex;
|
|
2181
|
-
//#endregion
|
|
2182
|
-
//#region ../../packages/components/src/chat/PkStreamingMarkdown.vue?vue&type=script&setup=true&lang.ts
|
|
2183
|
-
var pr = ["innerHTML"], mr = 100, hr = /* @__PURE__ */ o({
|
|
2184
|
-
__name: "PkStreamingMarkdown",
|
|
2185
|
-
props: {
|
|
2186
|
-
markdown: { default: "" },
|
|
2187
|
-
loading: {
|
|
2188
|
-
type: Boolean,
|
|
2189
|
-
default: !1
|
|
2190
|
-
},
|
|
2191
|
-
animation: { default: "fadeIn" },
|
|
2192
|
-
animationDuration: { default: "0.3s" },
|
|
2193
|
-
isDark: {
|
|
2194
|
-
type: Boolean,
|
|
2195
|
-
default: !1
|
|
2196
|
-
},
|
|
2197
|
-
tailLength: { default: void 0 }
|
|
2198
|
-
},
|
|
2199
|
-
setup(o) {
|
|
2200
|
-
let s = o, { t: f } = te({ useScope: "global" }), p = null;
|
|
2201
|
-
function h() {
|
|
2202
|
-
return p ||= import("beautiful-mermaid"), p;
|
|
2203
|
-
}
|
|
2204
|
-
let re = null;
|
|
2205
|
-
function ie() {
|
|
2206
|
-
return re ||= import("katex").then((e) => e.default), re;
|
|
2207
|
-
}
|
|
2208
|
-
let ae = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n$]))\1(?=[\s?!.,:\uFF1F\uFF01\u3002\uFF0C\uFF1A]|$)/, se = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
|
2209
|
-
function ce(e) {
|
|
2210
|
-
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2211
|
-
}
|
|
2212
|
-
function _(e, t) {
|
|
2213
|
-
return `<span class="katex-pending" data-katex="${ce(e)}" data-display="${t}"></span>`;
|
|
2214
|
-
}
|
|
2215
|
-
$.use({ extensions: [{
|
|
2216
|
-
name: "inlineKatex",
|
|
2217
|
-
level: "inline",
|
|
2218
|
-
start: (e) => {
|
|
2219
|
-
let t = e.indexOf("$");
|
|
2220
|
-
if (t !== -1 && (t === 0 || e.charAt(t - 1) === " ")) return t;
|
|
2221
|
-
},
|
|
2222
|
-
tokenizer(e) {
|
|
2223
|
-
let t = e.match(ae);
|
|
2224
|
-
if (t) return {
|
|
2225
|
-
type: "inlineKatex",
|
|
2226
|
-
raw: t[0],
|
|
2227
|
-
text: t[2].trim(),
|
|
2228
|
-
displayMode: t[1].length === 2
|
|
2229
|
-
};
|
|
2230
|
-
},
|
|
2231
|
-
renderer(e) {
|
|
2232
|
-
return _(e.text, e.displayMode);
|
|
2233
|
-
}
|
|
2234
|
-
}, {
|
|
2235
|
-
name: "blockKatex",
|
|
2236
|
-
level: "block",
|
|
2237
|
-
tokenizer(e) {
|
|
2238
|
-
let t = e.match(se);
|
|
2239
|
-
if (t) return {
|
|
2240
|
-
type: "blockKatex",
|
|
2241
|
-
raw: t[0],
|
|
2242
|
-
text: t[2].trim(),
|
|
2243
|
-
displayMode: t[1].length === 2
|
|
2244
|
-
};
|
|
2245
|
-
},
|
|
2246
|
-
renderer(e) {
|
|
2247
|
-
return _(e.text, e.displayMode) + "\n";
|
|
2248
|
-
}
|
|
2249
|
-
}] }), $.use({ extensions: [{
|
|
2250
|
-
name: "thinking",
|
|
2251
|
-
level: "block",
|
|
2252
|
-
start: (e) => e.indexOf("<thinking>"),
|
|
2253
|
-
tokenizer(e) {
|
|
2254
|
-
let t = /^<thinking>([\s\S]*?)<\/thinking>/.exec(e);
|
|
2255
|
-
if (!t) return;
|
|
2256
|
-
let n = {
|
|
2257
|
-
type: "thinking",
|
|
2258
|
-
raw: t[0],
|
|
2259
|
-
text: t[1].trim(),
|
|
2260
|
-
tokens: []
|
|
2261
|
-
};
|
|
2262
|
-
return this.lexer.blockTokens(n.text, n.tokens), n;
|
|
2263
|
-
},
|
|
2264
|
-
renderer(e) {
|
|
2265
|
-
return `<div class="thinking-block">${this.parser.parse(e.tokens ?? [])}</div>`;
|
|
2266
|
-
}
|
|
2267
|
-
}] });
|
|
2268
|
-
let v = new $.Renderer(), y = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">"), le = /^(?:javascript|data|vbscript|file):/i;
|
|
2269
|
-
v.link = function({ href: e, title: t, tokens: r }) {
|
|
2270
|
-
let i = this.parser.parseInline(r), a = (e ?? "").trim().replace(/[\x00-\x1f]/g, "");
|
|
2271
|
-
if (!a || le.test(a)) return i;
|
|
2272
|
-
let o = t ? ` title="${y(t)}"` : "", s = n(a) ? "" : " target=\"_blank\" rel=\"noopener noreferrer\"";
|
|
2273
|
-
return `<a href="${y(a)}"${o}${s}>${i}</a>`;
|
|
2274
|
-
}, v.table = function(e) {
|
|
2275
|
-
return `<div class="table-wrapper">${$.Renderer.prototype.table.call(this, e)}</div>`;
|
|
2276
|
-
};
|
|
2277
|
-
let ue = /^(sequenceDiagram|graph|classDiagram|stateDiagram|erDiagram|flowchart|xychart-beta)/;
|
|
2278
|
-
v.code = ({ text: e }) => ue.test(e) ? `<pre class="mermaid">${e}</pre>` : `<pre><code>${e}</code></pre>`;
|
|
2279
|
-
function fe(e) {
|
|
2280
|
-
return e.replace(/\\\[([\s\S]*?)\\\]/g, (e, t) => `$$${t}$$`).replace(/\\\(([\s\S]*?)\\\)/g, (e, t) => `$${t}$`).replace(/^(\d+)\.(?!\s)/gm, "$1\\.");
|
|
2281
|
-
}
|
|
2282
|
-
function pe(e) {
|
|
2283
|
-
let t = /* @__PURE__ */ new Set(), n = /^(`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n\1/gm, r;
|
|
2284
|
-
for (; (r = n.exec(e)) !== null;) for (let e = r.index; e < r.index + r[0].length; e++) t.add(e);
|
|
2285
|
-
return e.replace(/[{[]([\s\S]*?)[}\]]/g, (e, n, r) => {
|
|
2286
|
-
if (t.has(r)) return e;
|
|
2287
|
-
try {
|
|
2288
|
-
return JSON.parse(e), "";
|
|
2289
|
-
} catch {
|
|
2290
|
-
return e;
|
|
2291
|
-
}
|
|
2292
|
-
}).replace(/\n{3,}/g, "\n\n");
|
|
2293
|
-
}
|
|
2294
|
-
let me = [
|
|
2295
|
-
oe,
|
|
2296
|
-
pe,
|
|
2297
|
-
Ht,
|
|
2298
|
-
fe
|
|
2299
|
-
], b = ee("container"), he = ne(m(s, "markdown"), mr), ge = i(() => s.tailLength ? r(he.value, s.tailLength) : he.value), { resolveText: _e } = de(), ve = _e(ge), x = i(() => {
|
|
2300
|
-
let e = me.reduce((e, t) => t(e), ve.value);
|
|
2301
|
-
return $.parse(e, {
|
|
2302
|
-
async: !1,
|
|
2303
|
-
breaks: !0,
|
|
2304
|
-
renderer: v
|
|
2305
|
-
});
|
|
2306
|
-
});
|
|
2307
|
-
async function ye() {
|
|
2308
|
-
if (s.loading) return;
|
|
2309
|
-
await c();
|
|
2310
|
-
let e = b.value?.querySelectorAll("pre.mermaid:not([data-rendered])");
|
|
2311
|
-
if (!e?.length) return;
|
|
2312
|
-
let { renderMermaidSVG: t, THEMES: n } = await h(), r = s.isDark ? n["github-dark"] : n["github-light"];
|
|
2313
|
-
for (let n of Array.from(e)) {
|
|
2314
|
-
if (!n.isConnected) continue;
|
|
2315
|
-
let e = n.textContent?.trim();
|
|
2316
|
-
if (e) try {
|
|
2317
|
-
let i = t(e, r);
|
|
2318
|
-
n.isConnected && (n.dataset.code = e, n.innerHTML = i, n.setAttribute("data-rendered", "true"));
|
|
2319
|
-
} catch {}
|
|
2320
|
-
}
|
|
2321
|
-
}
|
|
2322
|
-
async function be() {
|
|
2323
|
-
await c();
|
|
2324
|
-
let e = b.value?.querySelectorAll("pre:not(.mermaid) > code:not([data-highlighted])");
|
|
2325
|
-
if (!e?.length) return;
|
|
2326
|
-
let t = (await import("highlight.js/lib/common")).default;
|
|
2327
|
-
for (let n of e) t.highlightElement(n), n.setAttribute("data-highlighted", "true");
|
|
2328
|
-
}
|
|
2329
|
-
async function S() {
|
|
2330
|
-
await c();
|
|
2331
|
-
let n = b.value?.querySelectorAll(".katex-pending");
|
|
2332
|
-
if (!n?.length) return;
|
|
2333
|
-
let r = await ie();
|
|
2334
|
-
e("https://cdn.jsdelivr.net/npm/katex@0.18/dist/katex.min.css", t(b.value));
|
|
2335
|
-
for (let e of Array.from(n)) {
|
|
2336
|
-
if (!e.isConnected) continue;
|
|
2337
|
-
let t = e.dataset.katex;
|
|
2338
|
-
if (!t) continue;
|
|
2339
|
-
let n = e.dataset.display === "true";
|
|
2340
|
-
try {
|
|
2341
|
-
e.innerHTML = r.renderToString(t, {
|
|
2342
|
-
throwOnError: !1,
|
|
2343
|
-
displayMode: n
|
|
2344
|
-
}), e.classList.remove("katex-pending");
|
|
2345
|
-
} catch {}
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
async function xe() {
|
|
2349
|
-
await c();
|
|
2350
|
-
let e = b.value?.querySelectorAll("pre.mermaid[data-rendered]");
|
|
2351
|
-
if (!e?.length) return;
|
|
2352
|
-
let { renderMermaidSVG: t, THEMES: n } = await h(), r = s.isDark ? n["github-dark"] : n["github-light"];
|
|
2353
|
-
for (let n of Array.from(e)) {
|
|
2354
|
-
if (!n.isConnected) continue;
|
|
2355
|
-
let e = n.dataset.code;
|
|
2356
|
-
if (e) try {
|
|
2357
|
-
n.innerHTML = t(e, r);
|
|
2358
|
-
} catch {}
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
function Se(e) {
|
|
2362
|
-
let t = e.target;
|
|
2363
|
-
if (!(t instanceof HTMLImageElement) || t.dataset.broken) return;
|
|
2364
|
-
t.dataset.broken = "true";
|
|
2365
|
-
let n = document.createElement("span");
|
|
2366
|
-
n.className = "markdown-broken-image", n.textContent = t.alt || f("label.imageLoadError"), n.title = t.src, t.replaceWith(n);
|
|
2367
|
-
}
|
|
2368
|
-
u(() => {
|
|
2369
|
-
b.value?.addEventListener("error", Se, !0);
|
|
2370
|
-
}), l(() => {
|
|
2371
|
-
b.value?.removeEventListener("error", Se, !0);
|
|
2372
|
-
}), g([x, () => s.loading], ye, { immediate: !0 }), g(() => s.isDark, xe), g(x, be, { immediate: !0 }), g(x, S, { immediate: !0 });
|
|
2373
|
-
let C = 0;
|
|
2374
|
-
function Ce(e, t) {
|
|
2375
|
-
let n = document.createElement("span");
|
|
2376
|
-
return n.style.cssText = `animation:ft-${s.animation} ${s.animationDuration} ease-out ${t}ms both;display:inline-block`, n.textContent = e, n.addEventListener("animationend", () => {
|
|
2377
|
-
let t = n.parentNode;
|
|
2378
|
-
t && (t.replaceChild(document.createTextNode(e), n), t.normalize());
|
|
2379
|
-
}, { once: !0 }), n;
|
|
2380
|
-
}
|
|
2381
|
-
function w(e, t, n, r) {
|
|
2382
|
-
let i = r, a = e.split(/(\s+)/);
|
|
2383
|
-
for (let e of a) if (e) {
|
|
2384
|
-
if (/^\s+$/.test(e)) {
|
|
2385
|
-
t.insertBefore(document.createTextNode(e), n);
|
|
2386
|
-
continue;
|
|
2387
|
-
}
|
|
2388
|
-
t.insertBefore(Ce(e, i * 30), n), i++;
|
|
2389
|
-
}
|
|
2390
|
-
return i;
|
|
2391
|
-
}
|
|
2392
|
-
function we(e) {
|
|
2393
|
-
let t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, { acceptNode(e) {
|
|
2394
|
-
return e.parentElement?.closest("pre, code, .katex-pending, .markdown-broken-image") ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
|
|
2395
|
-
} }), n = [];
|
|
2396
|
-
for (; t.nextNode();) n.push(t.currentNode);
|
|
2397
|
-
return n;
|
|
2398
|
-
}
|
|
2399
|
-
function Te() {
|
|
2400
|
-
if (!b.value || !s.loading || !s.animation) return;
|
|
2401
|
-
let e = we(b.value), t = 0, n = 0;
|
|
2402
|
-
for (let r of e) {
|
|
2403
|
-
let e = r.textContent || "", i = t, a = t + e.length;
|
|
2404
|
-
if (t = a, a <= C) continue;
|
|
2405
|
-
let o = r.parentNode;
|
|
2406
|
-
if (!o) continue;
|
|
2407
|
-
if (i >= C) {
|
|
2408
|
-
let t = r.nextSibling;
|
|
2409
|
-
o.removeChild(r), n = w(e, o, t, n);
|
|
2410
|
-
continue;
|
|
2411
|
-
}
|
|
2412
|
-
let s = C - i, c = r.splitText(s), l = c.textContent || "", u = c.nextSibling;
|
|
2413
|
-
o.removeChild(c), n = w(l, o, u, n);
|
|
2414
|
-
}
|
|
2415
|
-
C = t;
|
|
2416
|
-
}
|
|
2417
|
-
return g(x, async () => {
|
|
2418
|
-
await c(), Te();
|
|
2419
|
-
}, { immediate: !0 }), g(() => s.markdown, (e, t) => {
|
|
2420
|
-
(!e || t && e.length < t.length) && (C = 0);
|
|
2421
|
-
}), (e, t) => (d(), a("div", {
|
|
2422
|
-
ref: "container",
|
|
2423
|
-
innerHTML: x.value
|
|
2424
|
-
}, null, 8, pr));
|
|
2425
|
-
}
|
|
2426
|
-
});
|
|
2427
|
-
//#endregion
|
|
2428
|
-
export { le as n, de as r, hr as t };
|
|
2429
|
-
|
|
2430
|
-
//# sourceMappingURL=PkStreamingMarkdown-BoEpwaYQ.js.map
|