@floegence/floe-webapp-core 0.86.52 → 0.86.54
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/assets/markdown.worker-CDm-uCXT.js +1602 -0
- package/dist/chat.js +29 -27
- package/dist/components/chat/hooks/index.d.ts +1 -1
- package/dist/components/chat/hooks/useMarkdown.js +73 -53
- package/dist/components/chat/hooks/useVirtualList.d.ts +7 -6
- package/dist/components/chat/hooks/useVirtualList.js +99 -128
- package/dist/components/chat/hooks/virtualListLayout.d.ts +27 -0
- package/dist/components/chat/hooks/virtualListLayout.js +82 -0
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/markdown/createSessionWorker.d.ts +2 -0
- package/dist/components/chat/markdown/createSessionWorker.js +10 -0
- package/dist/components/chat/markdown/workerSession.d.ts +56 -0
- package/dist/components/chat/markdown/workerSession.js +126 -0
- package/dist/components/ui/picker/PickerNavigation.js +20 -20
- package/dist/full.js +176 -174
- package/dist/markdown.d.ts +3 -0
- package/dist/markdown.js +9 -4
- package/package.json +1 -1
- package/dist/assets/markdown.worker-CcdiAiK-.js +0 -1303
|
@@ -1,1303 +0,0 @@
|
|
|
1
|
-
function X() {
|
|
2
|
-
return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
|
|
3
|
-
}
|
|
4
|
-
var _ = X();
|
|
5
|
-
function de(t) {
|
|
6
|
-
_ = t;
|
|
7
|
-
}
|
|
8
|
-
var A = { exec: () => null };
|
|
9
|
-
function f(t, e = "") {
|
|
10
|
-
let r = typeof t == "string" ? t : t.source, s = { replace: (n, i) => {
|
|
11
|
-
let l = typeof i == "string" ? i : i.source;
|
|
12
|
-
return l = l.replace(m.caret, "$1"), r = r.replace(n, l), s;
|
|
13
|
-
}, getRegex: () => new RegExp(r, e) };
|
|
14
|
-
return s;
|
|
15
|
-
}
|
|
16
|
-
var Ie = (() => {
|
|
17
|
-
try {
|
|
18
|
-
return !!new RegExp("(?<=1)(?<!1)");
|
|
19
|
-
} catch {
|
|
20
|
-
return !1;
|
|
21
|
-
}
|
|
22
|
-
})(), m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (t) => new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}#`), htmlBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}>`) }, Ee = /^(?:[ \t]*(?:\n|$))+/, Be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, De = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, j = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, qe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, J = / {0,3}(?:[*+-]|\d{1,9}[.)])/, xe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, be = f(xe).replace(/bull/g, J).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), je = f(xe).replace(/bull/g, J).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, ve = /^[^\n]+/, V = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Ze = f(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", V).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Me = f(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, J).getRegex(), G = "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", Y = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Qe = f("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", Y).replace("tag", G).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), me = f(K).replace("hr", j).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", G).getRegex(), Ne = f(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", me).getRegex(), ee = { blockquote: Ne, code: Be, def: Ze, fences: De, heading: qe, hr: j, html: Qe, lheading: be, list: Me, newline: Ee, paragraph: me, table: A, text: ve }, ae = f("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", j).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", G).getRegex(), Ge = { ...ee, lheading: je, table: ae, paragraph: f(K).replace("hr", j).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ae).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", G).getRegex() }, Oe = { ...ee, html: f(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", Y).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: A, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: f(K).replace("hr", j).replace("heading", ` *#{1,6} *[^
|
|
23
|
-
]`).replace("lheading", be).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, He = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ue = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, we = /^( {2,}|\\)\n(?!\s*$)/, Fe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, C = /[\p{P}\p{S}]/u, O = /[\s\p{P}\p{S}]/u, te = /[^\s\p{P}\p{S}]/u, We = f(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, O).getRegex(), $e = /(?!~)[\p{P}\p{S}]/u, Xe = /(?!~)[\s\p{P}\p{S}]/u, Je = /(?:[^\s\p{P}\p{S}]|~)/u, Ke = f(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Ie ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), ye = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, Ve = f(ye, "u").replace(/punct/g, C).getRegex(), Ye = f(ye, "u").replace(/punct/g, $e).getRegex(), Se = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", et = f(Se, "gu").replace(/notPunctSpace/g, te).replace(/punctSpace/g, O).replace(/punct/g, C).getRegex(), tt = f(Se, "gu").replace(/notPunctSpace/g, Je).replace(/punctSpace/g, Xe).replace(/punct/g, $e).getRegex(), nt = f("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, te).replace(/punctSpace/g, O).replace(/punct/g, C).getRegex(), rt = f(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, C).getRegex(), st = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", lt = f(st, "gu").replace(/notPunctSpace/g, te).replace(/punctSpace/g, O).replace(/punct/g, C).getRegex(), it = f(/\\(punct)/, "gu").replace(/punct/g, C).getRegex(), at = f(/^<(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(), ot = f(Y).replace("(?:-->|$)", "-->").getRegex(), ct = f("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ot).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), M = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, ut = f(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", M).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Re = f(/^!?\[(label)\]\[(ref)\]/).replace("label", M).replace("ref", V).getRegex(), Te = f(/^!?\[(ref)\](?:\[\])?/).replace("ref", V).getRegex(), ht = f("reflink|nolink(?!\\()", "g").replace("reflink", Re).replace("nolink", Te).getRegex(), oe = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, ne = { _backpedal: A, anyPunctuation: it, autolink: at, blockSkip: Ke, br: we, code: Ue, del: A, delLDelim: A, delRDelim: A, emStrongLDelim: Ve, emStrongRDelimAst: et, emStrongRDelimUnd: nt, escape: He, link: ut, nolink: Te, punctuation: We, reflink: Re, reflinkSearch: ht, tag: ct, text: Fe, url: A }, pt = { ...ne, link: f(/^!?\[(label)\]\((.*?)\)/).replace("label", M).getRegex(), reflink: f(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", M).getRegex() }, U = { ...ne, emStrongRDelimAst: tt, emStrongLDelim: Ye, delLDelim: rt, delRDelim: lt, url: f(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", oe).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: f(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", oe).getRegex() }, ft = { ...U, br: f(we).replace("{2,}", "*").getRegex(), text: f(U.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, Z = { normal: ee, gfm: Ge, pedantic: Oe }, B = { normal: ne, gfm: U, breaks: ft, pedantic: pt }, gt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, ce = (t) => gt[t];
|
|
24
|
-
function R(t, e) {
|
|
25
|
-
if (e) {
|
|
26
|
-
if (m.escapeTest.test(t)) return t.replace(m.escapeReplace, ce);
|
|
27
|
-
} else if (m.escapeTestNoEncode.test(t)) return t.replace(m.escapeReplaceNoEncode, ce);
|
|
28
|
-
return t;
|
|
29
|
-
}
|
|
30
|
-
function ue(t) {
|
|
31
|
-
try {
|
|
32
|
-
t = encodeURI(t).replace(m.percentDecode, "%");
|
|
33
|
-
} catch {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
return t;
|
|
37
|
-
}
|
|
38
|
-
function he(t, e) {
|
|
39
|
-
let r = t.replace(m.findPipe, (i, l, o) => {
|
|
40
|
-
let a = !1, u = l;
|
|
41
|
-
for (; --u >= 0 && o[u] === "\\"; ) a = !a;
|
|
42
|
-
return a ? "|" : " |";
|
|
43
|
-
}), s = r.split(m.splitPipe), n = 0;
|
|
44
|
-
if (s[0].trim() || s.shift(), s.length > 0 && !s.at(-1)?.trim() && s.pop(), e) if (s.length > e) s.splice(e);
|
|
45
|
-
else for (; s.length < e; ) s.push("");
|
|
46
|
-
for (; n < s.length; n++) s[n] = s[n].trim().replace(m.slashPipe, "|");
|
|
47
|
-
return s;
|
|
48
|
-
}
|
|
49
|
-
function D(t, e, r) {
|
|
50
|
-
let s = t.length;
|
|
51
|
-
if (s === 0) return "";
|
|
52
|
-
let n = 0;
|
|
53
|
-
for (; n < s && t.charAt(s - n - 1) === e; )
|
|
54
|
-
n++;
|
|
55
|
-
return t.slice(0, s - n);
|
|
56
|
-
}
|
|
57
|
-
function kt(t, e) {
|
|
58
|
-
if (t.indexOf(e[1]) === -1) return -1;
|
|
59
|
-
let r = 0;
|
|
60
|
-
for (let s = 0; s < t.length; s++) if (t[s] === "\\") s++;
|
|
61
|
-
else if (t[s] === e[0]) r++;
|
|
62
|
-
else if (t[s] === e[1] && (r--, r < 0)) return s;
|
|
63
|
-
return r > 0 ? -2 : -1;
|
|
64
|
-
}
|
|
65
|
-
function dt(t, e = 0) {
|
|
66
|
-
let r = e, s = "";
|
|
67
|
-
for (let n of t) if (n === " ") {
|
|
68
|
-
let i = 4 - r % 4;
|
|
69
|
-
s += " ".repeat(i), r += i;
|
|
70
|
-
} else s += n, r++;
|
|
71
|
-
return s;
|
|
72
|
-
}
|
|
73
|
-
function pe(t, e, r, s, n) {
|
|
74
|
-
let i = e.href, l = e.title || null, o = t[1].replace(n.other.outputLinkReplace, "$1");
|
|
75
|
-
s.state.inLink = !0;
|
|
76
|
-
let a = { type: t[0].charAt(0) === "!" ? "image" : "link", raw: r, href: i, title: l, text: o, tokens: s.inlineTokens(o) };
|
|
77
|
-
return s.state.inLink = !1, a;
|
|
78
|
-
}
|
|
79
|
-
function xt(t, e, r) {
|
|
80
|
-
let s = t.match(r.other.indentCodeCompensation);
|
|
81
|
-
if (s === null) return e;
|
|
82
|
-
let n = s[1];
|
|
83
|
-
return e.split(`
|
|
84
|
-
`).map((i) => {
|
|
85
|
-
let l = i.match(r.other.beginningSpace);
|
|
86
|
-
if (l === null) return i;
|
|
87
|
-
let [o] = l;
|
|
88
|
-
return o.length >= n.length ? i.slice(n.length) : i;
|
|
89
|
-
}).join(`
|
|
90
|
-
`);
|
|
91
|
-
}
|
|
92
|
-
var Q = class {
|
|
93
|
-
options;
|
|
94
|
-
rules;
|
|
95
|
-
lexer;
|
|
96
|
-
constructor(t) {
|
|
97
|
-
this.options = t || _;
|
|
98
|
-
}
|
|
99
|
-
space(t) {
|
|
100
|
-
let e = this.rules.block.newline.exec(t);
|
|
101
|
-
if (e && e[0].length > 0) return { type: "space", raw: e[0] };
|
|
102
|
-
}
|
|
103
|
-
code(t) {
|
|
104
|
-
let e = this.rules.block.code.exec(t);
|
|
105
|
-
if (e) {
|
|
106
|
-
let r = e[0].replace(this.rules.other.codeRemoveIndent, "");
|
|
107
|
-
return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? r : D(r, `
|
|
108
|
-
`) };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
fences(t) {
|
|
112
|
-
let e = this.rules.block.fences.exec(t);
|
|
113
|
-
if (e) {
|
|
114
|
-
let r = e[0], s = xt(r, e[3] || "", this.rules);
|
|
115
|
-
return { type: "code", raw: r, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: s };
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
heading(t) {
|
|
119
|
-
let e = this.rules.block.heading.exec(t);
|
|
120
|
-
if (e) {
|
|
121
|
-
let r = e[2].trim();
|
|
122
|
-
if (this.rules.other.endingHash.test(r)) {
|
|
123
|
-
let s = D(r, "#");
|
|
124
|
-
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (r = s.trim());
|
|
125
|
-
}
|
|
126
|
-
return { type: "heading", raw: e[0], depth: e[1].length, text: r, tokens: this.lexer.inline(r) };
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
hr(t) {
|
|
130
|
-
let e = this.rules.block.hr.exec(t);
|
|
131
|
-
if (e) return { type: "hr", raw: D(e[0], `
|
|
132
|
-
`) };
|
|
133
|
-
}
|
|
134
|
-
blockquote(t) {
|
|
135
|
-
let e = this.rules.block.blockquote.exec(t);
|
|
136
|
-
if (e) {
|
|
137
|
-
let r = D(e[0], `
|
|
138
|
-
`).split(`
|
|
139
|
-
`), s = "", n = "", i = [];
|
|
140
|
-
for (; r.length > 0; ) {
|
|
141
|
-
let l = !1, o = [], a;
|
|
142
|
-
for (a = 0; a < r.length; a++) if (this.rules.other.blockquoteStart.test(r[a])) o.push(r[a]), l = !0;
|
|
143
|
-
else if (!l) o.push(r[a]);
|
|
144
|
-
else break;
|
|
145
|
-
r = r.slice(a);
|
|
146
|
-
let u = o.join(`
|
|
147
|
-
`), c = u.replace(this.rules.other.blockquoteSetextReplace, `
|
|
148
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
149
|
-
s = s ? `${s}
|
|
150
|
-
${u}` : u, n = n ? `${n}
|
|
151
|
-
${c}` : c;
|
|
152
|
-
let p = this.lexer.state.top;
|
|
153
|
-
if (this.lexer.state.top = !0, this.lexer.blockTokens(c, i, !0), this.lexer.state.top = p, r.length === 0) break;
|
|
154
|
-
let h = i.at(-1);
|
|
155
|
-
if (h?.type === "code") break;
|
|
156
|
-
if (h?.type === "blockquote") {
|
|
157
|
-
let d = h, k = d.raw + `
|
|
158
|
-
` + r.join(`
|
|
159
|
-
`), x = this.blockquote(k);
|
|
160
|
-
i[i.length - 1] = x, s = s.substring(0, s.length - d.raw.length) + x.raw, n = n.substring(0, n.length - d.text.length) + x.text;
|
|
161
|
-
break;
|
|
162
|
-
} else if (h?.type === "list") {
|
|
163
|
-
let d = h, k = d.raw + `
|
|
164
|
-
` + r.join(`
|
|
165
|
-
`), x = this.list(k);
|
|
166
|
-
i[i.length - 1] = x, s = s.substring(0, s.length - h.raw.length) + x.raw, n = n.substring(0, n.length - d.raw.length) + x.raw, r = k.substring(i.at(-1).raw.length).split(`
|
|
167
|
-
`);
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return { type: "blockquote", raw: s, tokens: i, text: n };
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
list(t) {
|
|
175
|
-
let e = this.rules.block.list.exec(t);
|
|
176
|
-
if (e) {
|
|
177
|
-
let r = e[1].trim(), s = r.length > 1, n = { type: "list", raw: "", ordered: s, start: s ? +r.slice(0, -1) : "", loose: !1, items: [] };
|
|
178
|
-
r = s ? `\\d{1,9}\\${r.slice(-1)}` : `\\${r}`, this.options.pedantic && (r = s ? r : "[*+-]");
|
|
179
|
-
let i = this.rules.other.listItemRegex(r), l = !1;
|
|
180
|
-
for (; t; ) {
|
|
181
|
-
let a = !1, u = "", c = "";
|
|
182
|
-
if (!(e = i.exec(t)) || this.rules.block.hr.test(t)) break;
|
|
183
|
-
u = e[0], t = t.substring(u.length);
|
|
184
|
-
let p = dt(e[2].split(`
|
|
185
|
-
`, 1)[0], e[1].length), h = t.split(`
|
|
186
|
-
`, 1)[0], d = !p.trim(), k = 0;
|
|
187
|
-
if (this.options.pedantic ? (k = 2, c = p.trimStart()) : d ? k = e[1].length + 1 : (k = p.search(this.rules.other.nonSpaceChar), k = k > 4 ? 1 : k, c = p.slice(k), k += e[1].length), d && this.rules.other.blankLine.test(h) && (u += h + `
|
|
188
|
-
`, t = t.substring(h.length + 1), a = !0), !a) {
|
|
189
|
-
let x = this.rules.other.nextBulletRegex(k), T = this.rules.other.hrRegex(k), b = this.rules.other.fencesBeginRegex(k), I = this.rules.other.headingBeginRegex(k), H = this.rules.other.htmlBeginRegex(k), v = this.rules.other.blockquoteBeginRegex(k);
|
|
190
|
-
for (; t; ) {
|
|
191
|
-
let E = t.split(`
|
|
192
|
-
`, 1)[0], S;
|
|
193
|
-
if (h = E, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), S = h) : S = h.replace(this.rules.other.tabCharGlobal, " "), b.test(h) || I.test(h) || H.test(h) || v.test(h) || x.test(h) || T.test(h)) break;
|
|
194
|
-
if (S.search(this.rules.other.nonSpaceChar) >= k || !h.trim()) c += `
|
|
195
|
-
` + S.slice(k);
|
|
196
|
-
else {
|
|
197
|
-
if (d || p.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || b.test(p) || I.test(p) || T.test(p)) break;
|
|
198
|
-
c += `
|
|
199
|
-
` + h;
|
|
200
|
-
}
|
|
201
|
-
d = !h.trim(), u += E + `
|
|
202
|
-
`, t = t.substring(E.length + 1), p = S.slice(k);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
n.loose || (l ? n.loose = !0 : this.rules.other.doubleBlankLine.test(u) && (l = !0)), n.items.push({ type: "list_item", raw: u, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: !1, text: c, tokens: [] }), n.raw += u;
|
|
206
|
-
}
|
|
207
|
-
let o = n.items.at(-1);
|
|
208
|
-
if (o) o.raw = o.raw.trimEnd(), o.text = o.text.trimEnd();
|
|
209
|
-
else return;
|
|
210
|
-
n.raw = n.raw.trimEnd();
|
|
211
|
-
for (let a of n.items) {
|
|
212
|
-
if (this.lexer.state.top = !1, a.tokens = this.lexer.blockTokens(a.text, []), a.task) {
|
|
213
|
-
if (a.text = a.text.replace(this.rules.other.listReplaceTask, ""), a.tokens[0]?.type === "text" || a.tokens[0]?.type === "paragraph") {
|
|
214
|
-
a.tokens[0].raw = a.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), a.tokens[0].text = a.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
|
|
215
|
-
for (let c = this.lexer.inlineQueue.length - 1; c >= 0; c--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)) {
|
|
216
|
-
this.lexer.inlineQueue[c].src = this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask, "");
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
let u = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
221
|
-
if (u) {
|
|
222
|
-
let c = { type: "checkbox", raw: u[0] + " ", checked: u[0] !== "[ ]" };
|
|
223
|
-
a.checked = c.checked, n.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = c.raw + a.tokens[0].raw, a.tokens[0].text = c.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(c)) : a.tokens.unshift({ type: "paragraph", raw: c.raw, text: c.raw, tokens: [c] }) : a.tokens.unshift(c);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (!n.loose) {
|
|
227
|
-
let u = a.tokens.filter((p) => p.type === "space"), c = u.length > 0 && u.some((p) => this.rules.other.anyLine.test(p.raw));
|
|
228
|
-
n.loose = c;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (n.loose) for (let a of n.items) {
|
|
232
|
-
a.loose = !0;
|
|
233
|
-
for (let u of a.tokens) u.type === "text" && (u.type = "paragraph");
|
|
234
|
-
}
|
|
235
|
-
return n;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
html(t) {
|
|
239
|
-
let e = this.rules.block.html.exec(t);
|
|
240
|
-
if (e) return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] };
|
|
241
|
-
}
|
|
242
|
-
def(t) {
|
|
243
|
-
let e = this.rules.block.def.exec(t);
|
|
244
|
-
if (e) {
|
|
245
|
-
let r = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", n = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
|
|
246
|
-
return { type: "def", tag: r, raw: e[0], href: s, title: n };
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
table(t) {
|
|
250
|
-
let e = this.rules.block.table.exec(t);
|
|
251
|
-
if (!e || !this.rules.other.tableDelimiter.test(e[2])) return;
|
|
252
|
-
let r = he(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), n = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
253
|
-
`) : [], i = { type: "table", raw: e[0], header: [], align: [], rows: [] };
|
|
254
|
-
if (r.length === s.length) {
|
|
255
|
-
for (let l of s) this.rules.other.tableAlignRight.test(l) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(l) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(l) ? i.align.push("left") : i.align.push(null);
|
|
256
|
-
for (let l = 0; l < r.length; l++) i.header.push({ text: r[l], tokens: this.lexer.inline(r[l]), header: !0, align: i.align[l] });
|
|
257
|
-
for (let l of n) i.rows.push(he(l, i.header.length).map((o, a) => ({ text: o, tokens: this.lexer.inline(o), header: !1, align: i.align[a] })));
|
|
258
|
-
return i;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
lheading(t) {
|
|
262
|
-
let e = this.rules.block.lheading.exec(t);
|
|
263
|
-
if (e) {
|
|
264
|
-
let r = e[1].trim();
|
|
265
|
-
return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: r, tokens: this.lexer.inline(r) };
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
paragraph(t) {
|
|
269
|
-
let e = this.rules.block.paragraph.exec(t);
|
|
270
|
-
if (e) {
|
|
271
|
-
let r = e[1].charAt(e[1].length - 1) === `
|
|
272
|
-
` ? e[1].slice(0, -1) : e[1];
|
|
273
|
-
return { type: "paragraph", raw: e[0], text: r, tokens: this.lexer.inline(r) };
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
text(t) {
|
|
277
|
-
let e = this.rules.block.text.exec(t);
|
|
278
|
-
if (e) return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) };
|
|
279
|
-
}
|
|
280
|
-
escape(t) {
|
|
281
|
-
let e = this.rules.inline.escape.exec(t);
|
|
282
|
-
if (e) return { type: "escape", raw: e[0], text: e[1] };
|
|
283
|
-
}
|
|
284
|
-
tag(t) {
|
|
285
|
-
let e = this.rules.inline.tag.exec(t);
|
|
286
|
-
if (e) return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), { type: "html", raw: e[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: !1, text: e[0] };
|
|
287
|
-
}
|
|
288
|
-
link(t) {
|
|
289
|
-
let e = this.rules.inline.link.exec(t);
|
|
290
|
-
if (e) {
|
|
291
|
-
let r = e[2].trim();
|
|
292
|
-
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
|
|
293
|
-
if (!this.rules.other.endAngleBracket.test(r)) return;
|
|
294
|
-
let i = D(r.slice(0, -1), "\\");
|
|
295
|
-
if ((r.length - i.length) % 2 === 0) return;
|
|
296
|
-
} else {
|
|
297
|
-
let i = kt(e[2], "()");
|
|
298
|
-
if (i === -2) return;
|
|
299
|
-
if (i > -1) {
|
|
300
|
-
let l = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
|
|
301
|
-
e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, l).trim(), e[3] = "";
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
let s = e[2], n = "";
|
|
305
|
-
if (this.options.pedantic) {
|
|
306
|
-
let i = this.rules.other.pedanticHrefTitle.exec(s);
|
|
307
|
-
i && (s = i[1], n = i[3]);
|
|
308
|
-
} else n = e[3] ? e[3].slice(1, -1) : "";
|
|
309
|
-
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(r) ? s = s.slice(1) : s = s.slice(1, -1)), pe(e, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: n && n.replace(this.rules.inline.anyPunctuation, "$1") }, e[0], this.lexer, this.rules);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
reflink(t, e) {
|
|
313
|
-
let r;
|
|
314
|
-
if ((r = this.rules.inline.reflink.exec(t)) || (r = this.rules.inline.nolink.exec(t))) {
|
|
315
|
-
let s = (r[2] || r[1]).replace(this.rules.other.multipleSpaceGlobal, " "), n = e[s.toLowerCase()];
|
|
316
|
-
if (!n) {
|
|
317
|
-
let i = r[0].charAt(0);
|
|
318
|
-
return { type: "text", raw: i, text: i };
|
|
319
|
-
}
|
|
320
|
-
return pe(r, n, r[0], this.lexer, this.rules);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
emStrong(t, e, r = "") {
|
|
324
|
-
let s = this.rules.inline.emStrongLDelim.exec(t);
|
|
325
|
-
if (!(!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && r.match(this.rules.other.unicodeAlphaNumeric)) && (!(s[1] || s[3]) || !r || this.rules.inline.punctuation.exec(r))) {
|
|
326
|
-
let n = [...s[0]].length - 1, i, l, o = n, a = 0, u = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
327
|
-
for (u.lastIndex = 0, e = e.slice(-1 * t.length + n); (s = u.exec(e)) !== null; ) {
|
|
328
|
-
if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue;
|
|
329
|
-
if (l = [...i].length, s[3] || s[4]) {
|
|
330
|
-
o += l;
|
|
331
|
-
continue;
|
|
332
|
-
} else if ((s[5] || s[6]) && n % 3 && !((n + l) % 3)) {
|
|
333
|
-
a += l;
|
|
334
|
-
continue;
|
|
335
|
-
}
|
|
336
|
-
if (o -= l, o > 0) continue;
|
|
337
|
-
l = Math.min(l, l + o + a);
|
|
338
|
-
let c = [...s[0]][0].length, p = t.slice(0, n + s.index + c + l);
|
|
339
|
-
if (Math.min(n, l) % 2) {
|
|
340
|
-
let d = p.slice(1, -1);
|
|
341
|
-
return { type: "em", raw: p, text: d, tokens: this.lexer.inlineTokens(d) };
|
|
342
|
-
}
|
|
343
|
-
let h = p.slice(2, -2);
|
|
344
|
-
return { type: "strong", raw: p, text: h, tokens: this.lexer.inlineTokens(h) };
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
codespan(t) {
|
|
349
|
-
let e = this.rules.inline.code.exec(t);
|
|
350
|
-
if (e) {
|
|
351
|
-
let r = e[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(r), n = this.rules.other.startingSpaceChar.test(r) && this.rules.other.endingSpaceChar.test(r);
|
|
352
|
-
return s && n && (r = r.substring(1, r.length - 1)), { type: "codespan", raw: e[0], text: r };
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
br(t) {
|
|
356
|
-
let e = this.rules.inline.br.exec(t);
|
|
357
|
-
if (e) return { type: "br", raw: e[0] };
|
|
358
|
-
}
|
|
359
|
-
del(t, e, r = "") {
|
|
360
|
-
let s = this.rules.inline.delLDelim.exec(t);
|
|
361
|
-
if (s && (!s[1] || !r || this.rules.inline.punctuation.exec(r))) {
|
|
362
|
-
let n = [...s[0]].length - 1, i, l, o = n, a = this.rules.inline.delRDelim;
|
|
363
|
-
for (a.lastIndex = 0, e = e.slice(-1 * t.length + n); (s = a.exec(e)) !== null; ) {
|
|
364
|
-
if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (l = [...i].length, l !== n)) continue;
|
|
365
|
-
if (s[3] || s[4]) {
|
|
366
|
-
o += l;
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
if (o -= l, o > 0) continue;
|
|
370
|
-
l = Math.min(l, l + o);
|
|
371
|
-
let u = [...s[0]][0].length, c = t.slice(0, n + s.index + u + l), p = c.slice(n, -n);
|
|
372
|
-
return { type: "del", raw: c, text: p, tokens: this.lexer.inlineTokens(p) };
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
autolink(t) {
|
|
377
|
-
let e = this.rules.inline.autolink.exec(t);
|
|
378
|
-
if (e) {
|
|
379
|
-
let r, s;
|
|
380
|
-
return e[2] === "@" ? (r = e[1], s = "mailto:" + r) : (r = e[1], s = r), { type: "link", raw: e[0], text: r, href: s, tokens: [{ type: "text", raw: r, text: r }] };
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
url(t) {
|
|
384
|
-
let e;
|
|
385
|
-
if (e = this.rules.inline.url.exec(t)) {
|
|
386
|
-
let r, s;
|
|
387
|
-
if (e[2] === "@") r = e[0], s = "mailto:" + r;
|
|
388
|
-
else {
|
|
389
|
-
let n;
|
|
390
|
-
do
|
|
391
|
-
n = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? "";
|
|
392
|
-
while (n !== e[0]);
|
|
393
|
-
r = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
|
|
394
|
-
}
|
|
395
|
-
return { type: "link", raw: e[0], text: r, href: s, tokens: [{ type: "text", raw: r, text: r }] };
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
inlineText(t) {
|
|
399
|
-
let e = this.rules.inline.text.exec(t);
|
|
400
|
-
if (e) {
|
|
401
|
-
let r = this.lexer.state.inRawBlock;
|
|
402
|
-
return { type: "text", raw: e[0], text: e[0], escaped: r };
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}, w = class F {
|
|
406
|
-
tokens;
|
|
407
|
-
options;
|
|
408
|
-
state;
|
|
409
|
-
inlineQueue;
|
|
410
|
-
tokenizer;
|
|
411
|
-
constructor(e) {
|
|
412
|
-
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || _, 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 = { inLink: !1, inRawBlock: !1, top: !0 };
|
|
413
|
-
let r = { other: m, block: Z.normal, inline: B.normal };
|
|
414
|
-
this.options.pedantic ? (r.block = Z.pedantic, r.inline = B.pedantic) : this.options.gfm && (r.block = Z.gfm, this.options.breaks ? r.inline = B.breaks : r.inline = B.gfm), this.tokenizer.rules = r;
|
|
415
|
-
}
|
|
416
|
-
static get rules() {
|
|
417
|
-
return { block: Z, inline: B };
|
|
418
|
-
}
|
|
419
|
-
static lex(e, r) {
|
|
420
|
-
return new F(r).lex(e);
|
|
421
|
-
}
|
|
422
|
-
static lexInline(e, r) {
|
|
423
|
-
return new F(r).inlineTokens(e);
|
|
424
|
-
}
|
|
425
|
-
lex(e) {
|
|
426
|
-
e = e.replace(m.carriageReturn, `
|
|
427
|
-
`), this.blockTokens(e, this.tokens);
|
|
428
|
-
for (let r = 0; r < this.inlineQueue.length; r++) {
|
|
429
|
-
let s = this.inlineQueue[r];
|
|
430
|
-
this.inlineTokens(s.src, s.tokens);
|
|
431
|
-
}
|
|
432
|
-
return this.inlineQueue = [], this.tokens;
|
|
433
|
-
}
|
|
434
|
-
blockTokens(e, r = [], s = !1) {
|
|
435
|
-
for (this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e; ) {
|
|
436
|
-
let n;
|
|
437
|
-
if (this.options.extensions?.block?.some((l) => (n = l.call({ lexer: this }, e, r)) ? (e = e.substring(n.raw.length), r.push(n), !0) : !1)) continue;
|
|
438
|
-
if (n = this.tokenizer.space(e)) {
|
|
439
|
-
e = e.substring(n.raw.length);
|
|
440
|
-
let l = r.at(-1);
|
|
441
|
-
n.raw.length === 1 && l !== void 0 ? l.raw += `
|
|
442
|
-
` : r.push(n);
|
|
443
|
-
continue;
|
|
444
|
-
}
|
|
445
|
-
if (n = this.tokenizer.code(e)) {
|
|
446
|
-
e = e.substring(n.raw.length);
|
|
447
|
-
let l = r.at(-1);
|
|
448
|
-
l?.type === "paragraph" || l?.type === "text" ? (l.raw += (l.raw.endsWith(`
|
|
449
|
-
`) ? "" : `
|
|
450
|
-
`) + n.raw, l.text += `
|
|
451
|
-
` + n.text, this.inlineQueue.at(-1).src = l.text) : r.push(n);
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
if (n = this.tokenizer.fences(e)) {
|
|
455
|
-
e = e.substring(n.raw.length), r.push(n);
|
|
456
|
-
continue;
|
|
457
|
-
}
|
|
458
|
-
if (n = this.tokenizer.heading(e)) {
|
|
459
|
-
e = e.substring(n.raw.length), r.push(n);
|
|
460
|
-
continue;
|
|
461
|
-
}
|
|
462
|
-
if (n = this.tokenizer.hr(e)) {
|
|
463
|
-
e = e.substring(n.raw.length), r.push(n);
|
|
464
|
-
continue;
|
|
465
|
-
}
|
|
466
|
-
if (n = this.tokenizer.blockquote(e)) {
|
|
467
|
-
e = e.substring(n.raw.length), r.push(n);
|
|
468
|
-
continue;
|
|
469
|
-
}
|
|
470
|
-
if (n = this.tokenizer.list(e)) {
|
|
471
|
-
e = e.substring(n.raw.length), r.push(n);
|
|
472
|
-
continue;
|
|
473
|
-
}
|
|
474
|
-
if (n = this.tokenizer.html(e)) {
|
|
475
|
-
e = e.substring(n.raw.length), r.push(n);
|
|
476
|
-
continue;
|
|
477
|
-
}
|
|
478
|
-
if (n = this.tokenizer.def(e)) {
|
|
479
|
-
e = e.substring(n.raw.length);
|
|
480
|
-
let l = r.at(-1);
|
|
481
|
-
l?.type === "paragraph" || l?.type === "text" ? (l.raw += (l.raw.endsWith(`
|
|
482
|
-
`) ? "" : `
|
|
483
|
-
`) + n.raw, l.text += `
|
|
484
|
-
` + n.raw, this.inlineQueue.at(-1).src = l.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = { href: n.href, title: n.title }, r.push(n));
|
|
485
|
-
continue;
|
|
486
|
-
}
|
|
487
|
-
if (n = this.tokenizer.table(e)) {
|
|
488
|
-
e = e.substring(n.raw.length), r.push(n);
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
if (n = this.tokenizer.lheading(e)) {
|
|
492
|
-
e = e.substring(n.raw.length), r.push(n);
|
|
493
|
-
continue;
|
|
494
|
-
}
|
|
495
|
-
let i = e;
|
|
496
|
-
if (this.options.extensions?.startBlock) {
|
|
497
|
-
let l = 1 / 0, o = e.slice(1), a;
|
|
498
|
-
this.options.extensions.startBlock.forEach((u) => {
|
|
499
|
-
a = u.call({ lexer: this }, o), typeof a == "number" && a >= 0 && (l = Math.min(l, a));
|
|
500
|
-
}), l < 1 / 0 && l >= 0 && (i = e.substring(0, l + 1));
|
|
501
|
-
}
|
|
502
|
-
if (this.state.top && (n = this.tokenizer.paragraph(i))) {
|
|
503
|
-
let l = r.at(-1);
|
|
504
|
-
s && l?.type === "paragraph" ? (l.raw += (l.raw.endsWith(`
|
|
505
|
-
`) ? "" : `
|
|
506
|
-
`) + n.raw, l.text += `
|
|
507
|
-
` + n.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : r.push(n), s = i.length !== e.length, e = e.substring(n.raw.length);
|
|
508
|
-
continue;
|
|
509
|
-
}
|
|
510
|
-
if (n = this.tokenizer.text(e)) {
|
|
511
|
-
e = e.substring(n.raw.length);
|
|
512
|
-
let l = r.at(-1);
|
|
513
|
-
l?.type === "text" ? (l.raw += (l.raw.endsWith(`
|
|
514
|
-
`) ? "" : `
|
|
515
|
-
`) + n.raw, l.text += `
|
|
516
|
-
` + n.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : r.push(n);
|
|
517
|
-
continue;
|
|
518
|
-
}
|
|
519
|
-
if (e) {
|
|
520
|
-
let l = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
521
|
-
if (this.options.silent) {
|
|
522
|
-
console.error(l);
|
|
523
|
-
break;
|
|
524
|
-
} else throw new Error(l);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return this.state.top = !0, r;
|
|
528
|
-
}
|
|
529
|
-
inline(e, r = []) {
|
|
530
|
-
return this.inlineQueue.push({ src: e, tokens: r }), r;
|
|
531
|
-
}
|
|
532
|
-
inlineTokens(e, r = []) {
|
|
533
|
-
this.tokenizer.lexer = this;
|
|
534
|
-
let s = e, n = null;
|
|
535
|
-
if (this.tokens.links) {
|
|
536
|
-
let a = Object.keys(this.tokens.links);
|
|
537
|
-
if (a.length > 0) for (; (n = this.tokenizer.rules.inline.reflinkSearch.exec(s)) !== null; ) a.includes(n[0].slice(n[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, n.index) + "[" + "a".repeat(n[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
538
|
-
}
|
|
539
|
-
for (; (n = this.tokenizer.rules.inline.anyPunctuation.exec(s)) !== null; ) s = s.slice(0, n.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
540
|
-
let i;
|
|
541
|
-
for (; (n = this.tokenizer.rules.inline.blockSkip.exec(s)) !== null; ) i = n[2] ? n[2].length : 0, s = s.slice(0, n.index + i) + "[" + "a".repeat(n[0].length - i - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
542
|
-
s = this.options.hooks?.emStrongMask?.call({ lexer: this }, s) ?? s;
|
|
543
|
-
let l = !1, o = "";
|
|
544
|
-
for (; e; ) {
|
|
545
|
-
l || (o = ""), l = !1;
|
|
546
|
-
let a;
|
|
547
|
-
if (this.options.extensions?.inline?.some((c) => (a = c.call({ lexer: this }, e, r)) ? (e = e.substring(a.raw.length), r.push(a), !0) : !1)) continue;
|
|
548
|
-
if (a = this.tokenizer.escape(e)) {
|
|
549
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
550
|
-
continue;
|
|
551
|
-
}
|
|
552
|
-
if (a = this.tokenizer.tag(e)) {
|
|
553
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
554
|
-
continue;
|
|
555
|
-
}
|
|
556
|
-
if (a = this.tokenizer.link(e)) {
|
|
557
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
558
|
-
continue;
|
|
559
|
-
}
|
|
560
|
-
if (a = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
561
|
-
e = e.substring(a.raw.length);
|
|
562
|
-
let c = r.at(-1);
|
|
563
|
-
a.type === "text" && c?.type === "text" ? (c.raw += a.raw, c.text += a.text) : r.push(a);
|
|
564
|
-
continue;
|
|
565
|
-
}
|
|
566
|
-
if (a = this.tokenizer.emStrong(e, s, o)) {
|
|
567
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
if (a = this.tokenizer.codespan(e)) {
|
|
571
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
572
|
-
continue;
|
|
573
|
-
}
|
|
574
|
-
if (a = this.tokenizer.br(e)) {
|
|
575
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
576
|
-
continue;
|
|
577
|
-
}
|
|
578
|
-
if (a = this.tokenizer.del(e, s, o)) {
|
|
579
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
580
|
-
continue;
|
|
581
|
-
}
|
|
582
|
-
if (a = this.tokenizer.autolink(e)) {
|
|
583
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
584
|
-
continue;
|
|
585
|
-
}
|
|
586
|
-
if (!this.state.inLink && (a = this.tokenizer.url(e))) {
|
|
587
|
-
e = e.substring(a.raw.length), r.push(a);
|
|
588
|
-
continue;
|
|
589
|
-
}
|
|
590
|
-
let u = e;
|
|
591
|
-
if (this.options.extensions?.startInline) {
|
|
592
|
-
let c = 1 / 0, p = e.slice(1), h;
|
|
593
|
-
this.options.extensions.startInline.forEach((d) => {
|
|
594
|
-
h = d.call({ lexer: this }, p), typeof h == "number" && h >= 0 && (c = Math.min(c, h));
|
|
595
|
-
}), c < 1 / 0 && c >= 0 && (u = e.substring(0, c + 1));
|
|
596
|
-
}
|
|
597
|
-
if (a = this.tokenizer.inlineText(u)) {
|
|
598
|
-
e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), l = !0;
|
|
599
|
-
let c = r.at(-1);
|
|
600
|
-
c?.type === "text" ? (c.raw += a.raw, c.text += a.text) : r.push(a);
|
|
601
|
-
continue;
|
|
602
|
-
}
|
|
603
|
-
if (e) {
|
|
604
|
-
let c = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
605
|
-
if (this.options.silent) {
|
|
606
|
-
console.error(c);
|
|
607
|
-
break;
|
|
608
|
-
} else throw new Error(c);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
return r;
|
|
612
|
-
}
|
|
613
|
-
}, N = class {
|
|
614
|
-
options;
|
|
615
|
-
parser;
|
|
616
|
-
constructor(t) {
|
|
617
|
-
this.options = t || _;
|
|
618
|
-
}
|
|
619
|
-
space(t) {
|
|
620
|
-
return "";
|
|
621
|
-
}
|
|
622
|
-
code({ text: t, lang: e, escaped: r }) {
|
|
623
|
-
let s = (e || "").match(m.notSpaceStart)?.[0], n = t.replace(m.endingNewline, "") + `
|
|
624
|
-
`;
|
|
625
|
-
return s ? '<pre><code class="language-' + R(s) + '">' + (r ? n : R(n, !0)) + `</code></pre>
|
|
626
|
-
` : "<pre><code>" + (r ? n : R(n, !0)) + `</code></pre>
|
|
627
|
-
`;
|
|
628
|
-
}
|
|
629
|
-
blockquote({ tokens: t }) {
|
|
630
|
-
return `<blockquote>
|
|
631
|
-
${this.parser.parse(t)}</blockquote>
|
|
632
|
-
`;
|
|
633
|
-
}
|
|
634
|
-
html({ text: t }) {
|
|
635
|
-
return t;
|
|
636
|
-
}
|
|
637
|
-
def(t) {
|
|
638
|
-
return "";
|
|
639
|
-
}
|
|
640
|
-
heading({ tokens: t, depth: e }) {
|
|
641
|
-
return `<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
642
|
-
`;
|
|
643
|
-
}
|
|
644
|
-
hr(t) {
|
|
645
|
-
return `<hr>
|
|
646
|
-
`;
|
|
647
|
-
}
|
|
648
|
-
list(t) {
|
|
649
|
-
let e = t.ordered, r = t.start, s = "";
|
|
650
|
-
for (let l = 0; l < t.items.length; l++) {
|
|
651
|
-
let o = t.items[l];
|
|
652
|
-
s += this.listitem(o);
|
|
653
|
-
}
|
|
654
|
-
let n = e ? "ol" : "ul", i = e && r !== 1 ? ' start="' + r + '"' : "";
|
|
655
|
-
return "<" + n + i + `>
|
|
656
|
-
` + s + "</" + n + `>
|
|
657
|
-
`;
|
|
658
|
-
}
|
|
659
|
-
listitem(t) {
|
|
660
|
-
return `<li>${this.parser.parse(t.tokens)}</li>
|
|
661
|
-
`;
|
|
662
|
-
}
|
|
663
|
-
checkbox({ checked: t }) {
|
|
664
|
-
return "<input " + (t ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
665
|
-
}
|
|
666
|
-
paragraph({ tokens: t }) {
|
|
667
|
-
return `<p>${this.parser.parseInline(t)}</p>
|
|
668
|
-
`;
|
|
669
|
-
}
|
|
670
|
-
table(t) {
|
|
671
|
-
let e = "", r = "";
|
|
672
|
-
for (let n = 0; n < t.header.length; n++) r += this.tablecell(t.header[n]);
|
|
673
|
-
e += this.tablerow({ text: r });
|
|
674
|
-
let s = "";
|
|
675
|
-
for (let n = 0; n < t.rows.length; n++) {
|
|
676
|
-
let i = t.rows[n];
|
|
677
|
-
r = "";
|
|
678
|
-
for (let l = 0; l < i.length; l++) r += this.tablecell(i[l]);
|
|
679
|
-
s += this.tablerow({ text: r });
|
|
680
|
-
}
|
|
681
|
-
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
682
|
-
<thead>
|
|
683
|
-
` + e + `</thead>
|
|
684
|
-
` + s + `</table>
|
|
685
|
-
`;
|
|
686
|
-
}
|
|
687
|
-
tablerow({ text: t }) {
|
|
688
|
-
return `<tr>
|
|
689
|
-
${t}</tr>
|
|
690
|
-
`;
|
|
691
|
-
}
|
|
692
|
-
tablecell(t) {
|
|
693
|
-
let e = this.parser.parseInline(t.tokens), r = t.header ? "th" : "td";
|
|
694
|
-
return (t.align ? `<${r} align="${t.align}">` : `<${r}>`) + e + `</${r}>
|
|
695
|
-
`;
|
|
696
|
-
}
|
|
697
|
-
strong({ tokens: t }) {
|
|
698
|
-
return `<strong>${this.parser.parseInline(t)}</strong>`;
|
|
699
|
-
}
|
|
700
|
-
em({ tokens: t }) {
|
|
701
|
-
return `<em>${this.parser.parseInline(t)}</em>`;
|
|
702
|
-
}
|
|
703
|
-
codespan({ text: t }) {
|
|
704
|
-
return `<code>${R(t, !0)}</code>`;
|
|
705
|
-
}
|
|
706
|
-
br(t) {
|
|
707
|
-
return "<br>";
|
|
708
|
-
}
|
|
709
|
-
del({ tokens: t }) {
|
|
710
|
-
return `<del>${this.parser.parseInline(t)}</del>`;
|
|
711
|
-
}
|
|
712
|
-
link({ href: t, title: e, tokens: r }) {
|
|
713
|
-
let s = this.parser.parseInline(r), n = ue(t);
|
|
714
|
-
if (n === null) return s;
|
|
715
|
-
t = n;
|
|
716
|
-
let i = '<a href="' + t + '"';
|
|
717
|
-
return e && (i += ' title="' + R(e) + '"'), i += ">" + s + "</a>", i;
|
|
718
|
-
}
|
|
719
|
-
image({ href: t, title: e, text: r, tokens: s }) {
|
|
720
|
-
s && (r = this.parser.parseInline(s, this.parser.textRenderer));
|
|
721
|
-
let n = ue(t);
|
|
722
|
-
if (n === null) return R(r);
|
|
723
|
-
t = n;
|
|
724
|
-
let i = `<img src="${t}" alt="${R(r)}"`;
|
|
725
|
-
return e && (i += ` title="${R(e)}"`), i += ">", i;
|
|
726
|
-
}
|
|
727
|
-
text(t) {
|
|
728
|
-
return "tokens" in t && t.tokens ? this.parser.parseInline(t.tokens) : "escaped" in t && t.escaped ? t.text : R(t.text);
|
|
729
|
-
}
|
|
730
|
-
}, re = class {
|
|
731
|
-
strong({ text: t }) {
|
|
732
|
-
return t;
|
|
733
|
-
}
|
|
734
|
-
em({ text: t }) {
|
|
735
|
-
return t;
|
|
736
|
-
}
|
|
737
|
-
codespan({ text: t }) {
|
|
738
|
-
return t;
|
|
739
|
-
}
|
|
740
|
-
del({ text: t }) {
|
|
741
|
-
return t;
|
|
742
|
-
}
|
|
743
|
-
html({ text: t }) {
|
|
744
|
-
return t;
|
|
745
|
-
}
|
|
746
|
-
text({ text: t }) {
|
|
747
|
-
return t;
|
|
748
|
-
}
|
|
749
|
-
link({ text: t }) {
|
|
750
|
-
return "" + t;
|
|
751
|
-
}
|
|
752
|
-
image({ text: t }) {
|
|
753
|
-
return "" + t;
|
|
754
|
-
}
|
|
755
|
-
br() {
|
|
756
|
-
return "";
|
|
757
|
-
}
|
|
758
|
-
checkbox({ raw: t }) {
|
|
759
|
-
return t;
|
|
760
|
-
}
|
|
761
|
-
}, $ = class W {
|
|
762
|
-
options;
|
|
763
|
-
renderer;
|
|
764
|
-
textRenderer;
|
|
765
|
-
constructor(e) {
|
|
766
|
-
this.options = e || _, this.options.renderer = this.options.renderer || new N(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new re();
|
|
767
|
-
}
|
|
768
|
-
static parse(e, r) {
|
|
769
|
-
return new W(r).parse(e);
|
|
770
|
-
}
|
|
771
|
-
static parseInline(e, r) {
|
|
772
|
-
return new W(r).parseInline(e);
|
|
773
|
-
}
|
|
774
|
-
parse(e) {
|
|
775
|
-
this.renderer.parser = this;
|
|
776
|
-
let r = "";
|
|
777
|
-
for (let s = 0; s < e.length; s++) {
|
|
778
|
-
let n = e[s];
|
|
779
|
-
if (this.options.extensions?.renderers?.[n.type]) {
|
|
780
|
-
let l = n, o = this.options.extensions.renderers[l.type].call({ parser: this }, l);
|
|
781
|
-
if (o !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(l.type)) {
|
|
782
|
-
r += o || "";
|
|
783
|
-
continue;
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
let i = n;
|
|
787
|
-
switch (i.type) {
|
|
788
|
-
case "space": {
|
|
789
|
-
r += this.renderer.space(i);
|
|
790
|
-
break;
|
|
791
|
-
}
|
|
792
|
-
case "hr": {
|
|
793
|
-
r += this.renderer.hr(i);
|
|
794
|
-
break;
|
|
795
|
-
}
|
|
796
|
-
case "heading": {
|
|
797
|
-
r += this.renderer.heading(i);
|
|
798
|
-
break;
|
|
799
|
-
}
|
|
800
|
-
case "code": {
|
|
801
|
-
r += this.renderer.code(i);
|
|
802
|
-
break;
|
|
803
|
-
}
|
|
804
|
-
case "table": {
|
|
805
|
-
r += this.renderer.table(i);
|
|
806
|
-
break;
|
|
807
|
-
}
|
|
808
|
-
case "blockquote": {
|
|
809
|
-
r += this.renderer.blockquote(i);
|
|
810
|
-
break;
|
|
811
|
-
}
|
|
812
|
-
case "list": {
|
|
813
|
-
r += this.renderer.list(i);
|
|
814
|
-
break;
|
|
815
|
-
}
|
|
816
|
-
case "checkbox": {
|
|
817
|
-
r += this.renderer.checkbox(i);
|
|
818
|
-
break;
|
|
819
|
-
}
|
|
820
|
-
case "html": {
|
|
821
|
-
r += this.renderer.html(i);
|
|
822
|
-
break;
|
|
823
|
-
}
|
|
824
|
-
case "def": {
|
|
825
|
-
r += this.renderer.def(i);
|
|
826
|
-
break;
|
|
827
|
-
}
|
|
828
|
-
case "paragraph": {
|
|
829
|
-
r += this.renderer.paragraph(i);
|
|
830
|
-
break;
|
|
831
|
-
}
|
|
832
|
-
case "text": {
|
|
833
|
-
r += this.renderer.text(i);
|
|
834
|
-
break;
|
|
835
|
-
}
|
|
836
|
-
default: {
|
|
837
|
-
let l = 'Token with "' + i.type + '" type was not found.';
|
|
838
|
-
if (this.options.silent) return console.error(l), "";
|
|
839
|
-
throw new Error(l);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
return r;
|
|
844
|
-
}
|
|
845
|
-
parseInline(e, r = this.renderer) {
|
|
846
|
-
this.renderer.parser = this;
|
|
847
|
-
let s = "";
|
|
848
|
-
for (let n = 0; n < e.length; n++) {
|
|
849
|
-
let i = e[n];
|
|
850
|
-
if (this.options.extensions?.renderers?.[i.type]) {
|
|
851
|
-
let o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
852
|
-
if (o !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
|
|
853
|
-
s += o || "";
|
|
854
|
-
continue;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
let l = i;
|
|
858
|
-
switch (l.type) {
|
|
859
|
-
case "escape": {
|
|
860
|
-
s += r.text(l);
|
|
861
|
-
break;
|
|
862
|
-
}
|
|
863
|
-
case "html": {
|
|
864
|
-
s += r.html(l);
|
|
865
|
-
break;
|
|
866
|
-
}
|
|
867
|
-
case "link": {
|
|
868
|
-
s += r.link(l);
|
|
869
|
-
break;
|
|
870
|
-
}
|
|
871
|
-
case "image": {
|
|
872
|
-
s += r.image(l);
|
|
873
|
-
break;
|
|
874
|
-
}
|
|
875
|
-
case "checkbox": {
|
|
876
|
-
s += r.checkbox(l);
|
|
877
|
-
break;
|
|
878
|
-
}
|
|
879
|
-
case "strong": {
|
|
880
|
-
s += r.strong(l);
|
|
881
|
-
break;
|
|
882
|
-
}
|
|
883
|
-
case "em": {
|
|
884
|
-
s += r.em(l);
|
|
885
|
-
break;
|
|
886
|
-
}
|
|
887
|
-
case "codespan": {
|
|
888
|
-
s += r.codespan(l);
|
|
889
|
-
break;
|
|
890
|
-
}
|
|
891
|
-
case "br": {
|
|
892
|
-
s += r.br(l);
|
|
893
|
-
break;
|
|
894
|
-
}
|
|
895
|
-
case "del": {
|
|
896
|
-
s += r.del(l);
|
|
897
|
-
break;
|
|
898
|
-
}
|
|
899
|
-
case "text": {
|
|
900
|
-
s += r.text(l);
|
|
901
|
-
break;
|
|
902
|
-
}
|
|
903
|
-
default: {
|
|
904
|
-
let o = 'Token with "' + l.type + '" type was not found.';
|
|
905
|
-
if (this.options.silent) return console.error(o), "";
|
|
906
|
-
throw new Error(o);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
return s;
|
|
911
|
-
}
|
|
912
|
-
}, q = class {
|
|
913
|
-
options;
|
|
914
|
-
block;
|
|
915
|
-
constructor(t) {
|
|
916
|
-
this.options = t || _;
|
|
917
|
-
}
|
|
918
|
-
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
919
|
-
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
920
|
-
preprocess(t) {
|
|
921
|
-
return t;
|
|
922
|
-
}
|
|
923
|
-
postprocess(t) {
|
|
924
|
-
return t;
|
|
925
|
-
}
|
|
926
|
-
processAllTokens(t) {
|
|
927
|
-
return t;
|
|
928
|
-
}
|
|
929
|
-
emStrongMask(t) {
|
|
930
|
-
return t;
|
|
931
|
-
}
|
|
932
|
-
provideLexer(t = this.block) {
|
|
933
|
-
return t ? w.lex : w.lexInline;
|
|
934
|
-
}
|
|
935
|
-
provideParser(t = this.block) {
|
|
936
|
-
return t ? $.parse : $.parseInline;
|
|
937
|
-
}
|
|
938
|
-
}, Ae = class {
|
|
939
|
-
defaults = X();
|
|
940
|
-
options = this.setOptions;
|
|
941
|
-
parse = this.parseMarkdown(!0);
|
|
942
|
-
parseInline = this.parseMarkdown(!1);
|
|
943
|
-
Parser = $;
|
|
944
|
-
Renderer = N;
|
|
945
|
-
TextRenderer = re;
|
|
946
|
-
Lexer = w;
|
|
947
|
-
Tokenizer = Q;
|
|
948
|
-
Hooks = q;
|
|
949
|
-
constructor(...t) {
|
|
950
|
-
this.use(...t);
|
|
951
|
-
}
|
|
952
|
-
walkTokens(t, e) {
|
|
953
|
-
let r = [];
|
|
954
|
-
for (let s of t) switch (r = r.concat(e.call(this, s)), s.type) {
|
|
955
|
-
case "table": {
|
|
956
|
-
let n = s;
|
|
957
|
-
for (let i of n.header) r = r.concat(this.walkTokens(i.tokens, e));
|
|
958
|
-
for (let i of n.rows) for (let l of i) r = r.concat(this.walkTokens(l.tokens, e));
|
|
959
|
-
break;
|
|
960
|
-
}
|
|
961
|
-
case "list": {
|
|
962
|
-
let n = s;
|
|
963
|
-
r = r.concat(this.walkTokens(n.items, e));
|
|
964
|
-
break;
|
|
965
|
-
}
|
|
966
|
-
default: {
|
|
967
|
-
let n = s;
|
|
968
|
-
this.defaults.extensions?.childTokens?.[n.type] ? this.defaults.extensions.childTokens[n.type].forEach((i) => {
|
|
969
|
-
let l = n[i].flat(1 / 0);
|
|
970
|
-
r = r.concat(this.walkTokens(l, e));
|
|
971
|
-
}) : n.tokens && (r = r.concat(this.walkTokens(n.tokens, e)));
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
return r;
|
|
975
|
-
}
|
|
976
|
-
use(...t) {
|
|
977
|
-
let e = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
978
|
-
return t.forEach((r) => {
|
|
979
|
-
let s = { ...r };
|
|
980
|
-
if (s.async = this.defaults.async || s.async || !1, r.extensions && (r.extensions.forEach((n) => {
|
|
981
|
-
if (!n.name) throw new Error("extension name required");
|
|
982
|
-
if ("renderer" in n) {
|
|
983
|
-
let i = e.renderers[n.name];
|
|
984
|
-
i ? e.renderers[n.name] = function(...l) {
|
|
985
|
-
let o = n.renderer.apply(this, l);
|
|
986
|
-
return o === !1 && (o = i.apply(this, l)), o;
|
|
987
|
-
} : e.renderers[n.name] = n.renderer;
|
|
988
|
-
}
|
|
989
|
-
if ("tokenizer" in n) {
|
|
990
|
-
if (!n.level || n.level !== "block" && n.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
991
|
-
let i = e[n.level];
|
|
992
|
-
i ? i.unshift(n.tokenizer) : e[n.level] = [n.tokenizer], n.start && (n.level === "block" ? e.startBlock ? e.startBlock.push(n.start) : e.startBlock = [n.start] : n.level === "inline" && (e.startInline ? e.startInline.push(n.start) : e.startInline = [n.start]));
|
|
993
|
-
}
|
|
994
|
-
"childTokens" in n && n.childTokens && (e.childTokens[n.name] = n.childTokens);
|
|
995
|
-
}), s.extensions = e), r.renderer) {
|
|
996
|
-
let n = this.defaults.renderer || new N(this.defaults);
|
|
997
|
-
for (let i in r.renderer) {
|
|
998
|
-
if (!(i in n)) throw new Error(`renderer '${i}' does not exist`);
|
|
999
|
-
if (["options", "parser"].includes(i)) continue;
|
|
1000
|
-
let l = i, o = r.renderer[l], a = n[l];
|
|
1001
|
-
n[l] = (...u) => {
|
|
1002
|
-
let c = o.apply(n, u);
|
|
1003
|
-
return c === !1 && (c = a.apply(n, u)), c || "";
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
s.renderer = n;
|
|
1007
|
-
}
|
|
1008
|
-
if (r.tokenizer) {
|
|
1009
|
-
let n = this.defaults.tokenizer || new Q(this.defaults);
|
|
1010
|
-
for (let i in r.tokenizer) {
|
|
1011
|
-
if (!(i in n)) throw new Error(`tokenizer '${i}' does not exist`);
|
|
1012
|
-
if (["options", "rules", "lexer"].includes(i)) continue;
|
|
1013
|
-
let l = i, o = r.tokenizer[l], a = n[l];
|
|
1014
|
-
n[l] = (...u) => {
|
|
1015
|
-
let c = o.apply(n, u);
|
|
1016
|
-
return c === !1 && (c = a.apply(n, u)), c;
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
s.tokenizer = n;
|
|
1020
|
-
}
|
|
1021
|
-
if (r.hooks) {
|
|
1022
|
-
let n = this.defaults.hooks || new q();
|
|
1023
|
-
for (let i in r.hooks) {
|
|
1024
|
-
if (!(i in n)) throw new Error(`hook '${i}' does not exist`);
|
|
1025
|
-
if (["options", "block"].includes(i)) continue;
|
|
1026
|
-
let l = i, o = r.hooks[l], a = n[l];
|
|
1027
|
-
q.passThroughHooks.has(i) ? n[l] = (u) => {
|
|
1028
|
-
if (this.defaults.async && q.passThroughHooksRespectAsync.has(i)) return (async () => {
|
|
1029
|
-
let p = await o.call(n, u);
|
|
1030
|
-
return a.call(n, p);
|
|
1031
|
-
})();
|
|
1032
|
-
let c = o.call(n, u);
|
|
1033
|
-
return a.call(n, c);
|
|
1034
|
-
} : n[l] = (...u) => {
|
|
1035
|
-
if (this.defaults.async) return (async () => {
|
|
1036
|
-
let p = await o.apply(n, u);
|
|
1037
|
-
return p === !1 && (p = await a.apply(n, u)), p;
|
|
1038
|
-
})();
|
|
1039
|
-
let c = o.apply(n, u);
|
|
1040
|
-
return c === !1 && (c = a.apply(n, u)), c;
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
s.hooks = n;
|
|
1044
|
-
}
|
|
1045
|
-
if (r.walkTokens) {
|
|
1046
|
-
let n = this.defaults.walkTokens, i = r.walkTokens;
|
|
1047
|
-
s.walkTokens = function(l) {
|
|
1048
|
-
let o = [];
|
|
1049
|
-
return o.push(i.call(this, l)), n && (o = o.concat(n.call(this, l))), o;
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
this.defaults = { ...this.defaults, ...s };
|
|
1053
|
-
}), this;
|
|
1054
|
-
}
|
|
1055
|
-
setOptions(t) {
|
|
1056
|
-
return this.defaults = { ...this.defaults, ...t }, this;
|
|
1057
|
-
}
|
|
1058
|
-
lexer(t, e) {
|
|
1059
|
-
return w.lex(t, e ?? this.defaults);
|
|
1060
|
-
}
|
|
1061
|
-
parser(t, e) {
|
|
1062
|
-
return $.parse(t, e ?? this.defaults);
|
|
1063
|
-
}
|
|
1064
|
-
parseMarkdown(t) {
|
|
1065
|
-
return (e, r) => {
|
|
1066
|
-
let s = { ...r }, n = { ...this.defaults, ...s }, i = this.onError(!!n.silent, !!n.async);
|
|
1067
|
-
if (this.defaults.async === !0 && s.async === !1) return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
1068
|
-
if (typeof e > "u" || e === null) return i(new Error("marked(): input parameter is undefined or null"));
|
|
1069
|
-
if (typeof e != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
|
|
1070
|
-
if (n.hooks && (n.hooks.options = n, n.hooks.block = t), n.async) return (async () => {
|
|
1071
|
-
let l = n.hooks ? await n.hooks.preprocess(e) : e, o = await (n.hooks ? await n.hooks.provideLexer(t) : t ? w.lex : w.lexInline)(l, n), a = n.hooks ? await n.hooks.processAllTokens(o) : o;
|
|
1072
|
-
n.walkTokens && await Promise.all(this.walkTokens(a, n.walkTokens));
|
|
1073
|
-
let u = await (n.hooks ? await n.hooks.provideParser(t) : t ? $.parse : $.parseInline)(a, n);
|
|
1074
|
-
return n.hooks ? await n.hooks.postprocess(u) : u;
|
|
1075
|
-
})().catch(i);
|
|
1076
|
-
try {
|
|
1077
|
-
n.hooks && (e = n.hooks.preprocess(e));
|
|
1078
|
-
let l = (n.hooks ? n.hooks.provideLexer(t) : t ? w.lex : w.lexInline)(e, n);
|
|
1079
|
-
n.hooks && (l = n.hooks.processAllTokens(l)), n.walkTokens && this.walkTokens(l, n.walkTokens);
|
|
1080
|
-
let o = (n.hooks ? n.hooks.provideParser(t) : t ? $.parse : $.parseInline)(l, n);
|
|
1081
|
-
return n.hooks && (o = n.hooks.postprocess(o)), o;
|
|
1082
|
-
} catch (l) {
|
|
1083
|
-
return i(l);
|
|
1084
|
-
}
|
|
1085
|
-
};
|
|
1086
|
-
}
|
|
1087
|
-
onError(t, e) {
|
|
1088
|
-
return (r) => {
|
|
1089
|
-
if (r.message += `
|
|
1090
|
-
Please report this to https://github.com/markedjs/marked.`, t) {
|
|
1091
|
-
let s = "<p>An error occurred:</p><pre>" + R(r.message + "", !0) + "</pre>";
|
|
1092
|
-
return e ? Promise.resolve(s) : s;
|
|
1093
|
-
}
|
|
1094
|
-
if (e) return Promise.reject(r);
|
|
1095
|
-
throw r;
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
}, z = new Ae();
|
|
1099
|
-
function g(t, e) {
|
|
1100
|
-
return z.parse(t, e);
|
|
1101
|
-
}
|
|
1102
|
-
g.options = g.setOptions = function(t) {
|
|
1103
|
-
return z.setOptions(t), g.defaults = z.defaults, de(g.defaults), g;
|
|
1104
|
-
};
|
|
1105
|
-
g.getDefaults = X;
|
|
1106
|
-
g.defaults = _;
|
|
1107
|
-
g.use = function(...t) {
|
|
1108
|
-
return z.use(...t), g.defaults = z.defaults, de(g.defaults), g;
|
|
1109
|
-
};
|
|
1110
|
-
g.walkTokens = function(t, e) {
|
|
1111
|
-
return z.walkTokens(t, e);
|
|
1112
|
-
};
|
|
1113
|
-
g.parseInline = z.parseInline;
|
|
1114
|
-
g.Parser = $;
|
|
1115
|
-
g.parser = $.parse;
|
|
1116
|
-
g.Renderer = N;
|
|
1117
|
-
g.TextRenderer = re;
|
|
1118
|
-
g.Lexer = w;
|
|
1119
|
-
g.lexer = w.lex;
|
|
1120
|
-
g.Tokenizer = Q;
|
|
1121
|
-
g.Hooks = q;
|
|
1122
|
-
g.parse = g;
|
|
1123
|
-
g.options;
|
|
1124
|
-
g.setOptions;
|
|
1125
|
-
g.use;
|
|
1126
|
-
g.walkTokens;
|
|
1127
|
-
g.parseInline;
|
|
1128
|
-
$.parse;
|
|
1129
|
-
w.lex;
|
|
1130
|
-
const y = "\\u1100-\\u11ff\\u20a9\\u2329-\\u232a\\u2630-\\u2637\\u268a-\\u268f\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u2ff0-\\u303e\\u3041-\\u3096\\u3099-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u31e5\\u31ef-\\u321e\\u3220-\\u3247\\u3250-\\ua48c\\ua490-\\ua4c6\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufaff\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe66\\ufe68-\\ufe6b\\uff01-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\\uffe0-\\uffe6\\uffe8-\\uffee\\u{16fe0}-\\u{16fe4}\\u{16ff0}-\\u{16ff6}\\u{17000}-\\u{18cda}\\u{18cff}-\\u{18d20}\\u{18d80}-\\u{18df2}\\u{18e00}-\\u{19191}\\u{191a0}-\\u{191d2}\\u{1aff0}-\\u{1aff3}\\u{1aff5}-\\u{1affb}\\u{1affd}-\\u{1affe}\\u{1b000}-\\u{1b128}\\u{1b132}\\u{1b150}-\\u{1b152}\\u{1b155}\\u{1b164}-\\u{1b168}\\u{1b170}-\\u{1b2fb}\\u{1d300}-\\u{1d356}\\u{1d360}-\\u{1d376}\\u{1f1ae}\\u{1f200}\\u{1f202}\\u{1f210}-\\u{1f219}\\u{1f21b}-\\u{1f22e}\\u{1f230}-\\u{1f231}\\u{1f237}\\u{1f23b}\\u{1f240}-\\u{1f248}\\u{1f260}-\\u{1f265}\\u{1f7da}\\u{20000}-\\u{3fffd}", P = new RegExp(`[${y}]`, "u"), bt = new RegExp(`^((?![*_])[\\s\\p{P}\\p{S}${y}])`, "u");
|
|
1131
|
-
function ze(t, e, r) {
|
|
1132
|
-
return new RegExp(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)${t}(\\*+)(?=[\\s]|$)|${r}(\\*+)(?!\\*)(?=${e}|$)|(?!\\*)${e}(\\*+)(?=${r})|[\\s](\\*+)(?!\\*)(?=${t})|(?!\\*)${t}(\\*+)(?!\\*)(?=${t})|${r}(\\*+)(?=${r})`, "gu");
|
|
1133
|
-
}
|
|
1134
|
-
function mt(t, e, r) {
|
|
1135
|
-
return new RegExp(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)${t}(_+)(?=[\\s]|$)|${r}(_+)(?!_)(?=${e}|$)|(?!_)${e}(_+)(?=${r})|[\\s](_+)(?!_)(?=${t})|(?!_)${t}(_+)(?!_)(?=${t})`, "gu");
|
|
1136
|
-
}
|
|
1137
|
-
function wt(t, e, r) {
|
|
1138
|
-
return new RegExp(`^[^~]+(?=[^~])|(?!~)${t}(~~?)(?=[\\s]|$)|${r}(~~?)(?!~)(?=${e}|$)|(?!~)${e}(~~?)(?=${r})|[\\s](~~?)(?!~)(?=${t})|(?!~)${t}(~~?)(?!~)(?=${t})|${r}(~~?)(?=${r})`, "gu");
|
|
1139
|
-
}
|
|
1140
|
-
const _e = `[\\p{P}\\p{S}${y}]`, Pe = `[\\s\\p{P}\\p{S}${y}]`, Ce = `[^\\s\\p{P}\\p{S}${y}]`, $t = `(?![*_])[\\p{P}\\p{S}${y}]`, yt = `(?![*_])[\\s\\p{P}\\p{S}${y}]`, St = `(?:[^\\s\\p{P}\\p{S}${y}]|[*_])`, Rt = `(?!~)[\\p{P}\\p{S}${y}]`, Tt = `(?!~)[\\s\\p{P}\\p{S}${y}]`, At = `(?:[^\\s\\p{P}\\p{S}${y}]|~)`, zt = ze(_e, Pe, Ce), _t = ze(Rt, Tt, At), Pt = mt(_e, Pe, Ce), fe = wt($t, yt, St);
|
|
1141
|
-
function ge(t, e, r) {
|
|
1142
|
-
let s = bt.test(t);
|
|
1143
|
-
if (!s && t) {
|
|
1144
|
-
const n = e.length - r.length;
|
|
1145
|
-
if (n >= 1) {
|
|
1146
|
-
let i = n - 1, l = e.charCodeAt(i);
|
|
1147
|
-
if (l >= 65024 && l <= 65038 && i >= 1 && (i--, l = e.charCodeAt(i)), (l & 64512) === 56320 && i >= 1) {
|
|
1148
|
-
const o = e.codePointAt(i - 1);
|
|
1149
|
-
o !== void 0 && o > 65535 && (o >= 917760 && o <= 917999 ? s = !0 : s = P.test(String.fromCodePoint(o)));
|
|
1150
|
-
} else s = P.test(String.fromCharCode(l));
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
return s;
|
|
1154
|
-
}
|
|
1155
|
-
function ke(t, e) {
|
|
1156
|
-
if (!(t[1] || t[2] || t[3] || t[4])) return !1;
|
|
1157
|
-
const r = String.fromCodePoint(t[0].codePointAt(0)), s = t.index + t[0].length, n = s < e.length ? String.fromCodePoint(e.codePointAt(s)) : "";
|
|
1158
|
-
return P.test(r) || P.test(n);
|
|
1159
|
-
}
|
|
1160
|
-
function se(t) {
|
|
1161
|
-
return t.length >= 5;
|
|
1162
|
-
}
|
|
1163
|
-
function Ct(t) {
|
|
1164
|
-
return !!(t[1] || t[2] || t[3] || t[4]);
|
|
1165
|
-
}
|
|
1166
|
-
function Lt(t) {
|
|
1167
|
-
return se(t) ? !!t[4] : !!t[3];
|
|
1168
|
-
}
|
|
1169
|
-
function It(t) {
|
|
1170
|
-
return se(t) ? t[1] || t[3] || "" : t[1] || t[2] || "";
|
|
1171
|
-
}
|
|
1172
|
-
function Et() {
|
|
1173
|
-
return { tokenizer: {
|
|
1174
|
-
emStrong(t, e, r = "") {
|
|
1175
|
-
const { rules: s } = this, n = s.inline.emStrongLDelim.exec(t);
|
|
1176
|
-
if (!n) return !1;
|
|
1177
|
-
const i = se(n);
|
|
1178
|
-
if (i && !Ct(n)) return;
|
|
1179
|
-
if (Lt(n) && r.match(s.other.unicodeAlphaNumeric)) return !1;
|
|
1180
|
-
const l = It(n), o = ge(r, e, t);
|
|
1181
|
-
if (!l || !r || s.inline.punctuation.exec(r) || o || P.test(l)) {
|
|
1182
|
-
const a = [...n[0]].length - 1;
|
|
1183
|
-
let u, c, p = a, h = 0;
|
|
1184
|
-
const d = i && r === n[0][0], k = s.inline.emStrongRDelimAst.source.includes("(?!~)");
|
|
1185
|
-
let x;
|
|
1186
|
-
n[0][0] === "*" ? x = k ? _t : zt : x = Pt, x.lastIndex = 0;
|
|
1187
|
-
const T = e.slice(-1 * t.length + a);
|
|
1188
|
-
let b;
|
|
1189
|
-
for (; (b = x.exec(T)) != null; ) {
|
|
1190
|
-
if (u = b[1] || b[2] || b[3] || b[4] || b[5] || b[6], !u) continue;
|
|
1191
|
-
c = [...u].length;
|
|
1192
|
-
const I = ke(b, T), H = !!(b[3] || b[4]), v = !!(b[5] || b[6]);
|
|
1193
|
-
if (H && !I) {
|
|
1194
|
-
p += c;
|
|
1195
|
-
continue;
|
|
1196
|
-
}
|
|
1197
|
-
if (v || I) {
|
|
1198
|
-
if (a % 3 && !((a + c) % 3)) {
|
|
1199
|
-
h += c;
|
|
1200
|
-
continue;
|
|
1201
|
-
}
|
|
1202
|
-
if (d && v) break;
|
|
1203
|
-
}
|
|
1204
|
-
if (p -= c, p > 0) continue;
|
|
1205
|
-
c = Math.min(c, c + p + h);
|
|
1206
|
-
const E = b[0].codePointAt(0) > 65535 ? 2 : 1, S = t.slice(0, a + b.index + E + c);
|
|
1207
|
-
if (Math.min(a, c) % 2) {
|
|
1208
|
-
const ie = S.slice(1, -1);
|
|
1209
|
-
return {
|
|
1210
|
-
type: "em",
|
|
1211
|
-
raw: S,
|
|
1212
|
-
text: ie,
|
|
1213
|
-
tokens: this.lexer.inlineTokens(ie)
|
|
1214
|
-
};
|
|
1215
|
-
}
|
|
1216
|
-
const le = S.slice(2, -2);
|
|
1217
|
-
return {
|
|
1218
|
-
type: "strong",
|
|
1219
|
-
raw: S,
|
|
1220
|
-
text: le,
|
|
1221
|
-
tokens: this.lexer.inlineTokens(le)
|
|
1222
|
-
};
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
},
|
|
1226
|
-
del(t, e, r = "") {
|
|
1227
|
-
const { rules: s } = this, n = s.inline.delLDelim.exec(t);
|
|
1228
|
-
if (!n) return !1;
|
|
1229
|
-
const i = n[1] || "", l = ge(r, e, t);
|
|
1230
|
-
if (!i || !r || s.inline.punctuation.exec(r) || l || P.test(i)) {
|
|
1231
|
-
const o = [...n[0]].length - 1;
|
|
1232
|
-
let a, u, c = o;
|
|
1233
|
-
fe.lastIndex = 0;
|
|
1234
|
-
const p = e.slice(-1 * t.length + o);
|
|
1235
|
-
let h;
|
|
1236
|
-
for (; (h = fe.exec(p)) != null; ) {
|
|
1237
|
-
if (a = h[1] || h[2] || h[3] || h[4] || h[5] || h[6], !a || (u = [...a].length, u !== o)) continue;
|
|
1238
|
-
const d = ke(h, p);
|
|
1239
|
-
if ((h[3] || h[4]) && !d) {
|
|
1240
|
-
c += u;
|
|
1241
|
-
continue;
|
|
1242
|
-
}
|
|
1243
|
-
if (c -= u, c > 0) continue;
|
|
1244
|
-
u = Math.min(u, u + c);
|
|
1245
|
-
const k = h[0].codePointAt(0) > 65535 ? 2 : 1, x = t.slice(0, o + h.index + k + u), T = x.slice(o, -o);
|
|
1246
|
-
return {
|
|
1247
|
-
type: "del",
|
|
1248
|
-
raw: x,
|
|
1249
|
-
text: T,
|
|
1250
|
-
tokens: this.lexer.inlineTokens(T)
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
} };
|
|
1256
|
-
}
|
|
1257
|
-
function Bt(t = {}) {
|
|
1258
|
-
const e = Et().tokenizer.emStrong;
|
|
1259
|
-
return new Ae({ tokenizer: {
|
|
1260
|
-
emStrong(r, s, n) {
|
|
1261
|
-
const i = e.call(this, r, s, n);
|
|
1262
|
-
return i && /^\s|\s$/u.test(i.text) ? !1 : i;
|
|
1263
|
-
}
|
|
1264
|
-
} }).setOptions({ gfm: !0, breaks: !0, ...t });
|
|
1265
|
-
}
|
|
1266
|
-
const Le = Bt(), L = new g.Renderer();
|
|
1267
|
-
L.code = function(t) {
|
|
1268
|
-
const e = t.lang || "text", r = t.text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1269
|
-
return `<pre class="chat-md-code-block" data-language="${e}"><code>${r}</code></pre>`;
|
|
1270
|
-
};
|
|
1271
|
-
L.codespan = function(t) {
|
|
1272
|
-
return `<code class="chat-md-inline-code">${t.text}</code>`;
|
|
1273
|
-
};
|
|
1274
|
-
L.link = function(t) {
|
|
1275
|
-
const e = t.title ? ` title="${t.title}"` : "";
|
|
1276
|
-
return `<a href="${t.href}"${e} target="_blank" rel="noopener noreferrer" class="chat-md-link">${t.text}</a>`;
|
|
1277
|
-
};
|
|
1278
|
-
L.image = function(t) {
|
|
1279
|
-
const e = t.title ? ` title="${t.title}"` : "";
|
|
1280
|
-
return `<img src="${t.href}" alt="${t.text}"${e} class="chat-md-image" loading="lazy" />`;
|
|
1281
|
-
};
|
|
1282
|
-
L.blockquote = function(t) {
|
|
1283
|
-
return `<blockquote class="chat-md-blockquote">${t.text}</blockquote>`;
|
|
1284
|
-
};
|
|
1285
|
-
Le.use({ renderer: L });
|
|
1286
|
-
function Dt(t) {
|
|
1287
|
-
return Le.parse(t, { async: !1 });
|
|
1288
|
-
}
|
|
1289
|
-
postMessage({ type: "ready" });
|
|
1290
|
-
addEventListener("message", (t) => {
|
|
1291
|
-
const { id: e, content: r } = t.data;
|
|
1292
|
-
try {
|
|
1293
|
-
const s = Dt(r);
|
|
1294
|
-
postMessage({ id: e, html: s });
|
|
1295
|
-
} catch (s) {
|
|
1296
|
-
const n = {
|
|
1297
|
-
id: e,
|
|
1298
|
-
html: "",
|
|
1299
|
-
error: s instanceof Error ? s.message : "Failed to render markdown"
|
|
1300
|
-
};
|
|
1301
|
-
postMessage(n);
|
|
1302
|
-
}
|
|
1303
|
-
});
|