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