@gui-chat-plugin/markdown 0.0.1 → 0.0.2
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/core.cjs +2 -2
- package/dist/core.js +21 -22
- package/dist/style.css +1 -1
- package/dist/vue/Preview.vue.d.ts +2 -1
- package/dist/vue/Preview.vue.d.ts.map +1 -1
- package/dist/vue/View.vue.d.ts +2 -1
- package/dist/vue/View.vue.d.ts.map +1 -1
- package/dist/vue.cjs +58 -55
- package/dist/vue.js +874 -1353
- package/package.json +14 -7
package/dist/vue.js
CHANGED
|
@@ -1,1702 +1,1223 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { defineComponent as de, ref as Le, computed as G, watch as le, nextTick as Pe, createElementBlock as P, openBlock as I, createElementVNode as x, Fragment as Ie, toDisplayString as ge, createTextVNode as Be, withDirectives as Ee, vModelText as qe } from "vue";
|
|
7
|
-
function F() {
|
|
8
|
-
return {
|
|
9
|
-
async: !1,
|
|
10
|
-
breaks: !1,
|
|
11
|
-
extensions: null,
|
|
12
|
-
gfm: !0,
|
|
13
|
-
hooks: null,
|
|
14
|
-
pedantic: !1,
|
|
15
|
-
renderer: null,
|
|
16
|
-
silent: !1,
|
|
17
|
-
tokenizer: null,
|
|
18
|
-
walkTokens: null
|
|
19
|
-
};
|
|
1
|
+
import { samples as Se, pluginCore as Te } from "./core.js";
|
|
2
|
+
import { TOOL_DEFINITION as Mt, executeMarkdown as Dt } from "./core.js";
|
|
3
|
+
import { defineComponent as he, ref as _e, computed as O, watch as re, nextTick as ze, createElementBlock as C, openBlock as L, createElementVNode as x, Fragment as Ae, toDisplayString as pe, createTextVNode as ve, withDirectives as Pe, vModelText as Ie } from "vue";
|
|
4
|
+
function H() {
|
|
5
|
+
return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
|
|
20
6
|
}
|
|
21
|
-
var S =
|
|
22
|
-
function
|
|
23
|
-
S =
|
|
7
|
+
var S = H();
|
|
8
|
+
function ue(s) {
|
|
9
|
+
S = s;
|
|
24
10
|
}
|
|
25
|
-
var
|
|
26
|
-
function
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
replace
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
getRegex: () => new RegExp(t, e)
|
|
34
|
-
};
|
|
35
|
-
return r;
|
|
11
|
+
var v = { exec: () => null };
|
|
12
|
+
function d(s, e = "") {
|
|
13
|
+
let r = typeof s == "string" ? s : s.source, n = { replace: (t, i) => {
|
|
14
|
+
let l = typeof i == "string" ? i : i.source;
|
|
15
|
+
return l = l.replace(b.caret, "$1"), r = r.replace(t, l), n;
|
|
16
|
+
}, getRegex: () => new RegExp(r, e) };
|
|
17
|
+
return n;
|
|
36
18
|
}
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
newLineCharGlobal: /\n/g,
|
|
47
|
-
tabCharGlobal: /\t/g,
|
|
48
|
-
multipleSpaceGlobal: /\s+/g,
|
|
49
|
-
blankLine: /^[ \t]*$/,
|
|
50
|
-
doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
|
|
51
|
-
blockquoteStart: /^ {0,3}>/,
|
|
52
|
-
blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
|
|
53
|
-
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
|
|
54
|
-
listReplaceTabs: /^\t+/,
|
|
55
|
-
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
|
|
56
|
-
listIsTask: /^\[[ xX]\] /,
|
|
57
|
-
listReplaceTask: /^\[[ xX]\] +/,
|
|
58
|
-
anyLine: /\n.*\n/,
|
|
59
|
-
hrefBrackets: /^<(.*)>$/,
|
|
60
|
-
tableDelimiter: /[:|]/,
|
|
61
|
-
tableAlignChars: /^\||\| *$/g,
|
|
62
|
-
tableRowBlankLine: /\n[ \t]*$/,
|
|
63
|
-
tableAlignRight: /^ *-+: *$/,
|
|
64
|
-
tableAlignCenter: /^ *:-+: *$/,
|
|
65
|
-
tableAlignLeft: /^ *:-+ *$/,
|
|
66
|
-
startATag: /^<a /i,
|
|
67
|
-
endATag: /^<\/a>/i,
|
|
68
|
-
startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
|
|
69
|
-
endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
|
|
70
|
-
startAngleBracket: /^</,
|
|
71
|
-
endAngleBracket: />$/,
|
|
72
|
-
pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
|
|
73
|
-
unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
|
|
74
|
-
escapeTest: /[&<>"']/,
|
|
75
|
-
escapeReplace: /[&<>"']/g,
|
|
76
|
-
escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
|
|
77
|
-
escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
|
|
78
|
-
unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
|
|
79
|
-
caret: /(^|[^\[])\^/g,
|
|
80
|
-
percentDecode: /%25/g,
|
|
81
|
-
findPipe: /\|/g,
|
|
82
|
-
splitPipe: / \|/,
|
|
83
|
-
slashPipe: /\\\|/g,
|
|
84
|
-
carriageReturn: /\r\n|\r/g,
|
|
85
|
-
spaceLine: /^ +$/gm,
|
|
86
|
-
notSpaceStart: /^\S*/,
|
|
87
|
-
endingNewline: /\n$/,
|
|
88
|
-
listItemRegex: (n) => new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
89
|
-
nextBulletRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
90
|
-
hrRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
|
|
91
|
-
fencesBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:\`\`\`|~~~)`),
|
|
92
|
-
headingBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}#`),
|
|
93
|
-
htmlBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}<(?:[a-z].*>|!--)`, "i")
|
|
94
|
-
}, De = /^(?:[ \t]*(?:\n|$))+/, Me = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Oe = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, C = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Ne = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, V = /(?:[*+-]|\d{1,9}[.)])/, ke = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, me = g(ke).replace(/bull/g, V).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(), Ze = g(ke).replace(/bull/g, V).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(), X = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, je = /^[^\n]+/, W = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Ge = g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), He = g(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, V).getRegex(), M = "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 = g(
|
|
95
|
-
"^ {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|$))",
|
|
96
|
-
"i"
|
|
97
|
-
).replace("comment", Y).replace("tag", M).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), be = g(X).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex(), Ue = g(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", be).getRegex(), J = {
|
|
98
|
-
blockquote: Ue,
|
|
99
|
-
code: Me,
|
|
100
|
-
def: Ge,
|
|
101
|
-
fences: Oe,
|
|
102
|
-
heading: Ne,
|
|
103
|
-
hr: C,
|
|
104
|
-
html: Qe,
|
|
105
|
-
lheading: me,
|
|
106
|
-
list: He,
|
|
107
|
-
newline: De,
|
|
108
|
-
paragraph: be,
|
|
109
|
-
table: A,
|
|
110
|
-
text: je
|
|
111
|
-
}, ae = g(
|
|
112
|
-
"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
|
|
113
|
-
).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex(), Fe = {
|
|
114
|
-
...J,
|
|
115
|
-
lheading: Ze,
|
|
116
|
-
table: ae,
|
|
117
|
-
paragraph: g(X).replace("hr", C).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[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex()
|
|
118
|
-
}, Ve = {
|
|
119
|
-
...J,
|
|
120
|
-
html: g(
|
|
121
|
-
`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
|
|
122
|
-
).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(),
|
|
123
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
124
|
-
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
125
|
-
fences: A,
|
|
126
|
-
// fences not supported
|
|
127
|
-
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
128
|
-
paragraph: g(X).replace("hr", C).replace("heading", ` *#{1,6} *[^
|
|
129
|
-
]`).replace("lheading", me).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
130
|
-
}, Xe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, We = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, xe = /^( {2,}|\\)\n(?!\s*$)/, Ye = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, O = /[\p{P}\p{S}]/u, K = /[\s\p{P}\p{S}]/u, we = /[^\s\p{P}\p{S}]/u, Je = g(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, K).getRegex(), ye = /(?!~)[\p{P}\p{S}]/u, Ke = /(?!~)[\s\p{P}\p{S}]/u, et = /(?:[^\s\p{P}\p{S}]|~)/u, tt = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, ve = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, nt = g(ve, "u").replace(/punct/g, O).getRegex(), rt = g(ve, "u").replace(/punct/g, ye).getRegex(), Re = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", st = g(Re, "gu").replace(/notPunctSpace/g, we).replace(/punctSpace/g, K).replace(/punct/g, O).getRegex(), it = g(Re, "gu").replace(/notPunctSpace/g, et).replace(/punctSpace/g, Ke).replace(/punct/g, ye).getRegex(), lt = g(
|
|
131
|
-
"^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
|
|
132
|
-
"gu"
|
|
133
|
-
).replace(/notPunctSpace/g, we).replace(/punctSpace/g, K).replace(/punct/g, O).getRegex(), at = g(/\\(punct)/, "gu").replace(/punct/g, O).getRegex(), ot = g(/^<(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(), ct = g(Y).replace("(?:-->|$)", "-->").getRegex(), ht = g(
|
|
134
|
-
"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
|
|
135
|
-
).replace("comment", ct).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), E = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, pt = g(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", E).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), $e = g(/^!?\[(label)\]\[(ref)\]/).replace("label", E).replace("ref", W).getRegex(), Se = g(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex(), ut = g("reflink|nolink(?!\\()", "g").replace("reflink", $e).replace("nolink", Se).getRegex(), ee = {
|
|
136
|
-
_backpedal: A,
|
|
137
|
-
// only used for GFM url
|
|
138
|
-
anyPunctuation: at,
|
|
139
|
-
autolink: ot,
|
|
140
|
-
blockSkip: tt,
|
|
141
|
-
br: xe,
|
|
142
|
-
code: We,
|
|
143
|
-
del: A,
|
|
144
|
-
emStrongLDelim: nt,
|
|
145
|
-
emStrongRDelimAst: st,
|
|
146
|
-
emStrongRDelimUnd: lt,
|
|
147
|
-
escape: Xe,
|
|
148
|
-
link: pt,
|
|
149
|
-
nolink: Se,
|
|
150
|
-
punctuation: Je,
|
|
151
|
-
reflink: $e,
|
|
152
|
-
reflinkSearch: ut,
|
|
153
|
-
tag: ht,
|
|
154
|
-
text: Ye,
|
|
155
|
-
url: A
|
|
156
|
-
}, dt = {
|
|
157
|
-
...ee,
|
|
158
|
-
link: g(/^!?\[(label)\]\((.*?)\)/).replace("label", E).getRegex(),
|
|
159
|
-
reflink: g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", E).getRegex()
|
|
160
|
-
}, H = {
|
|
161
|
-
...ee,
|
|
162
|
-
emStrongRDelimAst: it,
|
|
163
|
-
emStrongLDelim: rt,
|
|
164
|
-
url: g(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
|
|
165
|
-
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
166
|
-
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
|
|
167
|
-
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
168
|
-
}, gt = {
|
|
169
|
-
...H,
|
|
170
|
-
br: g(xe).replace("{2,}", "*").getRegex(),
|
|
171
|
-
text: g(H.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
172
|
-
}, L = {
|
|
173
|
-
normal: J,
|
|
174
|
-
gfm: Fe,
|
|
175
|
-
pedantic: Ve
|
|
176
|
-
}, T = {
|
|
177
|
-
normal: ee,
|
|
178
|
-
gfm: H,
|
|
179
|
-
breaks: gt,
|
|
180
|
-
pedantic: dt
|
|
181
|
-
}, ft = {
|
|
182
|
-
"&": "&",
|
|
183
|
-
"<": "<",
|
|
184
|
-
">": ">",
|
|
185
|
-
'"': """,
|
|
186
|
-
"'": "'"
|
|
187
|
-
}, oe = (n) => ft[n];
|
|
188
|
-
function y(n, e) {
|
|
19
|
+
var Ce = (() => {
|
|
20
|
+
try {
|
|
21
|
+
return !!new RegExp("(?<=1)(?<!1)");
|
|
22
|
+
} catch {
|
|
23
|
+
return !1;
|
|
24
|
+
}
|
|
25
|
+
})(), b = { 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, listReplaceTabs: /^\t+/, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (s) => new RegExp(`^( {0,3}${s})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (s) => new RegExp(`^ {0,${Math.min(3, s - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (s) => new RegExp(`^ {0,${Math.min(3, s - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (s) => new RegExp(`^ {0,${Math.min(3, s - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (s) => new RegExp(`^ {0,${Math.min(3, s - 1)}}#`), htmlBeginRegex: (s) => new RegExp(`^ {0,${Math.min(3, s - 1)}}<(?:[a-z].*>|!--)`, "i") }, Le = /^(?:[ \t]*(?:\n|$))+/, Ee = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Be = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, P = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, qe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, G = /(?:[*+-]|\d{1,9}[.)])/, de = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ge = d(de).replace(/bull/g, G).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(), Me = d(de).replace(/bull/g, G).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(), U = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, De = /^[^\n]+/, F = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Ze = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", F).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Oe = d(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, G).getRegex(), M = "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", V = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Ne = d("^ {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", V).replace("tag", M).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), ke = d(U).replace("hr", P).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex(), Qe = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ke).getRegex(), X = { blockquote: Qe, code: Ee, def: Ze, fences: Be, heading: qe, hr: P, html: Ne, lheading: ge, list: Oe, newline: Le, paragraph: ke, table: v, text: De }, se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", P).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex(), je = { ...X, lheading: Me, table: se, paragraph: d(U).replace("hr", P).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex() }, He = { ...X, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", V).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: v, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(U).replace("hr", P).replace("heading", ` *#{1,6} *[^
|
|
26
|
+
]`).replace("lheading", ge).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, Ge = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ue = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, fe = /^( {2,}|\\)\n(?!\s*$)/, Fe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, D = /[\p{P}\p{S}]/u, W = /[\s\p{P}\p{S}]/u, xe = /[^\s\p{P}\p{S}]/u, Ve = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, W).getRegex(), be = /(?!~)[\p{P}\p{S}]/u, Xe = /(?!~)[\s\p{P}\p{S}]/u, We = /(?:[^\s\p{P}\p{S}]|~)/u, Je = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Ce ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), me = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Ke = d(me, "u").replace(/punct/g, D).getRegex(), Ye = d(me, "u").replace(/punct/g, be).getRegex(), we = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", et = d(we, "gu").replace(/notPunctSpace/g, xe).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(), tt = d(we, "gu").replace(/notPunctSpace/g, We).replace(/punctSpace/g, Xe).replace(/punct/g, be).getRegex(), rt = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, xe).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(), st = d(/\\(punct)/, "gu").replace(/punct/g, D).getRegex(), nt = d(/^<(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(), lt = d(V).replace("(?:-->|$)", "-->").getRegex(), it = d("^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", lt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), E = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/, at = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", E).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ye = d(/^!?\[(label)\]\[(ref)\]/).replace("label", E).replace("ref", F).getRegex(), Re = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex(), ot = d("reflink|nolink(?!\\()", "g").replace("reflink", ye).replace("nolink", Re).getRegex(), ne = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, J = { _backpedal: v, anyPunctuation: st, autolink: nt, blockSkip: Je, br: fe, code: Ue, del: v, emStrongLDelim: Ke, emStrongRDelimAst: et, emStrongRDelimUnd: rt, escape: Ge, link: at, nolink: Re, punctuation: Ve, reflink: ye, reflinkSearch: ot, tag: it, text: Fe, url: v }, ct = { ...J, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", E).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", E).getRegex() }, N = { ...J, emStrongRDelimAst: tt, emStrongLDelim: Ye, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ne).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ne).getRegex() }, ht = { ...N, br: d(fe).replace("{2,}", "*").getRegex(), text: d(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, I = { normal: X, gfm: je, pedantic: He }, _ = { normal: J, gfm: N, breaks: ht, pedantic: ct }, pt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, le = (s) => pt[s];
|
|
27
|
+
function R(s, e) {
|
|
189
28
|
if (e) {
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return n.replace(w.escapeReplaceNoEncode, oe);
|
|
194
|
-
return n;
|
|
29
|
+
if (b.escapeTest.test(s)) return s.replace(b.escapeReplace, le);
|
|
30
|
+
} else if (b.escapeTestNoEncode.test(s)) return s.replace(b.escapeReplaceNoEncode, le);
|
|
31
|
+
return s;
|
|
195
32
|
}
|
|
196
|
-
function
|
|
33
|
+
function ie(s) {
|
|
197
34
|
try {
|
|
198
|
-
|
|
35
|
+
s = encodeURI(s).replace(b.percentDecode, "%");
|
|
199
36
|
} catch {
|
|
200
37
|
return null;
|
|
201
38
|
}
|
|
202
|
-
return
|
|
39
|
+
return s;
|
|
203
40
|
}
|
|
204
|
-
function
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
for (; --o >= 0 && h[o] === "\\"; ) a = !a;
|
|
41
|
+
function ae(s, e) {
|
|
42
|
+
let r = s.replace(b.findPipe, (i, l, c) => {
|
|
43
|
+
let a = !1, h = l;
|
|
44
|
+
for (; --h >= 0 && c[h] === "\\"; ) a = !a;
|
|
209
45
|
return a ? "|" : " |";
|
|
210
|
-
}),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
else
|
|
216
|
-
for (; r.length < e; ) r.push("");
|
|
217
|
-
for (; s < r.length; s++)
|
|
218
|
-
r[s] = r[s].trim().replace(w.slashPipe, "|");
|
|
219
|
-
return r;
|
|
220
|
-
}
|
|
221
|
-
function z(n, e, t) {
|
|
222
|
-
const r = n.length;
|
|
223
|
-
if (r === 0)
|
|
224
|
-
return "";
|
|
225
|
-
let s = 0;
|
|
226
|
-
for (; s < r && n.charAt(r - s - 1) === e; )
|
|
227
|
-
s++;
|
|
228
|
-
return n.slice(0, r - s);
|
|
46
|
+
}), n = r.split(b.splitPipe), t = 0;
|
|
47
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
|
|
48
|
+
else for (; n.length < e; ) n.push("");
|
|
49
|
+
for (; t < n.length; t++) n[t] = n[t].trim().replace(b.slashPipe, "|");
|
|
50
|
+
return n;
|
|
229
51
|
}
|
|
230
|
-
function
|
|
231
|
-
|
|
232
|
-
|
|
52
|
+
function z(s, e, r) {
|
|
53
|
+
let n = s.length;
|
|
54
|
+
if (n === 0) return "";
|
|
233
55
|
let t = 0;
|
|
234
|
-
for (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
else if (n[r] === e[0])
|
|
238
|
-
t++;
|
|
239
|
-
else if (n[r] === e[1] && (t--, t < 0))
|
|
240
|
-
return r;
|
|
241
|
-
return t > 0 ? -2 : -1;
|
|
56
|
+
for (; t < n && s.charAt(n - t - 1) === e; )
|
|
57
|
+
t++;
|
|
58
|
+
return s.slice(0, n - t);
|
|
242
59
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
r
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
title: c,
|
|
251
|
-
text: l,
|
|
252
|
-
tokens: r.inlineTokens(l)
|
|
253
|
-
};
|
|
254
|
-
return r.state.inLink = !1, h;
|
|
60
|
+
function ut(s, e) {
|
|
61
|
+
if (s.indexOf(e[1]) === -1) return -1;
|
|
62
|
+
let r = 0;
|
|
63
|
+
for (let n = 0; n < s.length; n++) if (s[n] === "\\") n++;
|
|
64
|
+
else if (s[n] === e[0]) r++;
|
|
65
|
+
else if (s[n] === e[1] && (r--, r < 0)) return n;
|
|
66
|
+
return r > 0 ? -2 : -1;
|
|
255
67
|
}
|
|
256
|
-
function
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
68
|
+
function oe(s, e, r, n, t) {
|
|
69
|
+
let i = e.href, l = e.title || null, c = s[1].replace(t.other.outputLinkReplace, "$1");
|
|
70
|
+
n.state.inLink = !0;
|
|
71
|
+
let a = { type: s[0].charAt(0) === "!" ? "image" : "link", raw: r, href: i, title: l, text: c, tokens: n.inlineTokens(c) };
|
|
72
|
+
return n.state.inLink = !1, a;
|
|
73
|
+
}
|
|
74
|
+
function dt(s, e, r) {
|
|
75
|
+
let n = s.match(r.other.indentCodeCompensation);
|
|
76
|
+
if (n === null) return e;
|
|
77
|
+
let t = n[1];
|
|
261
78
|
return e.split(`
|
|
262
79
|
`).map((i) => {
|
|
263
|
-
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return l.length >= s.length ? i.slice(s.length) : i;
|
|
80
|
+
let l = i.match(r.other.beginningSpace);
|
|
81
|
+
if (l === null) return i;
|
|
82
|
+
let [c] = l;
|
|
83
|
+
return c.length >= t.length ? i.slice(t.length) : i;
|
|
268
84
|
}).join(`
|
|
269
85
|
`);
|
|
270
86
|
}
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
type: "space",
|
|
285
|
-
raw: e[0]
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
code(n) {
|
|
289
|
-
const e = this.rules.block.code.exec(n);
|
|
87
|
+
var B = class {
|
|
88
|
+
options;
|
|
89
|
+
rules;
|
|
90
|
+
lexer;
|
|
91
|
+
constructor(s) {
|
|
92
|
+
this.options = s || S;
|
|
93
|
+
}
|
|
94
|
+
space(s) {
|
|
95
|
+
let e = this.rules.block.newline.exec(s);
|
|
96
|
+
if (e && e[0].length > 0) return { type: "space", raw: e[0] };
|
|
97
|
+
}
|
|
98
|
+
code(s) {
|
|
99
|
+
let e = this.rules.block.code.exec(s);
|
|
290
100
|
if (e) {
|
|
291
|
-
|
|
292
|
-
return {
|
|
293
|
-
|
|
294
|
-
raw: e[0],
|
|
295
|
-
codeBlockStyle: "indented",
|
|
296
|
-
text: this.options.pedantic ? t : z(t, `
|
|
297
|
-
`)
|
|
298
|
-
};
|
|
101
|
+
let r = e[0].replace(this.rules.other.codeRemoveIndent, "");
|
|
102
|
+
return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? r : z(r, `
|
|
103
|
+
`) };
|
|
299
104
|
}
|
|
300
105
|
}
|
|
301
|
-
fences(
|
|
302
|
-
|
|
106
|
+
fences(s) {
|
|
107
|
+
let e = this.rules.block.fences.exec(s);
|
|
303
108
|
if (e) {
|
|
304
|
-
|
|
305
|
-
return {
|
|
306
|
-
type: "code",
|
|
307
|
-
raw: t,
|
|
308
|
-
lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
|
|
309
|
-
text: r
|
|
310
|
-
};
|
|
109
|
+
let r = e[0], n = dt(r, e[3] || "", this.rules);
|
|
110
|
+
return { type: "code", raw: r, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: n };
|
|
311
111
|
}
|
|
312
112
|
}
|
|
313
|
-
heading(
|
|
314
|
-
|
|
113
|
+
heading(s) {
|
|
114
|
+
let e = this.rules.block.heading.exec(s);
|
|
315
115
|
if (e) {
|
|
316
|
-
let
|
|
317
|
-
if (this.rules.other.endingHash.test(
|
|
318
|
-
|
|
319
|
-
(this.options.pedantic || !
|
|
116
|
+
let r = e[2].trim();
|
|
117
|
+
if (this.rules.other.endingHash.test(r)) {
|
|
118
|
+
let n = z(r, "#");
|
|
119
|
+
(this.options.pedantic || !n || this.rules.other.endingSpaceChar.test(n)) && (r = n.trim());
|
|
320
120
|
}
|
|
321
|
-
return {
|
|
322
|
-
type: "heading",
|
|
323
|
-
raw: e[0],
|
|
324
|
-
depth: e[1].length,
|
|
325
|
-
text: t,
|
|
326
|
-
tokens: this.lexer.inline(t)
|
|
327
|
-
};
|
|
121
|
+
return { type: "heading", raw: e[0], depth: e[1].length, text: r, tokens: this.lexer.inline(r) };
|
|
328
122
|
}
|
|
329
123
|
}
|
|
330
|
-
hr(
|
|
331
|
-
|
|
332
|
-
if (e)
|
|
333
|
-
|
|
334
|
-
type: "hr",
|
|
335
|
-
raw: z(e[0], `
|
|
336
|
-
`)
|
|
337
|
-
};
|
|
124
|
+
hr(s) {
|
|
125
|
+
let e = this.rules.block.hr.exec(s);
|
|
126
|
+
if (e) return { type: "hr", raw: z(e[0], `
|
|
127
|
+
`) };
|
|
338
128
|
}
|
|
339
|
-
blockquote(
|
|
340
|
-
|
|
129
|
+
blockquote(s) {
|
|
130
|
+
let e = this.rules.block.blockquote.exec(s);
|
|
341
131
|
if (e) {
|
|
342
|
-
let
|
|
132
|
+
let r = z(e[0], `
|
|
343
133
|
`).split(`
|
|
344
|
-
`),
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
else if (!c)
|
|
354
|
-
l.push(t[h]);
|
|
355
|
-
else
|
|
356
|
-
break;
|
|
357
|
-
t = t.slice(h);
|
|
358
|
-
const a = l.join(`
|
|
359
|
-
`), o = a.replace(this.rules.other.blockquoteSetextReplace, `
|
|
134
|
+
`), n = "", t = "", i = [];
|
|
135
|
+
for (; r.length > 0; ) {
|
|
136
|
+
let l = !1, c = [], a;
|
|
137
|
+
for (a = 0; a < r.length; a++) if (this.rules.other.blockquoteStart.test(r[a])) c.push(r[a]), l = !0;
|
|
138
|
+
else if (!l) c.push(r[a]);
|
|
139
|
+
else break;
|
|
140
|
+
r = r.slice(a);
|
|
141
|
+
let h = c.join(`
|
|
142
|
+
`), o = h.replace(this.rules.other.blockquoteSetextReplace, `
|
|
360
143
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
361
|
-
|
|
362
|
-
${
|
|
144
|
+
n = n ? `${n}
|
|
145
|
+
${h}` : h, t = t ? `${t}
|
|
363
146
|
${o}` : o;
|
|
364
|
-
|
|
365
|
-
if (this.lexer.state.top = !0, this.lexer.blockTokens(o, i, !0), this.lexer.state.top =
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (
|
|
147
|
+
let p = this.lexer.state.top;
|
|
148
|
+
if (this.lexer.state.top = !0, this.lexer.blockTokens(o, i, !0), this.lexer.state.top = p, r.length === 0) break;
|
|
149
|
+
let u = i.at(-1);
|
|
150
|
+
if (u?.type === "code") break;
|
|
151
|
+
if (u?.type === "blockquote") {
|
|
152
|
+
let f = u, k = f.raw + `
|
|
153
|
+
` + r.join(`
|
|
154
|
+
`), m = this.blockquote(k);
|
|
155
|
+
i[i.length - 1] = m, n = n.substring(0, n.length - f.raw.length) + m.raw, t = t.substring(0, t.length - f.text.length) + m.text;
|
|
369
156
|
break;
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
` +
|
|
373
|
-
`),
|
|
374
|
-
i[i.length - 1] =
|
|
375
|
-
break;
|
|
376
|
-
} else if ((p == null ? void 0 : p.type) === "list") {
|
|
377
|
-
const m = p, d = m.raw + `
|
|
378
|
-
` + t.join(`
|
|
379
|
-
`), b = this.list(d);
|
|
380
|
-
i[i.length - 1] = b, r = r.substring(0, r.length - p.raw.length) + b.raw, s = s.substring(0, s.length - m.raw.length) + b.raw, t = d.substring(i.at(-1).raw.length).split(`
|
|
157
|
+
} else if (u?.type === "list") {
|
|
158
|
+
let f = u, k = f.raw + `
|
|
159
|
+
` + r.join(`
|
|
160
|
+
`), m = this.list(k);
|
|
161
|
+
i[i.length - 1] = m, n = n.substring(0, n.length - u.raw.length) + m.raw, t = t.substring(0, t.length - f.raw.length) + m.raw, r = k.substring(i.at(-1).raw.length).split(`
|
|
381
162
|
`);
|
|
382
163
|
continue;
|
|
383
164
|
}
|
|
384
165
|
}
|
|
385
|
-
return {
|
|
386
|
-
type: "blockquote",
|
|
387
|
-
raw: r,
|
|
388
|
-
tokens: i,
|
|
389
|
-
text: s
|
|
390
|
-
};
|
|
166
|
+
return { type: "blockquote", raw: n, tokens: i, text: t };
|
|
391
167
|
}
|
|
392
168
|
}
|
|
393
|
-
list(
|
|
394
|
-
let e = this.rules.block.list.exec(
|
|
169
|
+
list(s) {
|
|
170
|
+
let e = this.rules.block.list.exec(s);
|
|
395
171
|
if (e) {
|
|
396
|
-
let
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
`, 1)[0], m = !u.trim(), d = 0;
|
|
416
|
-
if (this.options.pedantic ? (d = 2, o = u.trimStart()) : m ? d = e[1].length + 1 : (d = e[2].search(this.rules.other.nonSpaceChar), d = d > 4 ? 1 : d, o = u.slice(d), d += e[1].length), m && this.rules.other.blankLine.test(p) && (a += p + `
|
|
417
|
-
`, n = n.substring(p.length + 1), h = !0), !h) {
|
|
418
|
-
const N = this.rules.other.nextBulletRegex(d), re = this.rules.other.hrRegex(d), se = this.rules.other.fencesBeginRegex(d), ie = this.rules.other.headingBeginRegex(d), _e = this.rules.other.htmlBeginRegex(d);
|
|
419
|
-
for (; n; ) {
|
|
420
|
-
const Z = n.split(`
|
|
421
|
-
`, 1)[0];
|
|
422
|
-
let _;
|
|
423
|
-
if (p = Z, this.options.pedantic ? (p = p.replace(this.rules.other.listReplaceNesting, " "), _ = p) : _ = p.replace(this.rules.other.tabCharGlobal, " "), se.test(p) || ie.test(p) || _e.test(p) || N.test(p) || re.test(p))
|
|
424
|
-
break;
|
|
425
|
-
if (_.search(this.rules.other.nonSpaceChar) >= d || !p.trim())
|
|
426
|
-
o += `
|
|
427
|
-
` + _.slice(d);
|
|
172
|
+
let r = e[1].trim(), n = r.length > 1, t = { type: "list", raw: "", ordered: n, start: n ? +r.slice(0, -1) : "", loose: !1, items: [] };
|
|
173
|
+
r = n ? `\\d{1,9}\\${r.slice(-1)}` : `\\${r}`, this.options.pedantic && (r = n ? r : "[*+-]");
|
|
174
|
+
let i = this.rules.other.listItemRegex(r), l = !1;
|
|
175
|
+
for (; s; ) {
|
|
176
|
+
let a = !1, h = "", o = "";
|
|
177
|
+
if (!(e = i.exec(s)) || this.rules.block.hr.test(s)) break;
|
|
178
|
+
h = e[0], s = s.substring(h.length);
|
|
179
|
+
let p = e[2].split(`
|
|
180
|
+
`, 1)[0].replace(this.rules.other.listReplaceTabs, (m) => " ".repeat(3 * m.length)), u = s.split(`
|
|
181
|
+
`, 1)[0], f = !p.trim(), k = 0;
|
|
182
|
+
if (this.options.pedantic ? (k = 2, o = p.trimStart()) : f ? k = e[1].length + 1 : (k = e[2].search(this.rules.other.nonSpaceChar), k = k > 4 ? 1 : k, o = p.slice(k), k += e[1].length), f && this.rules.other.blankLine.test(u) && (h += u + `
|
|
183
|
+
`, s = s.substring(u.length + 1), a = !0), !a) {
|
|
184
|
+
let m = this.rules.other.nextBulletRegex(k), Y = this.rules.other.hrRegex(k), ee = this.rules.other.fencesBeginRegex(k), te = this.rules.other.headingBeginRegex(k), $e = this.rules.other.htmlBeginRegex(k);
|
|
185
|
+
for (; s; ) {
|
|
186
|
+
let Z = s.split(`
|
|
187
|
+
`, 1)[0], T;
|
|
188
|
+
if (u = Z, this.options.pedantic ? (u = u.replace(this.rules.other.listReplaceNesting, " "), T = u) : T = u.replace(this.rules.other.tabCharGlobal, " "), ee.test(u) || te.test(u) || $e.test(u) || m.test(u) || Y.test(u)) break;
|
|
189
|
+
if (T.search(this.rules.other.nonSpaceChar) >= k || !u.trim()) o += `
|
|
190
|
+
` + T.slice(k);
|
|
428
191
|
else {
|
|
429
|
-
if (
|
|
430
|
-
break;
|
|
192
|
+
if (f || p.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ee.test(p) || te.test(p) || Y.test(p)) break;
|
|
431
193
|
o += `
|
|
432
|
-
` +
|
|
194
|
+
` + u;
|
|
433
195
|
}
|
|
434
|
-
!
|
|
435
|
-
`,
|
|
196
|
+
!f && !u.trim() && (f = !0), h += Z + `
|
|
197
|
+
`, s = s.substring(Z.length + 1), p = T.slice(k);
|
|
436
198
|
}
|
|
437
199
|
}
|
|
438
|
-
|
|
439
|
-
let b = null, ne;
|
|
440
|
-
this.options.gfm && (b = this.rules.other.listIsTask.exec(o), b && (ne = b[0] !== "[ ] ", o = o.replace(this.rules.other.listReplaceTask, ""))), s.items.push({
|
|
441
|
-
type: "list_item",
|
|
442
|
-
raw: a,
|
|
443
|
-
task: !!b,
|
|
444
|
-
checked: ne,
|
|
445
|
-
loose: !1,
|
|
446
|
-
text: o,
|
|
447
|
-
tokens: []
|
|
448
|
-
}), s.raw += a;
|
|
200
|
+
t.loose || (l ? t.loose = !0 : this.rules.other.doubleBlankLine.test(h) && (l = !0)), t.items.push({ type: "list_item", raw: h, task: !!this.options.gfm && this.rules.other.listIsTask.test(o), loose: !1, text: o, tokens: [] }), t.raw += h;
|
|
449
201
|
}
|
|
450
|
-
|
|
451
|
-
if (
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
202
|
+
let c = t.items.at(-1);
|
|
203
|
+
if (c) c.raw = c.raw.trimEnd(), c.text = c.text.trimEnd();
|
|
204
|
+
else return;
|
|
205
|
+
t.raw = t.raw.trimEnd();
|
|
206
|
+
for (let a of t.items) {
|
|
207
|
+
if (this.lexer.state.top = !1, a.tokens = this.lexer.blockTokens(a.text, []), a.task) {
|
|
208
|
+
if (a.text = a.text.replace(this.rules.other.listReplaceTask, ""), a.tokens[0]?.type === "text" || a.tokens[0]?.type === "paragraph") {
|
|
209
|
+
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, "");
|
|
210
|
+
for (let o = this.lexer.inlineQueue.length - 1; o >= 0; o--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[o].src)) {
|
|
211
|
+
this.lexer.inlineQueue[o].src = this.lexer.inlineQueue[o].src.replace(this.rules.other.listReplaceTask, "");
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
let h = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
216
|
+
if (h) {
|
|
217
|
+
let o = { type: "checkbox", raw: h[0] + " ", checked: h[0] !== "[ ]" };
|
|
218
|
+
a.checked = o.checked, t.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = o.raw + a.tokens[0].raw, a.tokens[0].text = o.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(o)) : a.tokens.unshift({ type: "paragraph", raw: o.raw, text: o.raw, tokens: [o] }) : a.tokens.unshift(o);
|
|
219
|
+
}
|
|
460
220
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
221
|
+
if (!t.loose) {
|
|
222
|
+
let h = a.tokens.filter((p) => p.type === "space"), o = h.length > 0 && h.some((p) => this.rules.other.anyLine.test(p.raw));
|
|
223
|
+
t.loose = o;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (t.loose) for (let a of t.items) {
|
|
227
|
+
a.loose = !0;
|
|
228
|
+
for (let h of a.tokens) h.type === "text" && (h.type = "paragraph");
|
|
229
|
+
}
|
|
230
|
+
return t;
|
|
465
231
|
}
|
|
466
232
|
}
|
|
467
|
-
html(
|
|
468
|
-
|
|
469
|
-
if (e)
|
|
470
|
-
return {
|
|
471
|
-
type: "html",
|
|
472
|
-
block: !0,
|
|
473
|
-
raw: e[0],
|
|
474
|
-
pre: e[1] === "pre" || e[1] === "script" || e[1] === "style",
|
|
475
|
-
text: e[0]
|
|
476
|
-
};
|
|
233
|
+
html(s) {
|
|
234
|
+
let e = this.rules.block.html.exec(s);
|
|
235
|
+
if (e) return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] };
|
|
477
236
|
}
|
|
478
|
-
def(
|
|
479
|
-
|
|
237
|
+
def(s) {
|
|
238
|
+
let e = this.rules.block.def.exec(s);
|
|
480
239
|
if (e) {
|
|
481
|
-
|
|
482
|
-
return {
|
|
483
|
-
type: "def",
|
|
484
|
-
tag: t,
|
|
485
|
-
raw: e[0],
|
|
486
|
-
href: r,
|
|
487
|
-
title: s
|
|
488
|
-
};
|
|
240
|
+
let r = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), n = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", t = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
|
|
241
|
+
return { type: "def", tag: r, raw: e[0], href: n, title: t };
|
|
489
242
|
}
|
|
490
243
|
}
|
|
491
|
-
table(
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
header: [],
|
|
501
|
-
align: [],
|
|
502
|
-
rows: []
|
|
503
|
-
};
|
|
504
|
-
if (t.length === r.length) {
|
|
505
|
-
for (const l of r)
|
|
506
|
-
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);
|
|
507
|
-
for (let l = 0; l < t.length; l++)
|
|
508
|
-
i.header.push({
|
|
509
|
-
text: t[l],
|
|
510
|
-
tokens: this.lexer.inline(t[l]),
|
|
511
|
-
header: !0,
|
|
512
|
-
align: i.align[l]
|
|
513
|
-
});
|
|
514
|
-
for (const l of s)
|
|
515
|
-
i.rows.push(he(l, i.header.length).map((h, a) => ({
|
|
516
|
-
text: h,
|
|
517
|
-
tokens: this.lexer.inline(h),
|
|
518
|
-
header: !1,
|
|
519
|
-
align: i.align[a]
|
|
520
|
-
})));
|
|
244
|
+
table(s) {
|
|
245
|
+
let e = this.rules.block.table.exec(s);
|
|
246
|
+
if (!e || !this.rules.other.tableDelimiter.test(e[2])) return;
|
|
247
|
+
let r = ae(e[1]), n = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), t = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
248
|
+
`) : [], i = { type: "table", raw: e[0], header: [], align: [], rows: [] };
|
|
249
|
+
if (r.length === n.length) {
|
|
250
|
+
for (let l of n) 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);
|
|
251
|
+
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] });
|
|
252
|
+
for (let l of t) i.rows.push(ae(l, i.header.length).map((c, a) => ({ text: c, tokens: this.lexer.inline(c), header: !1, align: i.align[a] })));
|
|
521
253
|
return i;
|
|
522
254
|
}
|
|
523
255
|
}
|
|
524
|
-
lheading(
|
|
525
|
-
|
|
526
|
-
if (e)
|
|
527
|
-
return {
|
|
528
|
-
type: "heading",
|
|
529
|
-
raw: e[0],
|
|
530
|
-
depth: e[2].charAt(0) === "=" ? 1 : 2,
|
|
531
|
-
text: e[1],
|
|
532
|
-
tokens: this.lexer.inline(e[1])
|
|
533
|
-
};
|
|
256
|
+
lheading(s) {
|
|
257
|
+
let e = this.rules.block.lheading.exec(s);
|
|
258
|
+
if (e) return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: e[1], tokens: this.lexer.inline(e[1]) };
|
|
534
259
|
}
|
|
535
|
-
paragraph(
|
|
536
|
-
|
|
260
|
+
paragraph(s) {
|
|
261
|
+
let e = this.rules.block.paragraph.exec(s);
|
|
537
262
|
if (e) {
|
|
538
|
-
|
|
263
|
+
let r = e[1].charAt(e[1].length - 1) === `
|
|
539
264
|
` ? e[1].slice(0, -1) : e[1];
|
|
540
|
-
return {
|
|
541
|
-
type: "paragraph",
|
|
542
|
-
raw: e[0],
|
|
543
|
-
text: t,
|
|
544
|
-
tokens: this.lexer.inline(t)
|
|
545
|
-
};
|
|
265
|
+
return { type: "paragraph", raw: e[0], text: r, tokens: this.lexer.inline(r) };
|
|
546
266
|
}
|
|
547
267
|
}
|
|
548
|
-
text(
|
|
549
|
-
|
|
550
|
-
if (e)
|
|
551
|
-
return {
|
|
552
|
-
type: "text",
|
|
553
|
-
raw: e[0],
|
|
554
|
-
text: e[0],
|
|
555
|
-
tokens: this.lexer.inline(e[0])
|
|
556
|
-
};
|
|
268
|
+
text(s) {
|
|
269
|
+
let e = this.rules.block.text.exec(s);
|
|
270
|
+
if (e) return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) };
|
|
557
271
|
}
|
|
558
|
-
escape(
|
|
559
|
-
|
|
560
|
-
if (e)
|
|
561
|
-
return {
|
|
562
|
-
type: "escape",
|
|
563
|
-
raw: e[0],
|
|
564
|
-
text: e[1]
|
|
565
|
-
};
|
|
272
|
+
escape(s) {
|
|
273
|
+
let e = this.rules.inline.escape.exec(s);
|
|
274
|
+
if (e) return { type: "escape", raw: e[0], text: e[1] };
|
|
566
275
|
}
|
|
567
|
-
tag(
|
|
568
|
-
|
|
569
|
-
if (e)
|
|
570
|
-
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), {
|
|
571
|
-
type: "html",
|
|
572
|
-
raw: e[0],
|
|
573
|
-
inLink: this.lexer.state.inLink,
|
|
574
|
-
inRawBlock: this.lexer.state.inRawBlock,
|
|
575
|
-
block: !1,
|
|
576
|
-
text: e[0]
|
|
577
|
-
};
|
|
276
|
+
tag(s) {
|
|
277
|
+
let e = this.rules.inline.tag.exec(s);
|
|
278
|
+
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] };
|
|
578
279
|
}
|
|
579
|
-
link(
|
|
580
|
-
|
|
280
|
+
link(s) {
|
|
281
|
+
let e = this.rules.inline.link.exec(s);
|
|
581
282
|
if (e) {
|
|
582
|
-
|
|
583
|
-
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(
|
|
584
|
-
if (!this.rules.other.endAngleBracket.test(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
if ((t.length - i.length) % 2 === 0)
|
|
588
|
-
return;
|
|
283
|
+
let r = e[2].trim();
|
|
284
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
|
|
285
|
+
if (!this.rules.other.endAngleBracket.test(r)) return;
|
|
286
|
+
let i = z(r.slice(0, -1), "\\");
|
|
287
|
+
if ((r.length - i.length) % 2 === 0) return;
|
|
589
288
|
} else {
|
|
590
|
-
|
|
591
|
-
if (i === -2)
|
|
592
|
-
return;
|
|
289
|
+
let i = ut(e[2], "()");
|
|
290
|
+
if (i === -2) return;
|
|
593
291
|
if (i > -1) {
|
|
594
|
-
|
|
292
|
+
let l = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
|
|
595
293
|
e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, l).trim(), e[3] = "";
|
|
596
294
|
}
|
|
597
295
|
}
|
|
598
|
-
let
|
|
296
|
+
let n = e[2], t = "";
|
|
599
297
|
if (this.options.pedantic) {
|
|
600
|
-
|
|
601
|
-
i && (
|
|
602
|
-
} else
|
|
603
|
-
|
|
604
|
-
return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? r = r.slice(1) : r = r.slice(1, -1)), pe(e, {
|
|
605
|
-
href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
606
|
-
title: s && s.replace(this.rules.inline.anyPunctuation, "$1")
|
|
607
|
-
}, e[0], this.lexer, this.rules);
|
|
298
|
+
let i = this.rules.other.pedanticHrefTitle.exec(n);
|
|
299
|
+
i && (n = i[1], t = i[3]);
|
|
300
|
+
} else t = e[3] ? e[3].slice(1, -1) : "";
|
|
301
|
+
return n = n.trim(), this.rules.other.startAngleBracket.test(n) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(r) ? n = n.slice(1) : n = n.slice(1, -1)), oe(e, { href: n && n.replace(this.rules.inline.anyPunctuation, "$1"), title: t && t.replace(this.rules.inline.anyPunctuation, "$1") }, e[0], this.lexer, this.rules);
|
|
608
302
|
}
|
|
609
303
|
}
|
|
610
|
-
reflink(
|
|
611
|
-
let
|
|
612
|
-
if ((
|
|
613
|
-
|
|
614
|
-
if (!
|
|
615
|
-
|
|
616
|
-
return {
|
|
617
|
-
type: "text",
|
|
618
|
-
raw: i,
|
|
619
|
-
text: i
|
|
620
|
-
};
|
|
304
|
+
reflink(s, e) {
|
|
305
|
+
let r;
|
|
306
|
+
if ((r = this.rules.inline.reflink.exec(s)) || (r = this.rules.inline.nolink.exec(s))) {
|
|
307
|
+
let n = (r[2] || r[1]).replace(this.rules.other.multipleSpaceGlobal, " "), t = e[n.toLowerCase()];
|
|
308
|
+
if (!t) {
|
|
309
|
+
let i = r[0].charAt(0);
|
|
310
|
+
return { type: "text", raw: i, text: i };
|
|
621
311
|
}
|
|
622
|
-
return
|
|
312
|
+
return oe(r, t, r[0], this.lexer, this.rules);
|
|
623
313
|
}
|
|
624
314
|
}
|
|
625
|
-
emStrong(
|
|
626
|
-
let
|
|
627
|
-
if (!
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (c = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !c) continue;
|
|
634
|
-
if (l = [...c].length, r[3] || r[4]) {
|
|
635
|
-
h += l;
|
|
315
|
+
emStrong(s, e, r = "") {
|
|
316
|
+
let n = this.rules.inline.emStrongLDelim.exec(s);
|
|
317
|
+
if (!(!n || n[3] && r.match(this.rules.other.unicodeAlphaNumeric)) && (!(n[1] || n[2]) || !r || this.rules.inline.punctuation.exec(r))) {
|
|
318
|
+
let t = [...n[0]].length - 1, i, l, c = t, a = 0, h = n[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
319
|
+
for (h.lastIndex = 0, e = e.slice(-1 * s.length + t); (n = h.exec(e)) != null; ) {
|
|
320
|
+
if (i = n[1] || n[2] || n[3] || n[4] || n[5] || n[6], !i) continue;
|
|
321
|
+
if (l = [...i].length, n[3] || n[4]) {
|
|
322
|
+
c += l;
|
|
636
323
|
continue;
|
|
637
|
-
} else if ((
|
|
324
|
+
} else if ((n[5] || n[6]) && t % 3 && !((t + l) % 3)) {
|
|
638
325
|
a += l;
|
|
639
326
|
continue;
|
|
640
327
|
}
|
|
641
|
-
if (
|
|
642
|
-
l = Math.min(l, l +
|
|
643
|
-
|
|
644
|
-
if (Math.min(
|
|
645
|
-
|
|
646
|
-
return {
|
|
647
|
-
type: "em",
|
|
648
|
-
raw: p,
|
|
649
|
-
text: d,
|
|
650
|
-
tokens: this.lexer.inlineTokens(d)
|
|
651
|
-
};
|
|
328
|
+
if (c -= l, c > 0) continue;
|
|
329
|
+
l = Math.min(l, l + c + a);
|
|
330
|
+
let o = [...n[0]][0].length, p = s.slice(0, t + n.index + o + l);
|
|
331
|
+
if (Math.min(t, l) % 2) {
|
|
332
|
+
let f = p.slice(1, -1);
|
|
333
|
+
return { type: "em", raw: p, text: f, tokens: this.lexer.inlineTokens(f) };
|
|
652
334
|
}
|
|
653
|
-
|
|
654
|
-
return {
|
|
655
|
-
type: "strong",
|
|
656
|
-
raw: p,
|
|
657
|
-
text: m,
|
|
658
|
-
tokens: this.lexer.inlineTokens(m)
|
|
659
|
-
};
|
|
335
|
+
let u = p.slice(2, -2);
|
|
336
|
+
return { type: "strong", raw: p, text: u, tokens: this.lexer.inlineTokens(u) };
|
|
660
337
|
}
|
|
661
338
|
}
|
|
662
339
|
}
|
|
663
|
-
codespan(
|
|
664
|
-
|
|
340
|
+
codespan(s) {
|
|
341
|
+
let e = this.rules.inline.code.exec(s);
|
|
665
342
|
if (e) {
|
|
666
|
-
let
|
|
667
|
-
|
|
668
|
-
return r && s && (t = t.substring(1, t.length - 1)), {
|
|
669
|
-
type: "codespan",
|
|
670
|
-
raw: e[0],
|
|
671
|
-
text: t
|
|
672
|
-
};
|
|
343
|
+
let r = e[2].replace(this.rules.other.newLineCharGlobal, " "), n = this.rules.other.nonSpaceChar.test(r), t = this.rules.other.startingSpaceChar.test(r) && this.rules.other.endingSpaceChar.test(r);
|
|
344
|
+
return n && t && (r = r.substring(1, r.length - 1)), { type: "codespan", raw: e[0], text: r };
|
|
673
345
|
}
|
|
674
346
|
}
|
|
675
|
-
br(
|
|
676
|
-
|
|
677
|
-
if (e)
|
|
678
|
-
return {
|
|
679
|
-
type: "br",
|
|
680
|
-
raw: e[0]
|
|
681
|
-
};
|
|
347
|
+
br(s) {
|
|
348
|
+
let e = this.rules.inline.br.exec(s);
|
|
349
|
+
if (e) return { type: "br", raw: e[0] };
|
|
682
350
|
}
|
|
683
|
-
del(
|
|
684
|
-
|
|
685
|
-
if (e)
|
|
686
|
-
return {
|
|
687
|
-
type: "del",
|
|
688
|
-
raw: e[0],
|
|
689
|
-
text: e[2],
|
|
690
|
-
tokens: this.lexer.inlineTokens(e[2])
|
|
691
|
-
};
|
|
351
|
+
del(s) {
|
|
352
|
+
let e = this.rules.inline.del.exec(s);
|
|
353
|
+
if (e) return { type: "del", raw: e[0], text: e[2], tokens: this.lexer.inlineTokens(e[2]) };
|
|
692
354
|
}
|
|
693
|
-
autolink(
|
|
694
|
-
|
|
355
|
+
autolink(s) {
|
|
356
|
+
let e = this.rules.inline.autolink.exec(s);
|
|
695
357
|
if (e) {
|
|
696
|
-
let
|
|
697
|
-
return e[2] === "@" ? (
|
|
698
|
-
type: "link",
|
|
699
|
-
raw: e[0],
|
|
700
|
-
text: t,
|
|
701
|
-
href: r,
|
|
702
|
-
tokens: [
|
|
703
|
-
{
|
|
704
|
-
type: "text",
|
|
705
|
-
raw: t,
|
|
706
|
-
text: t
|
|
707
|
-
}
|
|
708
|
-
]
|
|
709
|
-
};
|
|
358
|
+
let r, n;
|
|
359
|
+
return e[2] === "@" ? (r = e[1], n = "mailto:" + r) : (r = e[1], n = r), { type: "link", raw: e[0], text: r, href: n, tokens: [{ type: "text", raw: r, text: r }] };
|
|
710
360
|
}
|
|
711
361
|
}
|
|
712
|
-
url(
|
|
713
|
-
var t;
|
|
362
|
+
url(s) {
|
|
714
363
|
let e;
|
|
715
|
-
if (e = this.rules.inline.url.exec(
|
|
716
|
-
let r,
|
|
717
|
-
if (e[2] === "@")
|
|
718
|
-
r = e[0], s = "mailto:" + r;
|
|
364
|
+
if (e = this.rules.inline.url.exec(s)) {
|
|
365
|
+
let r, n;
|
|
366
|
+
if (e[2] === "@") r = e[0], n = "mailto:" + r;
|
|
719
367
|
else {
|
|
720
|
-
let
|
|
368
|
+
let t;
|
|
721
369
|
do
|
|
722
|
-
|
|
723
|
-
while (
|
|
724
|
-
r = e[0], e[1] === "www." ?
|
|
370
|
+
t = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? "";
|
|
371
|
+
while (t !== e[0]);
|
|
372
|
+
r = e[0], e[1] === "www." ? n = "http://" + e[0] : n = e[0];
|
|
725
373
|
}
|
|
726
|
-
return {
|
|
727
|
-
type: "link",
|
|
728
|
-
raw: e[0],
|
|
729
|
-
text: r,
|
|
730
|
-
href: s,
|
|
731
|
-
tokens: [
|
|
732
|
-
{
|
|
733
|
-
type: "text",
|
|
734
|
-
raw: r,
|
|
735
|
-
text: r
|
|
736
|
-
}
|
|
737
|
-
]
|
|
738
|
-
};
|
|
374
|
+
return { type: "link", raw: e[0], text: r, href: n, tokens: [{ type: "text", raw: r, text: r }] };
|
|
739
375
|
}
|
|
740
376
|
}
|
|
741
|
-
inlineText(
|
|
742
|
-
|
|
377
|
+
inlineText(s) {
|
|
378
|
+
let e = this.rules.inline.text.exec(s);
|
|
743
379
|
if (e) {
|
|
744
|
-
|
|
745
|
-
return {
|
|
746
|
-
type: "text",
|
|
747
|
-
raw: e[0],
|
|
748
|
-
text: e[0],
|
|
749
|
-
escaped: t
|
|
750
|
-
};
|
|
380
|
+
let r = this.lexer.state.inRawBlock;
|
|
381
|
+
return { type: "text", raw: e[0], text: e[0], escaped: r };
|
|
751
382
|
}
|
|
752
383
|
}
|
|
753
|
-
},
|
|
384
|
+
}, w = class Q {
|
|
385
|
+
tokens;
|
|
386
|
+
options;
|
|
387
|
+
state;
|
|
388
|
+
inlineQueue;
|
|
389
|
+
tokenizer;
|
|
754
390
|
constructor(e) {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
k(this, "tokenizer");
|
|
759
|
-
k(this, "inlineQueue");
|
|
760
|
-
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || S, 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 = {
|
|
761
|
-
inLink: !1,
|
|
762
|
-
inRawBlock: !1,
|
|
763
|
-
top: !0
|
|
764
|
-
};
|
|
765
|
-
const t = {
|
|
766
|
-
other: w,
|
|
767
|
-
block: L.normal,
|
|
768
|
-
inline: T.normal
|
|
769
|
-
};
|
|
770
|
-
this.options.pedantic ? (t.block = L.pedantic, t.inline = T.pedantic) : this.options.gfm && (t.block = L.gfm, this.options.breaks ? t.inline = T.breaks : t.inline = T.gfm), this.tokenizer.rules = t;
|
|
391
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || S, this.options.tokenizer = this.options.tokenizer || new B(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 };
|
|
392
|
+
let r = { other: b, block: I.normal, inline: _.normal };
|
|
393
|
+
this.options.pedantic ? (r.block = I.pedantic, r.inline = _.pedantic) : this.options.gfm && (r.block = I.gfm, this.options.breaks ? r.inline = _.breaks : r.inline = _.gfm), this.tokenizer.rules = r;
|
|
771
394
|
}
|
|
772
|
-
/**
|
|
773
|
-
* Expose Rules
|
|
774
|
-
*/
|
|
775
395
|
static get rules() {
|
|
776
|
-
return {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
396
|
+
return { block: I, inline: _ };
|
|
397
|
+
}
|
|
398
|
+
static lex(e, r) {
|
|
399
|
+
return new Q(r).lex(e);
|
|
400
|
+
}
|
|
401
|
+
static lexInline(e, r) {
|
|
402
|
+
return new Q(r).inlineTokens(e);
|
|
780
403
|
}
|
|
781
|
-
/**
|
|
782
|
-
* Static Lex Method
|
|
783
|
-
*/
|
|
784
|
-
static lex(e, t) {
|
|
785
|
-
return new Q(t).lex(e);
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* Static Lex Inline Method
|
|
789
|
-
*/
|
|
790
|
-
static lexInline(e, t) {
|
|
791
|
-
return new Q(t).inlineTokens(e);
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Preprocessing
|
|
795
|
-
*/
|
|
796
404
|
lex(e) {
|
|
797
|
-
e = e.replace(
|
|
405
|
+
e = e.replace(b.carriageReturn, `
|
|
798
406
|
`), this.blockTokens(e, this.tokens);
|
|
799
|
-
for (let
|
|
800
|
-
|
|
801
|
-
this.inlineTokens(
|
|
407
|
+
for (let r = 0; r < this.inlineQueue.length; r++) {
|
|
408
|
+
let n = this.inlineQueue[r];
|
|
409
|
+
this.inlineTokens(n.src, n.tokens);
|
|
802
410
|
}
|
|
803
411
|
return this.inlineQueue = [], this.tokens;
|
|
804
412
|
}
|
|
805
|
-
blockTokens(e,
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
if (
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
l.raw.length === 1 && a !== void 0 ? a.raw += `
|
|
815
|
-
` : t.push(l);
|
|
413
|
+
blockTokens(e, r = [], n = !1) {
|
|
414
|
+
for (this.options.pedantic && (e = e.replace(b.tabCharGlobal, " ").replace(b.spaceLine, "")); e; ) {
|
|
415
|
+
let t;
|
|
416
|
+
if (this.options.extensions?.block?.some((l) => (t = l.call({ lexer: this }, e, r)) ? (e = e.substring(t.raw.length), r.push(t), !0) : !1)) continue;
|
|
417
|
+
if (t = this.tokenizer.space(e)) {
|
|
418
|
+
e = e.substring(t.raw.length);
|
|
419
|
+
let l = r.at(-1);
|
|
420
|
+
t.raw.length === 1 && l !== void 0 ? l.raw += `
|
|
421
|
+
` : r.push(t);
|
|
816
422
|
continue;
|
|
817
423
|
}
|
|
818
|
-
if (
|
|
819
|
-
e = e.substring(
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
`
|
|
823
|
-
` +
|
|
424
|
+
if (t = this.tokenizer.code(e)) {
|
|
425
|
+
e = e.substring(t.raw.length);
|
|
426
|
+
let l = r.at(-1);
|
|
427
|
+
l?.type === "paragraph" || l?.type === "text" ? (l.raw += (l.raw.endsWith(`
|
|
428
|
+
`) ? "" : `
|
|
429
|
+
`) + t.raw, l.text += `
|
|
430
|
+
` + t.text, this.inlineQueue.at(-1).src = l.text) : r.push(t);
|
|
824
431
|
continue;
|
|
825
432
|
}
|
|
826
|
-
if (
|
|
827
|
-
e = e.substring(
|
|
433
|
+
if (t = this.tokenizer.fences(e)) {
|
|
434
|
+
e = e.substring(t.raw.length), r.push(t);
|
|
828
435
|
continue;
|
|
829
436
|
}
|
|
830
|
-
if (
|
|
831
|
-
e = e.substring(
|
|
437
|
+
if (t = this.tokenizer.heading(e)) {
|
|
438
|
+
e = e.substring(t.raw.length), r.push(t);
|
|
832
439
|
continue;
|
|
833
440
|
}
|
|
834
|
-
if (
|
|
835
|
-
e = e.substring(
|
|
441
|
+
if (t = this.tokenizer.hr(e)) {
|
|
442
|
+
e = e.substring(t.raw.length), r.push(t);
|
|
836
443
|
continue;
|
|
837
444
|
}
|
|
838
|
-
if (
|
|
839
|
-
e = e.substring(
|
|
445
|
+
if (t = this.tokenizer.blockquote(e)) {
|
|
446
|
+
e = e.substring(t.raw.length), r.push(t);
|
|
840
447
|
continue;
|
|
841
448
|
}
|
|
842
|
-
if (
|
|
843
|
-
e = e.substring(
|
|
449
|
+
if (t = this.tokenizer.list(e)) {
|
|
450
|
+
e = e.substring(t.raw.length), r.push(t);
|
|
844
451
|
continue;
|
|
845
452
|
}
|
|
846
|
-
if (
|
|
847
|
-
e = e.substring(
|
|
453
|
+
if (t = this.tokenizer.html(e)) {
|
|
454
|
+
e = e.substring(t.raw.length), r.push(t);
|
|
848
455
|
continue;
|
|
849
456
|
}
|
|
850
|
-
if (
|
|
851
|
-
e = e.substring(
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
`
|
|
855
|
-
` +
|
|
856
|
-
|
|
857
|
-
title: l.title
|
|
858
|
-
});
|
|
457
|
+
if (t = this.tokenizer.def(e)) {
|
|
458
|
+
e = e.substring(t.raw.length);
|
|
459
|
+
let l = r.at(-1);
|
|
460
|
+
l?.type === "paragraph" || l?.type === "text" ? (l.raw += (l.raw.endsWith(`
|
|
461
|
+
`) ? "" : `
|
|
462
|
+
`) + t.raw, l.text += `
|
|
463
|
+
` + t.raw, this.inlineQueue.at(-1).src = l.text) : this.tokens.links[t.tag] || (this.tokens.links[t.tag] = { href: t.href, title: t.title }, r.push(t));
|
|
859
464
|
continue;
|
|
860
465
|
}
|
|
861
|
-
if (
|
|
862
|
-
e = e.substring(
|
|
466
|
+
if (t = this.tokenizer.table(e)) {
|
|
467
|
+
e = e.substring(t.raw.length), r.push(t);
|
|
863
468
|
continue;
|
|
864
469
|
}
|
|
865
|
-
if (
|
|
866
|
-
e = e.substring(
|
|
470
|
+
if (t = this.tokenizer.lheading(e)) {
|
|
471
|
+
e = e.substring(t.raw.length), r.push(t);
|
|
867
472
|
continue;
|
|
868
473
|
}
|
|
869
|
-
let
|
|
870
|
-
if (
|
|
871
|
-
let
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
u = p.call({ lexer: this }, o), typeof u == "number" && u >= 0 && (a = Math.min(a, u));
|
|
876
|
-
}), a < 1 / 0 && a >= 0 && (h = e.substring(0, a + 1));
|
|
474
|
+
let i = e;
|
|
475
|
+
if (this.options.extensions?.startBlock) {
|
|
476
|
+
let l = 1 / 0, c = e.slice(1), a;
|
|
477
|
+
this.options.extensions.startBlock.forEach((h) => {
|
|
478
|
+
a = h.call({ lexer: this }, c), typeof a == "number" && a >= 0 && (l = Math.min(l, a));
|
|
479
|
+
}), l < 1 / 0 && l >= 0 && (i = e.substring(0, l + 1));
|
|
877
480
|
}
|
|
878
|
-
if (this.state.top && (
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
`
|
|
882
|
-
` +
|
|
481
|
+
if (this.state.top && (t = this.tokenizer.paragraph(i))) {
|
|
482
|
+
let l = r.at(-1);
|
|
483
|
+
n && l?.type === "paragraph" ? (l.raw += (l.raw.endsWith(`
|
|
484
|
+
`) ? "" : `
|
|
485
|
+
`) + t.raw, l.text += `
|
|
486
|
+
` + t.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : r.push(t), n = i.length !== e.length, e = e.substring(t.raw.length);
|
|
883
487
|
continue;
|
|
884
488
|
}
|
|
885
|
-
if (
|
|
886
|
-
e = e.substring(
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
`
|
|
890
|
-
` +
|
|
489
|
+
if (t = this.tokenizer.text(e)) {
|
|
490
|
+
e = e.substring(t.raw.length);
|
|
491
|
+
let l = r.at(-1);
|
|
492
|
+
l?.type === "text" ? (l.raw += (l.raw.endsWith(`
|
|
493
|
+
`) ? "" : `
|
|
494
|
+
`) + t.raw, l.text += `
|
|
495
|
+
` + t.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : r.push(t);
|
|
891
496
|
continue;
|
|
892
497
|
}
|
|
893
498
|
if (e) {
|
|
894
|
-
|
|
499
|
+
let l = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
895
500
|
if (this.options.silent) {
|
|
896
|
-
console.error(
|
|
501
|
+
console.error(l);
|
|
897
502
|
break;
|
|
898
|
-
} else
|
|
899
|
-
throw new Error(a);
|
|
503
|
+
} else throw new Error(l);
|
|
900
504
|
}
|
|
901
505
|
}
|
|
902
|
-
return this.state.top = !0,
|
|
506
|
+
return this.state.top = !0, r;
|
|
903
507
|
}
|
|
904
|
-
inline(e,
|
|
905
|
-
return this.inlineQueue.push({ src: e, tokens:
|
|
508
|
+
inline(e, r = []) {
|
|
509
|
+
return this.inlineQueue.push({ src: e, tokens: r }), r;
|
|
906
510
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
*/
|
|
910
|
-
inlineTokens(e, t = []) {
|
|
911
|
-
var l, h, a;
|
|
912
|
-
let r = e, s = null;
|
|
511
|
+
inlineTokens(e, r = []) {
|
|
512
|
+
let n = e, t = null;
|
|
913
513
|
if (this.tokens.links) {
|
|
914
|
-
|
|
915
|
-
if (
|
|
916
|
-
for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(r)) != null; )
|
|
917
|
-
o.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (r = r.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
514
|
+
let a = Object.keys(this.tokens.links);
|
|
515
|
+
if (a.length > 0) for (; (t = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null; ) a.includes(t[0].slice(t[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, t.index) + "[" + "a".repeat(t[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
918
516
|
}
|
|
919
|
-
for (; (
|
|
920
|
-
|
|
921
|
-
for (; (
|
|
922
|
-
|
|
923
|
-
let
|
|
517
|
+
for (; (t = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; ) n = n.slice(0, t.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
518
|
+
let i;
|
|
519
|
+
for (; (t = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; ) i = t[2] ? t[2].length : 0, n = n.slice(0, t.index + i) + "[" + "a".repeat(t[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
520
|
+
n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
521
|
+
let l = !1, c = "";
|
|
924
522
|
for (; e; ) {
|
|
925
|
-
|
|
926
|
-
let
|
|
927
|
-
if (
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
523
|
+
l || (c = ""), l = !1;
|
|
524
|
+
let a;
|
|
525
|
+
if (this.options.extensions?.inline?.some((o) => (a = o.call({ lexer: this }, e, r)) ? (e = e.substring(a.raw.length), r.push(a), !0) : !1)) continue;
|
|
526
|
+
if (a = this.tokenizer.escape(e)) {
|
|
527
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
931
528
|
continue;
|
|
932
529
|
}
|
|
933
|
-
if (
|
|
934
|
-
e = e.substring(
|
|
530
|
+
if (a = this.tokenizer.tag(e)) {
|
|
531
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
935
532
|
continue;
|
|
936
533
|
}
|
|
937
|
-
if (
|
|
938
|
-
e = e.substring(
|
|
534
|
+
if (a = this.tokenizer.link(e)) {
|
|
535
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
939
536
|
continue;
|
|
940
537
|
}
|
|
941
|
-
if (
|
|
942
|
-
e = e.substring(
|
|
943
|
-
|
|
944
|
-
|
|
538
|
+
if (a = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
539
|
+
e = e.substring(a.raw.length);
|
|
540
|
+
let o = r.at(-1);
|
|
541
|
+
a.type === "text" && o?.type === "text" ? (o.raw += a.raw, o.text += a.text) : r.push(a);
|
|
945
542
|
continue;
|
|
946
543
|
}
|
|
947
|
-
if (
|
|
948
|
-
e = e.substring(
|
|
544
|
+
if (a = this.tokenizer.emStrong(e, n, c)) {
|
|
545
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
949
546
|
continue;
|
|
950
547
|
}
|
|
951
|
-
if (
|
|
952
|
-
e = e.substring(
|
|
548
|
+
if (a = this.tokenizer.codespan(e)) {
|
|
549
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
953
550
|
continue;
|
|
954
551
|
}
|
|
955
|
-
if (
|
|
956
|
-
e = e.substring(
|
|
552
|
+
if (a = this.tokenizer.br(e)) {
|
|
553
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
957
554
|
continue;
|
|
958
555
|
}
|
|
959
|
-
if (
|
|
960
|
-
e = e.substring(
|
|
556
|
+
if (a = this.tokenizer.del(e)) {
|
|
557
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
961
558
|
continue;
|
|
962
559
|
}
|
|
963
|
-
if (
|
|
964
|
-
e = e.substring(
|
|
560
|
+
if (a = this.tokenizer.autolink(e)) {
|
|
561
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
965
562
|
continue;
|
|
966
563
|
}
|
|
967
|
-
if (!this.state.inLink && (
|
|
968
|
-
e = e.substring(
|
|
564
|
+
if (!this.state.inLink && (a = this.tokenizer.url(e))) {
|
|
565
|
+
e = e.substring(a.raw.length), r.push(a);
|
|
969
566
|
continue;
|
|
970
567
|
}
|
|
971
|
-
let
|
|
972
|
-
if (
|
|
973
|
-
let
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
d = b.call({ lexer: this }, m), typeof d == "number" && d >= 0 && (p = Math.min(p, d));
|
|
978
|
-
}), p < 1 / 0 && p >= 0 && (u = e.substring(0, p + 1));
|
|
568
|
+
let h = e;
|
|
569
|
+
if (this.options.extensions?.startInline) {
|
|
570
|
+
let o = 1 / 0, p = e.slice(1), u;
|
|
571
|
+
this.options.extensions.startInline.forEach((f) => {
|
|
572
|
+
u = f.call({ lexer: this }, p), typeof u == "number" && u >= 0 && (o = Math.min(o, u));
|
|
573
|
+
}), o < 1 / 0 && o >= 0 && (h = e.substring(0, o + 1));
|
|
979
574
|
}
|
|
980
|
-
if (
|
|
981
|
-
e = e.substring(
|
|
982
|
-
|
|
983
|
-
|
|
575
|
+
if (a = this.tokenizer.inlineText(h)) {
|
|
576
|
+
e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (c = a.raw.slice(-1)), l = !0;
|
|
577
|
+
let o = r.at(-1);
|
|
578
|
+
o?.type === "text" ? (o.raw += a.raw, o.text += a.text) : r.push(a);
|
|
984
579
|
continue;
|
|
985
580
|
}
|
|
986
581
|
if (e) {
|
|
987
|
-
|
|
582
|
+
let o = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
988
583
|
if (this.options.silent) {
|
|
989
|
-
console.error(
|
|
584
|
+
console.error(o);
|
|
990
585
|
break;
|
|
991
|
-
} else
|
|
992
|
-
throw new Error(p);
|
|
586
|
+
} else throw new Error(o);
|
|
993
587
|
}
|
|
994
588
|
}
|
|
995
|
-
return
|
|
589
|
+
return r;
|
|
996
590
|
}
|
|
997
|
-
},
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
this.options = n || S;
|
|
591
|
+
}, q = class {
|
|
592
|
+
options;
|
|
593
|
+
parser;
|
|
594
|
+
constructor(s) {
|
|
595
|
+
this.options = s || S;
|
|
1003
596
|
}
|
|
1004
|
-
space(
|
|
597
|
+
space(s) {
|
|
1005
598
|
return "";
|
|
1006
599
|
}
|
|
1007
|
-
code({ text:
|
|
1008
|
-
|
|
1009
|
-
const r = (i = (e || "").match(w.notSpaceStart)) == null ? void 0 : i[0], s = n.replace(w.endingNewline, "") + `
|
|
600
|
+
code({ text: s, lang: e, escaped: r }) {
|
|
601
|
+
let n = (e || "").match(b.notSpaceStart)?.[0], t = s.replace(b.endingNewline, "") + `
|
|
1010
602
|
`;
|
|
1011
|
-
return
|
|
1012
|
-
` : "<pre><code>" + (
|
|
603
|
+
return n ? '<pre><code class="language-' + R(n) + '">' + (r ? t : R(t, !0)) + `</code></pre>
|
|
604
|
+
` : "<pre><code>" + (r ? t : R(t, !0)) + `</code></pre>
|
|
1013
605
|
`;
|
|
1014
606
|
}
|
|
1015
|
-
blockquote({ tokens:
|
|
607
|
+
blockquote({ tokens: s }) {
|
|
1016
608
|
return `<blockquote>
|
|
1017
|
-
${this.parser.parse(
|
|
609
|
+
${this.parser.parse(s)}</blockquote>
|
|
1018
610
|
`;
|
|
1019
611
|
}
|
|
1020
|
-
html({ text:
|
|
1021
|
-
return
|
|
612
|
+
html({ text: s }) {
|
|
613
|
+
return s;
|
|
614
|
+
}
|
|
615
|
+
def(s) {
|
|
616
|
+
return "";
|
|
1022
617
|
}
|
|
1023
|
-
heading({ tokens:
|
|
1024
|
-
return `<h${e}>${this.parser.parseInline(
|
|
618
|
+
heading({ tokens: s, depth: e }) {
|
|
619
|
+
return `<h${e}>${this.parser.parseInline(s)}</h${e}>
|
|
1025
620
|
`;
|
|
1026
621
|
}
|
|
1027
|
-
hr(
|
|
622
|
+
hr(s) {
|
|
1028
623
|
return `<hr>
|
|
1029
624
|
`;
|
|
1030
625
|
}
|
|
1031
|
-
list(
|
|
1032
|
-
|
|
1033
|
-
let
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
r += this.listitem(l);
|
|
626
|
+
list(s) {
|
|
627
|
+
let e = s.ordered, r = s.start, n = "";
|
|
628
|
+
for (let l = 0; l < s.items.length; l++) {
|
|
629
|
+
let c = s.items[l];
|
|
630
|
+
n += this.listitem(c);
|
|
1037
631
|
}
|
|
1038
|
-
|
|
1039
|
-
return "<" +
|
|
1040
|
-
` +
|
|
632
|
+
let t = e ? "ol" : "ul", i = e && r !== 1 ? ' start="' + r + '"' : "";
|
|
633
|
+
return "<" + t + i + `>
|
|
634
|
+
` + n + "</" + t + `>
|
|
1041
635
|
`;
|
|
1042
636
|
}
|
|
1043
|
-
listitem(
|
|
1044
|
-
|
|
1045
|
-
let e = "";
|
|
1046
|
-
if (n.task) {
|
|
1047
|
-
const r = this.checkbox({ checked: !!n.checked });
|
|
1048
|
-
n.loose ? ((t = n.tokens[0]) == null ? void 0 : t.type) === "paragraph" ? (n.tokens[0].text = r + " " + n.tokens[0].text, n.tokens[0].tokens && n.tokens[0].tokens.length > 0 && n.tokens[0].tokens[0].type === "text" && (n.tokens[0].tokens[0].text = r + " " + y(n.tokens[0].tokens[0].text), n.tokens[0].tokens[0].escaped = !0)) : n.tokens.unshift({
|
|
1049
|
-
type: "text",
|
|
1050
|
-
raw: r + " ",
|
|
1051
|
-
text: r + " ",
|
|
1052
|
-
escaped: !0
|
|
1053
|
-
}) : e += r + " ";
|
|
1054
|
-
}
|
|
1055
|
-
return e += this.parser.parse(n.tokens, !!n.loose), `<li>${e}</li>
|
|
637
|
+
listitem(s) {
|
|
638
|
+
return `<li>${this.parser.parse(s.tokens)}</li>
|
|
1056
639
|
`;
|
|
1057
640
|
}
|
|
1058
|
-
checkbox({ checked:
|
|
1059
|
-
return "<input " + (
|
|
641
|
+
checkbox({ checked: s }) {
|
|
642
|
+
return "<input " + (s ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
1060
643
|
}
|
|
1061
|
-
paragraph({ tokens:
|
|
1062
|
-
return `<p>${this.parser.parseInline(
|
|
644
|
+
paragraph({ tokens: s }) {
|
|
645
|
+
return `<p>${this.parser.parseInline(s)}</p>
|
|
1063
646
|
`;
|
|
1064
647
|
}
|
|
1065
|
-
table(
|
|
1066
|
-
let e = "",
|
|
1067
|
-
for (let
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
let
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
t += this.tablecell(i[c]);
|
|
1076
|
-
r += this.tablerow({ text: t });
|
|
648
|
+
table(s) {
|
|
649
|
+
let e = "", r = "";
|
|
650
|
+
for (let t = 0; t < s.header.length; t++) r += this.tablecell(s.header[t]);
|
|
651
|
+
e += this.tablerow({ text: r });
|
|
652
|
+
let n = "";
|
|
653
|
+
for (let t = 0; t < s.rows.length; t++) {
|
|
654
|
+
let i = s.rows[t];
|
|
655
|
+
r = "";
|
|
656
|
+
for (let l = 0; l < i.length; l++) r += this.tablecell(i[l]);
|
|
657
|
+
n += this.tablerow({ text: r });
|
|
1077
658
|
}
|
|
1078
|
-
return
|
|
659
|
+
return n && (n = `<tbody>${n}</tbody>`), `<table>
|
|
1079
660
|
<thead>
|
|
1080
661
|
` + e + `</thead>
|
|
1081
|
-
` +
|
|
662
|
+
` + n + `</table>
|
|
1082
663
|
`;
|
|
1083
664
|
}
|
|
1084
|
-
tablerow({ text:
|
|
665
|
+
tablerow({ text: s }) {
|
|
1085
666
|
return `<tr>
|
|
1086
|
-
${
|
|
667
|
+
${s}</tr>
|
|
1087
668
|
`;
|
|
1088
669
|
}
|
|
1089
|
-
tablecell(
|
|
1090
|
-
|
|
1091
|
-
return (
|
|
670
|
+
tablecell(s) {
|
|
671
|
+
let e = this.parser.parseInline(s.tokens), r = s.header ? "th" : "td";
|
|
672
|
+
return (s.align ? `<${r} align="${s.align}">` : `<${r}>`) + e + `</${r}>
|
|
1092
673
|
`;
|
|
1093
674
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
*/
|
|
1097
|
-
strong({ tokens: n }) {
|
|
1098
|
-
return `<strong>${this.parser.parseInline(n)}</strong>`;
|
|
675
|
+
strong({ tokens: s }) {
|
|
676
|
+
return `<strong>${this.parser.parseInline(s)}</strong>`;
|
|
1099
677
|
}
|
|
1100
|
-
em({ tokens:
|
|
1101
|
-
return `<em>${this.parser.parseInline(
|
|
678
|
+
em({ tokens: s }) {
|
|
679
|
+
return `<em>${this.parser.parseInline(s)}</em>`;
|
|
1102
680
|
}
|
|
1103
|
-
codespan({ text:
|
|
1104
|
-
return `<code>${
|
|
681
|
+
codespan({ text: s }) {
|
|
682
|
+
return `<code>${R(s, !0)}</code>`;
|
|
1105
683
|
}
|
|
1106
|
-
br(
|
|
684
|
+
br(s) {
|
|
1107
685
|
return "<br>";
|
|
1108
686
|
}
|
|
1109
|
-
del({ tokens:
|
|
1110
|
-
return `<del>${this.parser.parseInline(
|
|
1111
|
-
}
|
|
1112
|
-
link({ href: n, title: e, tokens: t }) {
|
|
1113
|
-
const r = this.parser.parseInline(t), s = ce(n);
|
|
1114
|
-
if (s === null)
|
|
1115
|
-
return r;
|
|
1116
|
-
n = s;
|
|
1117
|
-
let i = '<a href="' + n + '"';
|
|
1118
|
-
return e && (i += ' title="' + y(e) + '"'), i += ">" + r + "</a>", i;
|
|
1119
|
-
}
|
|
1120
|
-
image({ href: n, title: e, text: t, tokens: r }) {
|
|
1121
|
-
r && (t = this.parser.parseInline(r, this.parser.textRenderer));
|
|
1122
|
-
const s = ce(n);
|
|
1123
|
-
if (s === null)
|
|
1124
|
-
return y(t);
|
|
1125
|
-
n = s;
|
|
1126
|
-
let i = `<img src="${n}" alt="${t}"`;
|
|
1127
|
-
return e && (i += ` title="${y(e)}"`), i += ">", i;
|
|
1128
|
-
}
|
|
1129
|
-
text(n) {
|
|
1130
|
-
return "tokens" in n && n.tokens ? this.parser.parseInline(n.tokens) : "escaped" in n && n.escaped ? n.text : y(n.text);
|
|
1131
|
-
}
|
|
1132
|
-
}, te = class {
|
|
1133
|
-
// no need for block level renderers
|
|
1134
|
-
strong({ text: n }) {
|
|
1135
|
-
return n;
|
|
687
|
+
del({ tokens: s }) {
|
|
688
|
+
return `<del>${this.parser.parseInline(s)}</del>`;
|
|
1136
689
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
690
|
+
link({ href: s, title: e, tokens: r }) {
|
|
691
|
+
let n = this.parser.parseInline(r), t = ie(s);
|
|
692
|
+
if (t === null) return n;
|
|
693
|
+
s = t;
|
|
694
|
+
let i = '<a href="' + s + '"';
|
|
695
|
+
return e && (i += ' title="' + R(e) + '"'), i += ">" + n + "</a>", i;
|
|
1139
696
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
697
|
+
image({ href: s, title: e, text: r, tokens: n }) {
|
|
698
|
+
n && (r = this.parser.parseInline(n, this.parser.textRenderer));
|
|
699
|
+
let t = ie(s);
|
|
700
|
+
if (t === null) return R(r);
|
|
701
|
+
s = t;
|
|
702
|
+
let i = `<img src="${s}" alt="${r}"`;
|
|
703
|
+
return e && (i += ` title="${R(e)}"`), i += ">", i;
|
|
1142
704
|
}
|
|
1143
|
-
|
|
1144
|
-
return
|
|
705
|
+
text(s) {
|
|
706
|
+
return "tokens" in s && s.tokens ? this.parser.parseInline(s.tokens) : "escaped" in s && s.escaped ? s.text : R(s.text);
|
|
1145
707
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
708
|
+
}, K = class {
|
|
709
|
+
strong({ text: s }) {
|
|
710
|
+
return s;
|
|
1148
711
|
}
|
|
1149
|
-
|
|
1150
|
-
return
|
|
712
|
+
em({ text: s }) {
|
|
713
|
+
return s;
|
|
714
|
+
}
|
|
715
|
+
codespan({ text: s }) {
|
|
716
|
+
return s;
|
|
1151
717
|
}
|
|
1152
|
-
|
|
1153
|
-
return
|
|
718
|
+
del({ text: s }) {
|
|
719
|
+
return s;
|
|
1154
720
|
}
|
|
1155
|
-
|
|
1156
|
-
return
|
|
721
|
+
html({ text: s }) {
|
|
722
|
+
return s;
|
|
723
|
+
}
|
|
724
|
+
text({ text: s }) {
|
|
725
|
+
return s;
|
|
726
|
+
}
|
|
727
|
+
link({ text: s }) {
|
|
728
|
+
return "" + s;
|
|
729
|
+
}
|
|
730
|
+
image({ text: s }) {
|
|
731
|
+
return "" + s;
|
|
1157
732
|
}
|
|
1158
733
|
br() {
|
|
1159
734
|
return "";
|
|
1160
735
|
}
|
|
1161
|
-
|
|
736
|
+
checkbox({ raw: s }) {
|
|
737
|
+
return s;
|
|
738
|
+
}
|
|
739
|
+
}, y = class j {
|
|
740
|
+
options;
|
|
741
|
+
renderer;
|
|
742
|
+
textRenderer;
|
|
1162
743
|
constructor(e) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
return new U(t).parse(e);
|
|
1173
|
-
}
|
|
1174
|
-
/**
|
|
1175
|
-
* Static Parse Inline Method
|
|
1176
|
-
*/
|
|
1177
|
-
static parseInline(e, t) {
|
|
1178
|
-
return new U(t).parseInline(e);
|
|
1179
|
-
}
|
|
1180
|
-
/**
|
|
1181
|
-
* Parse Loop
|
|
1182
|
-
*/
|
|
1183
|
-
parse(e, t = !0) {
|
|
1184
|
-
var s, i;
|
|
744
|
+
this.options = e || S, this.options.renderer = this.options.renderer || new q(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new K();
|
|
745
|
+
}
|
|
746
|
+
static parse(e, r) {
|
|
747
|
+
return new j(r).parse(e);
|
|
748
|
+
}
|
|
749
|
+
static parseInline(e, r) {
|
|
750
|
+
return new j(r).parseInline(e);
|
|
751
|
+
}
|
|
752
|
+
parse(e) {
|
|
1185
753
|
let r = "";
|
|
1186
|
-
for (let
|
|
1187
|
-
|
|
1188
|
-
if (
|
|
1189
|
-
|
|
1190
|
-
if (
|
|
1191
|
-
r +=
|
|
754
|
+
for (let n = 0; n < e.length; n++) {
|
|
755
|
+
let t = e[n];
|
|
756
|
+
if (this.options.extensions?.renderers?.[t.type]) {
|
|
757
|
+
let l = t, c = this.options.extensions.renderers[l.type].call({ parser: this }, l);
|
|
758
|
+
if (c !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(l.type)) {
|
|
759
|
+
r += c || "";
|
|
1192
760
|
continue;
|
|
1193
761
|
}
|
|
1194
762
|
}
|
|
1195
|
-
|
|
1196
|
-
switch (
|
|
763
|
+
let i = t;
|
|
764
|
+
switch (i.type) {
|
|
1197
765
|
case "space": {
|
|
1198
|
-
r += this.renderer.space(
|
|
1199
|
-
|
|
766
|
+
r += this.renderer.space(i);
|
|
767
|
+
break;
|
|
1200
768
|
}
|
|
1201
769
|
case "hr": {
|
|
1202
|
-
r += this.renderer.hr(
|
|
1203
|
-
|
|
770
|
+
r += this.renderer.hr(i);
|
|
771
|
+
break;
|
|
1204
772
|
}
|
|
1205
773
|
case "heading": {
|
|
1206
|
-
r += this.renderer.heading(
|
|
1207
|
-
|
|
774
|
+
r += this.renderer.heading(i);
|
|
775
|
+
break;
|
|
1208
776
|
}
|
|
1209
777
|
case "code": {
|
|
1210
|
-
r += this.renderer.code(
|
|
1211
|
-
|
|
778
|
+
r += this.renderer.code(i);
|
|
779
|
+
break;
|
|
1212
780
|
}
|
|
1213
781
|
case "table": {
|
|
1214
|
-
r += this.renderer.table(
|
|
1215
|
-
|
|
782
|
+
r += this.renderer.table(i);
|
|
783
|
+
break;
|
|
1216
784
|
}
|
|
1217
785
|
case "blockquote": {
|
|
1218
|
-
r += this.renderer.blockquote(
|
|
1219
|
-
|
|
786
|
+
r += this.renderer.blockquote(i);
|
|
787
|
+
break;
|
|
1220
788
|
}
|
|
1221
789
|
case "list": {
|
|
1222
|
-
r += this.renderer.list(
|
|
1223
|
-
|
|
790
|
+
r += this.renderer.list(i);
|
|
791
|
+
break;
|
|
792
|
+
}
|
|
793
|
+
case "checkbox": {
|
|
794
|
+
r += this.renderer.checkbox(i);
|
|
795
|
+
break;
|
|
1224
796
|
}
|
|
1225
797
|
case "html": {
|
|
1226
|
-
r += this.renderer.html(
|
|
1227
|
-
|
|
798
|
+
r += this.renderer.html(i);
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
801
|
+
case "def": {
|
|
802
|
+
r += this.renderer.def(i);
|
|
803
|
+
break;
|
|
1228
804
|
}
|
|
1229
805
|
case "paragraph": {
|
|
1230
|
-
r += this.renderer.paragraph(
|
|
1231
|
-
|
|
806
|
+
r += this.renderer.paragraph(i);
|
|
807
|
+
break;
|
|
1232
808
|
}
|
|
1233
809
|
case "text": {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
a = e[++c], o += `
|
|
1237
|
-
` + this.renderer.text(a);
|
|
1238
|
-
t ? r += this.renderer.paragraph({
|
|
1239
|
-
type: "paragraph",
|
|
1240
|
-
raw: o,
|
|
1241
|
-
text: o,
|
|
1242
|
-
tokens: [{ type: "text", raw: o, text: o, escaped: !0 }]
|
|
1243
|
-
}) : r += o;
|
|
1244
|
-
continue;
|
|
810
|
+
r += this.renderer.text(i);
|
|
811
|
+
break;
|
|
1245
812
|
}
|
|
1246
813
|
default: {
|
|
1247
|
-
|
|
1248
|
-
if (this.options.silent)
|
|
1249
|
-
|
|
1250
|
-
throw new Error(a);
|
|
814
|
+
let l = 'Token with "' + i.type + '" type was not found.';
|
|
815
|
+
if (this.options.silent) return console.error(l), "";
|
|
816
|
+
throw new Error(l);
|
|
1251
817
|
}
|
|
1252
818
|
}
|
|
1253
819
|
}
|
|
1254
820
|
return r;
|
|
1255
821
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
if ((i = (s = this.options.extensions) == null ? void 0 : s.renderers) != null && i[l.type]) {
|
|
1265
|
-
const a = this.options.extensions.renderers[l.type].call({ parser: this }, l);
|
|
1266
|
-
if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(l.type)) {
|
|
1267
|
-
r += a || "";
|
|
822
|
+
parseInline(e, r = this.renderer) {
|
|
823
|
+
let n = "";
|
|
824
|
+
for (let t = 0; t < e.length; t++) {
|
|
825
|
+
let i = e[t];
|
|
826
|
+
if (this.options.extensions?.renderers?.[i.type]) {
|
|
827
|
+
let c = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
828
|
+
if (c !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
|
|
829
|
+
n += c || "";
|
|
1268
830
|
continue;
|
|
1269
831
|
}
|
|
1270
832
|
}
|
|
1271
|
-
|
|
1272
|
-
switch (
|
|
833
|
+
let l = i;
|
|
834
|
+
switch (l.type) {
|
|
1273
835
|
case "escape": {
|
|
1274
|
-
|
|
836
|
+
n += r.text(l);
|
|
1275
837
|
break;
|
|
1276
838
|
}
|
|
1277
839
|
case "html": {
|
|
1278
|
-
|
|
840
|
+
n += r.html(l);
|
|
1279
841
|
break;
|
|
1280
842
|
}
|
|
1281
843
|
case "link": {
|
|
1282
|
-
|
|
844
|
+
n += r.link(l);
|
|
1283
845
|
break;
|
|
1284
846
|
}
|
|
1285
847
|
case "image": {
|
|
1286
|
-
|
|
848
|
+
n += r.image(l);
|
|
849
|
+
break;
|
|
850
|
+
}
|
|
851
|
+
case "checkbox": {
|
|
852
|
+
n += r.checkbox(l);
|
|
1287
853
|
break;
|
|
1288
854
|
}
|
|
1289
855
|
case "strong": {
|
|
1290
|
-
|
|
856
|
+
n += r.strong(l);
|
|
1291
857
|
break;
|
|
1292
858
|
}
|
|
1293
859
|
case "em": {
|
|
1294
|
-
|
|
860
|
+
n += r.em(l);
|
|
1295
861
|
break;
|
|
1296
862
|
}
|
|
1297
863
|
case "codespan": {
|
|
1298
|
-
|
|
864
|
+
n += r.codespan(l);
|
|
1299
865
|
break;
|
|
1300
866
|
}
|
|
1301
867
|
case "br": {
|
|
1302
|
-
|
|
868
|
+
n += r.br(l);
|
|
1303
869
|
break;
|
|
1304
870
|
}
|
|
1305
871
|
case "del": {
|
|
1306
|
-
|
|
872
|
+
n += r.del(l);
|
|
1307
873
|
break;
|
|
1308
874
|
}
|
|
1309
875
|
case "text": {
|
|
1310
|
-
|
|
876
|
+
n += r.text(l);
|
|
1311
877
|
break;
|
|
1312
878
|
}
|
|
1313
879
|
default: {
|
|
1314
|
-
|
|
1315
|
-
if (this.options.silent)
|
|
1316
|
-
|
|
1317
|
-
throw new Error(a);
|
|
880
|
+
let c = 'Token with "' + l.type + '" type was not found.';
|
|
881
|
+
if (this.options.silent) return console.error(c), "";
|
|
882
|
+
throw new Error(c);
|
|
1318
883
|
}
|
|
1319
884
|
}
|
|
1320
885
|
}
|
|
1321
|
-
return
|
|
886
|
+
return n;
|
|
1322
887
|
}
|
|
1323
|
-
},
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
this.options =
|
|
888
|
+
}, A = class {
|
|
889
|
+
options;
|
|
890
|
+
block;
|
|
891
|
+
constructor(s) {
|
|
892
|
+
this.options = s || S;
|
|
1328
893
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
return n;
|
|
894
|
+
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
895
|
+
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
896
|
+
preprocess(s) {
|
|
897
|
+
return s;
|
|
1334
898
|
}
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
*/
|
|
1338
|
-
postprocess(n) {
|
|
1339
|
-
return n;
|
|
899
|
+
postprocess(s) {
|
|
900
|
+
return s;
|
|
1340
901
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
return
|
|
902
|
+
processAllTokens(s) {
|
|
903
|
+
return s;
|
|
904
|
+
}
|
|
905
|
+
emStrongMask(s) {
|
|
906
|
+
return s;
|
|
1346
907
|
}
|
|
1347
|
-
/**
|
|
1348
|
-
* Provide function to tokenize markdown
|
|
1349
|
-
*/
|
|
1350
908
|
provideLexer() {
|
|
1351
|
-
return this.block ?
|
|
909
|
+
return this.block ? w.lex : w.lexInline;
|
|
1352
910
|
}
|
|
1353
|
-
/**
|
|
1354
|
-
* Provide function to parse tokens
|
|
1355
|
-
*/
|
|
1356
911
|
provideParser() {
|
|
1357
|
-
return this.block ?
|
|
1358
|
-
}
|
|
1359
|
-
},
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
const c = i;
|
|
1387
|
-
for (const l of c.header)
|
|
1388
|
-
t = t.concat(this.walkTokens(l.tokens, e));
|
|
1389
|
-
for (const l of c.rows)
|
|
1390
|
-
for (const h of l)
|
|
1391
|
-
t = t.concat(this.walkTokens(h.tokens, e));
|
|
1392
|
-
break;
|
|
1393
|
-
}
|
|
1394
|
-
case "list": {
|
|
1395
|
-
const c = i;
|
|
1396
|
-
t = t.concat(this.walkTokens(c.items, e));
|
|
1397
|
-
break;
|
|
1398
|
-
}
|
|
1399
|
-
default: {
|
|
1400
|
-
const c = i;
|
|
1401
|
-
(s = (r = this.defaults.extensions) == null ? void 0 : r.childTokens) != null && s[c.type] ? this.defaults.extensions.childTokens[c.type].forEach((l) => {
|
|
1402
|
-
const h = c[l].flat(1 / 0);
|
|
1403
|
-
t = t.concat(this.walkTokens(h, e));
|
|
1404
|
-
}) : c.tokens && (t = t.concat(this.walkTokens(c.tokens, e)));
|
|
1405
|
-
}
|
|
912
|
+
return this.block ? y.parse : y.parseInline;
|
|
913
|
+
}
|
|
914
|
+
}, gt = class {
|
|
915
|
+
defaults = H();
|
|
916
|
+
options = this.setOptions;
|
|
917
|
+
parse = this.parseMarkdown(!0);
|
|
918
|
+
parseInline = this.parseMarkdown(!1);
|
|
919
|
+
Parser = y;
|
|
920
|
+
Renderer = q;
|
|
921
|
+
TextRenderer = K;
|
|
922
|
+
Lexer = w;
|
|
923
|
+
Tokenizer = B;
|
|
924
|
+
Hooks = A;
|
|
925
|
+
constructor(...s) {
|
|
926
|
+
this.use(...s);
|
|
927
|
+
}
|
|
928
|
+
walkTokens(s, e) {
|
|
929
|
+
let r = [];
|
|
930
|
+
for (let n of s) switch (r = r.concat(e.call(this, n)), n.type) {
|
|
931
|
+
case "table": {
|
|
932
|
+
let t = n;
|
|
933
|
+
for (let i of t.header) r = r.concat(this.walkTokens(i.tokens, e));
|
|
934
|
+
for (let i of t.rows) for (let l of i) r = r.concat(this.walkTokens(l.tokens, e));
|
|
935
|
+
break;
|
|
936
|
+
}
|
|
937
|
+
case "list": {
|
|
938
|
+
let t = n;
|
|
939
|
+
r = r.concat(this.walkTokens(t.items, e));
|
|
940
|
+
break;
|
|
1406
941
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
942
|
+
default: {
|
|
943
|
+
let t = n;
|
|
944
|
+
this.defaults.extensions?.childTokens?.[t.type] ? this.defaults.extensions.childTokens[t.type].forEach((i) => {
|
|
945
|
+
let l = t[i].flat(1 / 0);
|
|
946
|
+
r = r.concat(this.walkTokens(l, e));
|
|
947
|
+
}) : t.tokens && (r = r.concat(this.walkTokens(t.tokens, e)));
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return r;
|
|
951
|
+
}
|
|
952
|
+
use(...s) {
|
|
953
|
+
let e = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
954
|
+
return s.forEach((r) => {
|
|
955
|
+
let n = { ...r };
|
|
956
|
+
if (n.async = this.defaults.async || n.async || !1, r.extensions && (r.extensions.forEach((t) => {
|
|
957
|
+
if (!t.name) throw new Error("extension name required");
|
|
958
|
+
if ("renderer" in t) {
|
|
959
|
+
let i = e.renderers[t.name];
|
|
960
|
+
i ? e.renderers[t.name] = function(...l) {
|
|
961
|
+
let c = t.renderer.apply(this, l);
|
|
962
|
+
return c === !1 && (c = i.apply(this, l)), c;
|
|
963
|
+
} : e.renderers[t.name] = t.renderer;
|
|
1422
964
|
}
|
|
1423
|
-
if ("tokenizer" in
|
|
1424
|
-
if (!
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
i ? i.unshift(s.tokenizer) : e[s.level] = [s.tokenizer], s.start && (s.level === "block" ? e.startBlock ? e.startBlock.push(s.start) : e.startBlock = [s.start] : s.level === "inline" && (e.startInline ? e.startInline.push(s.start) : e.startInline = [s.start]));
|
|
965
|
+
if ("tokenizer" in t) {
|
|
966
|
+
if (!t.level || t.level !== "block" && t.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
967
|
+
let i = e[t.level];
|
|
968
|
+
i ? i.unshift(t.tokenizer) : e[t.level] = [t.tokenizer], t.start && (t.level === "block" ? e.startBlock ? e.startBlock.push(t.start) : e.startBlock = [t.start] : t.level === "inline" && (e.startInline ? e.startInline.push(t.start) : e.startInline = [t.start]));
|
|
1428
969
|
}
|
|
1429
|
-
"childTokens" in
|
|
1430
|
-
}),
|
|
1431
|
-
|
|
1432
|
-
for (
|
|
1433
|
-
if (!(i in
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
let o = l.apply(s, a);
|
|
1440
|
-
return o === !1 && (o = h.apply(s, a)), o || "";
|
|
970
|
+
"childTokens" in t && t.childTokens && (e.childTokens[t.name] = t.childTokens);
|
|
971
|
+
}), n.extensions = e), r.renderer) {
|
|
972
|
+
let t = this.defaults.renderer || new q(this.defaults);
|
|
973
|
+
for (let i in r.renderer) {
|
|
974
|
+
if (!(i in t)) throw new Error(`renderer '${i}' does not exist`);
|
|
975
|
+
if (["options", "parser"].includes(i)) continue;
|
|
976
|
+
let l = i, c = r.renderer[l], a = t[l];
|
|
977
|
+
t[l] = (...h) => {
|
|
978
|
+
let o = c.apply(t, h);
|
|
979
|
+
return o === !1 && (o = a.apply(t, h)), o || "";
|
|
1441
980
|
};
|
|
1442
981
|
}
|
|
1443
|
-
|
|
982
|
+
n.renderer = t;
|
|
1444
983
|
}
|
|
1445
|
-
if (
|
|
1446
|
-
|
|
1447
|
-
for (
|
|
1448
|
-
if (!(i in
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
let o = l.apply(s, a);
|
|
1455
|
-
return o === !1 && (o = h.apply(s, a)), o;
|
|
984
|
+
if (r.tokenizer) {
|
|
985
|
+
let t = this.defaults.tokenizer || new B(this.defaults);
|
|
986
|
+
for (let i in r.tokenizer) {
|
|
987
|
+
if (!(i in t)) throw new Error(`tokenizer '${i}' does not exist`);
|
|
988
|
+
if (["options", "rules", "lexer"].includes(i)) continue;
|
|
989
|
+
let l = i, c = r.tokenizer[l], a = t[l];
|
|
990
|
+
t[l] = (...h) => {
|
|
991
|
+
let o = c.apply(t, h);
|
|
992
|
+
return o === !1 && (o = a.apply(t, h)), o;
|
|
1456
993
|
};
|
|
1457
994
|
}
|
|
1458
|
-
|
|
995
|
+
n.tokenizer = t;
|
|
1459
996
|
}
|
|
1460
|
-
if (
|
|
1461
|
-
|
|
1462
|
-
for (
|
|
1463
|
-
if (!(i in
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
return
|
|
1473
|
-
} :
|
|
1474
|
-
|
|
1475
|
-
|
|
997
|
+
if (r.hooks) {
|
|
998
|
+
let t = this.defaults.hooks || new A();
|
|
999
|
+
for (let i in r.hooks) {
|
|
1000
|
+
if (!(i in t)) throw new Error(`hook '${i}' does not exist`);
|
|
1001
|
+
if (["options", "block"].includes(i)) continue;
|
|
1002
|
+
let l = i, c = r.hooks[l], a = t[l];
|
|
1003
|
+
A.passThroughHooks.has(i) ? t[l] = (h) => {
|
|
1004
|
+
if (this.defaults.async && A.passThroughHooksRespectAsync.has(i)) return (async () => {
|
|
1005
|
+
let p = await c.call(t, h);
|
|
1006
|
+
return a.call(t, p);
|
|
1007
|
+
})();
|
|
1008
|
+
let o = c.call(t, h);
|
|
1009
|
+
return a.call(t, o);
|
|
1010
|
+
} : t[l] = (...h) => {
|
|
1011
|
+
if (this.defaults.async) return (async () => {
|
|
1012
|
+
let p = await c.apply(t, h);
|
|
1013
|
+
return p === !1 && (p = await a.apply(t, h)), p;
|
|
1014
|
+
})();
|
|
1015
|
+
let o = c.apply(t, h);
|
|
1016
|
+
return o === !1 && (o = a.apply(t, h)), o;
|
|
1476
1017
|
};
|
|
1477
1018
|
}
|
|
1478
|
-
|
|
1019
|
+
n.hooks = t;
|
|
1479
1020
|
}
|
|
1480
|
-
if (
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
let
|
|
1484
|
-
return
|
|
1021
|
+
if (r.walkTokens) {
|
|
1022
|
+
let t = this.defaults.walkTokens, i = r.walkTokens;
|
|
1023
|
+
n.walkTokens = function(l) {
|
|
1024
|
+
let c = [];
|
|
1025
|
+
return c.push(i.call(this, l)), t && (c = c.concat(t.call(this, l))), c;
|
|
1485
1026
|
};
|
|
1486
1027
|
}
|
|
1487
|
-
this.defaults = { ...this.defaults, ...
|
|
1028
|
+
this.defaults = { ...this.defaults, ...n };
|
|
1488
1029
|
}), this;
|
|
1489
1030
|
}
|
|
1490
|
-
setOptions(
|
|
1491
|
-
return this.defaults = { ...this.defaults, ...
|
|
1492
|
-
}
|
|
1493
|
-
lexer(
|
|
1494
|
-
return
|
|
1495
|
-
}
|
|
1496
|
-
parser(
|
|
1497
|
-
return
|
|
1498
|
-
}
|
|
1499
|
-
parseMarkdown(
|
|
1500
|
-
return (
|
|
1501
|
-
|
|
1502
|
-
if (this.defaults.async === !0 &&
|
|
1503
|
-
|
|
1504
|
-
if (typeof
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
return Promise.resolve(i.hooks ? i.hooks.preprocess(t) : t).then((a) => l(a, i)).then((a) => i.hooks ? i.hooks.processAllTokens(a) : a).then((a) => i.walkTokens ? Promise.all(this.walkTokens(a, i.walkTokens)).then(() => a) : a).then((a) => h(a, i)).then((a) => i.hooks ? i.hooks.postprocess(a) : a).catch(c);
|
|
1031
|
+
setOptions(s) {
|
|
1032
|
+
return this.defaults = { ...this.defaults, ...s }, this;
|
|
1033
|
+
}
|
|
1034
|
+
lexer(s, e) {
|
|
1035
|
+
return w.lex(s, e ?? this.defaults);
|
|
1036
|
+
}
|
|
1037
|
+
parser(s, e) {
|
|
1038
|
+
return y.parse(s, e ?? this.defaults);
|
|
1039
|
+
}
|
|
1040
|
+
parseMarkdown(s) {
|
|
1041
|
+
return (e, r) => {
|
|
1042
|
+
let n = { ...r }, t = { ...this.defaults, ...n }, i = this.onError(!!t.silent, !!t.async);
|
|
1043
|
+
if (this.defaults.async === !0 && n.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."));
|
|
1044
|
+
if (typeof e > "u" || e === null) return i(new Error("marked(): input parameter is undefined or null"));
|
|
1045
|
+
if (typeof e != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
|
|
1046
|
+
if (t.hooks && (t.hooks.options = t, t.hooks.block = s), t.async) return (async () => {
|
|
1047
|
+
let l = t.hooks ? await t.hooks.preprocess(e) : e, c = await (t.hooks ? await t.hooks.provideLexer() : s ? w.lex : w.lexInline)(l, t), a = t.hooks ? await t.hooks.processAllTokens(c) : c;
|
|
1048
|
+
t.walkTokens && await Promise.all(this.walkTokens(a, t.walkTokens));
|
|
1049
|
+
let h = await (t.hooks ? await t.hooks.provideParser() : s ? y.parse : y.parseInline)(a, t);
|
|
1050
|
+
return t.hooks ? await t.hooks.postprocess(h) : h;
|
|
1051
|
+
})().catch(i);
|
|
1512
1052
|
try {
|
|
1513
|
-
|
|
1514
|
-
let
|
|
1515
|
-
|
|
1516
|
-
let
|
|
1517
|
-
return
|
|
1518
|
-
} catch (
|
|
1519
|
-
return
|
|
1053
|
+
t.hooks && (e = t.hooks.preprocess(e));
|
|
1054
|
+
let l = (t.hooks ? t.hooks.provideLexer() : s ? w.lex : w.lexInline)(e, t);
|
|
1055
|
+
t.hooks && (l = t.hooks.processAllTokens(l)), t.walkTokens && this.walkTokens(l, t.walkTokens);
|
|
1056
|
+
let c = (t.hooks ? t.hooks.provideParser() : s ? y.parse : y.parseInline)(l, t);
|
|
1057
|
+
return t.hooks && (c = t.hooks.postprocess(c)), c;
|
|
1058
|
+
} catch (l) {
|
|
1059
|
+
return i(l);
|
|
1520
1060
|
}
|
|
1521
1061
|
};
|
|
1522
1062
|
}
|
|
1523
|
-
onError(
|
|
1524
|
-
return (
|
|
1525
|
-
if (
|
|
1526
|
-
Please report this to https://github.com/markedjs/marked.`,
|
|
1527
|
-
|
|
1528
|
-
return e ? Promise.resolve(
|
|
1063
|
+
onError(s, e) {
|
|
1064
|
+
return (r) => {
|
|
1065
|
+
if (r.message += `
|
|
1066
|
+
Please report this to https://github.com/markedjs/marked.`, s) {
|
|
1067
|
+
let n = "<p>An error occurred:</p><pre>" + R(r.message + "", !0) + "</pre>";
|
|
1068
|
+
return e ? Promise.resolve(n) : n;
|
|
1529
1069
|
}
|
|
1530
|
-
if (e)
|
|
1531
|
-
|
|
1532
|
-
throw t;
|
|
1070
|
+
if (e) return Promise.reject(r);
|
|
1071
|
+
throw r;
|
|
1533
1072
|
};
|
|
1534
1073
|
}
|
|
1535
|
-
}, $ = new
|
|
1536
|
-
function
|
|
1537
|
-
return $.parse(
|
|
1074
|
+
}, $ = new gt();
|
|
1075
|
+
function g(s, e) {
|
|
1076
|
+
return $.parse(s, e);
|
|
1538
1077
|
}
|
|
1539
|
-
|
|
1540
|
-
return $.setOptions(
|
|
1078
|
+
g.options = g.setOptions = function(s) {
|
|
1079
|
+
return $.setOptions(s), g.defaults = $.defaults, ue(g.defaults), g;
|
|
1541
1080
|
};
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
return $.use(...
|
|
1081
|
+
g.getDefaults = H;
|
|
1082
|
+
g.defaults = S;
|
|
1083
|
+
g.use = function(...s) {
|
|
1084
|
+
return $.use(...s), g.defaults = $.defaults, ue(g.defaults), g;
|
|
1546
1085
|
};
|
|
1547
|
-
|
|
1548
|
-
return $.walkTokens(
|
|
1086
|
+
g.walkTokens = function(s, e) {
|
|
1087
|
+
return $.walkTokens(s, e);
|
|
1549
1088
|
};
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
const
|
|
1089
|
+
g.parseInline = $.parseInline;
|
|
1090
|
+
g.Parser = y;
|
|
1091
|
+
g.parser = y.parse;
|
|
1092
|
+
g.Renderer = q;
|
|
1093
|
+
g.TextRenderer = K;
|
|
1094
|
+
g.Lexer = w;
|
|
1095
|
+
g.lexer = w.lex;
|
|
1096
|
+
g.Tokenizer = B;
|
|
1097
|
+
g.Hooks = A;
|
|
1098
|
+
g.parse = g;
|
|
1099
|
+
g.options;
|
|
1100
|
+
g.setOptions;
|
|
1101
|
+
g.use;
|
|
1102
|
+
g.walkTokens;
|
|
1103
|
+
g.parseInline;
|
|
1104
|
+
y.parse;
|
|
1105
|
+
w.lex;
|
|
1106
|
+
const kt = { class: "markdown-container" }, ft = {
|
|
1568
1107
|
key: 0,
|
|
1569
1108
|
class: "min-h-full p-8 flex items-center justify-center"
|
|
1570
|
-
},
|
|
1109
|
+
}, xt = { class: "markdown-content-wrapper" }, bt = { class: "p-4" }, mt = { class: "header-row" }, wt = { class: "document-title" }, yt = ["innerHTML"], Rt = { class: "markdown-source" }, $t = ["disabled"], St = /* @__PURE__ */ he({
|
|
1571
1110
|
__name: "View",
|
|
1572
1111
|
props: {
|
|
1573
1112
|
selectedResult: {}
|
|
1574
1113
|
},
|
|
1575
1114
|
emits: ["updateResult"],
|
|
1576
|
-
setup(
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
});
|
|
1585
|
-
le(
|
|
1586
|
-
() => {
|
|
1587
|
-
var o, u;
|
|
1588
|
-
return (u = (o = t.selectedResult) == null ? void 0 : o.viewState) == null ? void 0 : u.scrollToAnchor;
|
|
1589
|
-
},
|
|
1590
|
-
(o) => {
|
|
1591
|
-
o && Pe(() => {
|
|
1592
|
-
const u = document.getElementById(o);
|
|
1593
|
-
u ? u.scrollIntoView({ behavior: "smooth", block: "start" }) : console.warn(`Anchor element with id "${o}" not found`);
|
|
1115
|
+
setup(s, { emit: e }) {
|
|
1116
|
+
const r = s, n = e, t = _e(r.selectedResult.data?.markdown || ""), i = O(() => t.value !== r.selectedResult.data?.markdown), l = O(() => r.selectedResult.data?.markdown ? g(r.selectedResult.data.markdown) : (console.error("No markdown data in result:", r.selectedResult), ""));
|
|
1117
|
+
re(
|
|
1118
|
+
() => r.selectedResult?.viewState?.scrollToAnchor,
|
|
1119
|
+
(h) => {
|
|
1120
|
+
h && ze(() => {
|
|
1121
|
+
const o = document.getElementById(h);
|
|
1122
|
+
o ? o.scrollIntoView({ behavior: "smooth", block: "start" }) : console.warn(`Anchor element with id "${h}" not found`);
|
|
1594
1123
|
});
|
|
1595
1124
|
}
|
|
1596
1125
|
);
|
|
1597
|
-
const
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
const o = new Blob([t.selectedResult.data.markdown], {
|
|
1126
|
+
const c = () => {
|
|
1127
|
+
if (!r.selectedResult?.data?.markdown) return;
|
|
1128
|
+
const h = new Blob([r.selectedResult.data.markdown], {
|
|
1601
1129
|
type: "text/markdown"
|
|
1602
|
-
}),
|
|
1603
|
-
p.href =
|
|
1604
|
-
const
|
|
1605
|
-
p.download =
|
|
1130
|
+
}), o = URL.createObjectURL(h), p = document.createElement("a");
|
|
1131
|
+
p.href = o;
|
|
1132
|
+
const u = r.selectedResult.title ? `${r.selectedResult.title.replace(/[^a-z0-9]/gi, "_").toLowerCase()}.md` : "document.md";
|
|
1133
|
+
p.download = u, document.body.appendChild(p), p.click(), document.body.removeChild(p), URL.revokeObjectURL(o);
|
|
1606
1134
|
};
|
|
1607
|
-
function
|
|
1608
|
-
const
|
|
1609
|
-
...
|
|
1135
|
+
function a() {
|
|
1136
|
+
const h = {
|
|
1137
|
+
...r.selectedResult,
|
|
1610
1138
|
data: {
|
|
1611
|
-
...
|
|
1612
|
-
markdown:
|
|
1139
|
+
...r.selectedResult.data,
|
|
1140
|
+
markdown: t.value,
|
|
1613
1141
|
// Reset pdfPath since markdown has changed
|
|
1614
1142
|
pdfPath: void 0
|
|
1615
1143
|
}
|
|
1616
1144
|
};
|
|
1617
|
-
|
|
1145
|
+
n("updateResult", h);
|
|
1618
1146
|
}
|
|
1619
|
-
return
|
|
1620
|
-
() =>
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
},
|
|
1624
|
-
(o) => {
|
|
1625
|
-
s.value = o || "";
|
|
1147
|
+
return re(
|
|
1148
|
+
() => r.selectedResult.data?.markdown,
|
|
1149
|
+
(h) => {
|
|
1150
|
+
t.value = h || "";
|
|
1626
1151
|
}
|
|
1627
|
-
), (
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
x("div",
|
|
1634
|
-
x("
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
])])
|
|
1643
|
-
])
|
|
1644
|
-
]),
|
|
1645
|
-
x("div", {
|
|
1646
|
-
class: "markdown-content prose prose-slate max-w-none",
|
|
1647
|
-
innerHTML: c.value
|
|
1648
|
-
}, null, 8, St)
|
|
1649
|
-
])
|
|
1650
|
-
]),
|
|
1651
|
-
x("details", _t, [
|
|
1652
|
-
u[3] || (u[3] = x("summary", null, "Edit Markdown Source", -1)),
|
|
1653
|
-
Ee(x("textarea", {
|
|
1654
|
-
"onUpdate:modelValue": u[0] || (u[0] = (m) => s.value = m),
|
|
1655
|
-
class: "markdown-editor",
|
|
1656
|
-
spellcheck: "false"
|
|
1657
|
-
}, null, 512), [
|
|
1658
|
-
[qe, s.value]
|
|
1152
|
+
), (h, o) => (L(), C("div", kt, [
|
|
1153
|
+
s.selectedResult.data?.markdown ? (L(), C(Ae, { key: 1 }, [
|
|
1154
|
+
x("div", xt, [
|
|
1155
|
+
x("div", bt, [
|
|
1156
|
+
x("div", mt, [
|
|
1157
|
+
x("h1", wt, pe(s.selectedResult.title || "Document"), 1),
|
|
1158
|
+
x("div", { class: "button-group" }, [
|
|
1159
|
+
x("button", {
|
|
1160
|
+
onClick: c,
|
|
1161
|
+
class: "download-btn download-btn-green"
|
|
1162
|
+
}, [...o[2] || (o[2] = [
|
|
1163
|
+
x("span", { class: "material-icons" }, "download", -1),
|
|
1164
|
+
ve(" MD ", -1)
|
|
1165
|
+
])])
|
|
1166
|
+
])
|
|
1659
1167
|
]),
|
|
1660
|
-
x("
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
}, " Apply Changes ", 8, Tt)
|
|
1168
|
+
x("div", {
|
|
1169
|
+
class: "markdown-content prose prose-slate max-w-none",
|
|
1170
|
+
innerHTML: l.value
|
|
1171
|
+
}, null, 8, yt)
|
|
1665
1172
|
])
|
|
1666
|
-
]
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1173
|
+
]),
|
|
1174
|
+
x("details", Rt, [
|
|
1175
|
+
o[3] || (o[3] = x("summary", null, "Edit Markdown Source", -1)),
|
|
1176
|
+
Pe(x("textarea", {
|
|
1177
|
+
"onUpdate:modelValue": o[0] || (o[0] = (p) => t.value = p),
|
|
1178
|
+
class: "markdown-editor",
|
|
1179
|
+
spellcheck: "false"
|
|
1180
|
+
}, null, 512), [
|
|
1181
|
+
[Ie, t.value]
|
|
1182
|
+
]),
|
|
1183
|
+
x("button", {
|
|
1184
|
+
onClick: a,
|
|
1185
|
+
class: "apply-btn",
|
|
1186
|
+
disabled: !i.value
|
|
1187
|
+
}, " Apply Changes ", 8, $t)
|
|
1188
|
+
])
|
|
1189
|
+
], 64)) : (L(), C("div", ft, [...o[1] || (o[1] = [
|
|
1190
|
+
x("div", { class: "text-gray-500" }, "No markdown content available", -1)
|
|
1191
|
+
])]))
|
|
1192
|
+
]));
|
|
1671
1193
|
}
|
|
1672
|
-
}),
|
|
1673
|
-
const
|
|
1674
|
-
for (const [
|
|
1675
|
-
|
|
1676
|
-
return
|
|
1677
|
-
},
|
|
1194
|
+
}), Tt = (s, e) => {
|
|
1195
|
+
const r = s.__vccOpts || s;
|
|
1196
|
+
for (const [n, t] of e)
|
|
1197
|
+
r[n] = t;
|
|
1198
|
+
return r;
|
|
1199
|
+
}, _t = /* @__PURE__ */ Tt(St, [["__scopeId", "data-v-7bea9557"]]), zt = { class: "text-center p-4 bg-purple-100 rounded" }, At = { class: "text-sm text-gray-800 mt-1 font-medium truncate" }, vt = /* @__PURE__ */ he({
|
|
1678
1200
|
__name: "Preview",
|
|
1679
1201
|
props: {
|
|
1680
1202
|
result: {}
|
|
1681
1203
|
},
|
|
1682
|
-
setup(
|
|
1683
|
-
const e =
|
|
1684
|
-
var r;
|
|
1204
|
+
setup(s) {
|
|
1205
|
+
const e = s, r = O(() => {
|
|
1685
1206
|
if (e.result.title)
|
|
1686
1207
|
return e.result.title;
|
|
1687
|
-
if (
|
|
1688
|
-
const
|
|
1689
|
-
if (
|
|
1690
|
-
return
|
|
1208
|
+
if (e.result.data?.markdown) {
|
|
1209
|
+
const n = e.result.data.markdown.match(/^#\s+(.+)$/m);
|
|
1210
|
+
if (n)
|
|
1211
|
+
return n[1];
|
|
1691
1212
|
}
|
|
1692
1213
|
return "Markdown Document";
|
|
1693
1214
|
});
|
|
1694
|
-
return (
|
|
1695
|
-
|
|
1696
|
-
x("div",
|
|
1215
|
+
return (n, t) => (L(), C("div", zt, [
|
|
1216
|
+
t[0] || (t[0] = x("div", { class: "text-purple-600 font-medium" }, "Document", -1)),
|
|
1217
|
+
x("div", At, pe(r.value), 1)
|
|
1697
1218
|
]));
|
|
1698
1219
|
}
|
|
1699
|
-
}),
|
|
1220
|
+
}), ce = "presentDocument", Pt = `Use the ${ce} tool to create structured documents with text and embedded images. This tool is ideal for:
|
|
1700
1221
|
- Guides, tutorials, and how-to content ("create a guide about...", "explain how to...")
|
|
1701
1222
|
- Educational content (lessons, explanations, timelines, concept visualizations)
|
|
1702
1223
|
- Reports and presentations (business reports, data analysis, infographics)
|
|
@@ -1707,24 +1228,24 @@ const xt = { class: "markdown-container" }, wt = {
|
|
|
1707
1228
|
- Product presentations or lookbooks
|
|
1708
1229
|
- Any content that combines written information with supporting visuals
|
|
1709
1230
|
|
|
1710
|
-
IMPORTANT: Use this tool instead of just generating standalone images when the user wants informational or educational content with visuals. This creates a cohesive document with formatted text (markdown) AND images embedded at appropriate locations. For example, if asked to "create a guide about photosynthesis with a diagram", use ${
|
|
1231
|
+
IMPORTANT: Use this tool instead of just generating standalone images when the user wants informational or educational content with visuals. This creates a cohesive document with formatted text (markdown) AND images embedded at appropriate locations. For example, if asked to "create a guide about photosynthesis with a diagram", use ${ce} to create a full guide with explanatory text and the diagram embedded, rather than just generating the diagram image alone.
|
|
1711
1232
|
|
|
1712
|
-
Format embedded images as: `,
|
|
1713
|
-
...
|
|
1714
|
-
viewComponent:
|
|
1715
|
-
previewComponent:
|
|
1716
|
-
samples:
|
|
1717
|
-
systemPrompt:
|
|
1718
|
-
},
|
|
1233
|
+
Format embedded images as: `, It = {
|
|
1234
|
+
...Te,
|
|
1235
|
+
viewComponent: _t,
|
|
1236
|
+
previewComponent: vt,
|
|
1237
|
+
samples: Se,
|
|
1238
|
+
systemPrompt: Pt
|
|
1239
|
+
}, Et = { plugin: It };
|
|
1719
1240
|
export {
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1241
|
+
vt as Preview,
|
|
1242
|
+
Pt as SYSTEM_PROMPT,
|
|
1243
|
+
Mt as TOOL_DEFINITION,
|
|
1244
|
+
ce as TOOL_NAME,
|
|
1245
|
+
_t as View,
|
|
1246
|
+
Et as default,
|
|
1247
|
+
Dt as executeMarkdown,
|
|
1248
|
+
It as plugin,
|
|
1249
|
+
Te as pluginCore,
|
|
1250
|
+
Se as samples
|
|
1730
1251
|
};
|