@flyfish-group/file-viewer 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/components/ImageViewer.js +841 -584
- package/dist/components/MarkdownViewer.js +432 -413
- package/dist/components/PdfView.js +6641 -6474
- package/dist/components/PptxRender.js +1800 -1787
- package/dist/components/XlsxTable.js +25698 -20699
- package/dist/components/_commonjsHelpers.js +1 -1
- package/dist/components/docx-preview.js +5622 -0
- package/dist/components/index.js +736 -646
- package/dist/components/worker-ref.js +1 -1
- package/dist/index.umd.js +144 -209
- package/dist/style.css +10 -10
- package/dist/worker/pdf.worker.js +31 -31
- package/dist/worker/pptx.worker.js +7 -7
- package/dist/worker/sheet.worker.js +24 -24
- package/dist/worker/xlsx.worker.js +17 -17
- package/package.json +10 -10
- package/dist/components/docx-preview.min.js +0 -5354
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var we = Object.defineProperty, ye = Object.defineProperties;
|
|
2
|
+
var $e = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var se = Object.getOwnPropertySymbols;
|
|
4
|
+
var Te = Object.prototype.hasOwnProperty, _e = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var H = (a, t, e) => t in a ? we(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e, x = (a, t) => {
|
|
6
|
+
for (var e in t || (t = {}))
|
|
7
|
+
Te.call(t, e) && H(a, e, t[e]);
|
|
8
|
+
if (se)
|
|
9
|
+
for (var e of se(t))
|
|
10
|
+
_e.call(t, e) && H(a, e, t[e]);
|
|
11
|
+
return a;
|
|
12
|
+
}, R = (a, t) => ye(a, $e(t));
|
|
13
|
+
var d = (a, t, e) => (H(a, typeof t != "symbol" ? t + "" : t, e), e), ze = (a, t, e) => {
|
|
4
14
|
if (!t.has(a))
|
|
5
15
|
throw TypeError("Cannot " + e);
|
|
6
16
|
};
|
|
7
|
-
var
|
|
17
|
+
var N = (a, t, e) => {
|
|
8
18
|
if (t.has(a))
|
|
9
19
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
20
|
t instanceof WeakSet ? t.add(a) : t.set(a, e);
|
|
11
21
|
};
|
|
12
|
-
var
|
|
13
|
-
import { defineComponent as
|
|
14
|
-
import { n as
|
|
15
|
-
function
|
|
22
|
+
var v = (a, t, e) => (ze(a, t, "access private method"), e);
|
|
23
|
+
import { defineComponent as Re, computed as Se } from "vue";
|
|
24
|
+
import { n as Ie } from "./index.js";
|
|
25
|
+
function V() {
|
|
16
26
|
return {
|
|
17
27
|
async: !1,
|
|
18
28
|
breaks: !1,
|
|
@@ -26,86 +36,86 @@ function N() {
|
|
|
26
36
|
walkTokens: null
|
|
27
37
|
};
|
|
28
38
|
}
|
|
29
|
-
let
|
|
30
|
-
function
|
|
31
|
-
|
|
39
|
+
let z = V();
|
|
40
|
+
function ce(a) {
|
|
41
|
+
z = a;
|
|
32
42
|
}
|
|
33
|
-
const
|
|
43
|
+
const he = /[&<>"']/, Ae = new RegExp(he.source, "g"), pe = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, Ee = new RegExp(pe.source, "g"), Ce = {
|
|
34
44
|
"&": "&",
|
|
35
45
|
"<": "<",
|
|
36
46
|
">": ">",
|
|
37
47
|
'"': """,
|
|
38
48
|
"'": "'"
|
|
39
|
-
},
|
|
40
|
-
function
|
|
49
|
+
}, ie = (a) => Ce[a];
|
|
50
|
+
function m(a, t) {
|
|
41
51
|
if (t) {
|
|
42
|
-
if (
|
|
43
|
-
return a.replace(
|
|
44
|
-
} else if (
|
|
45
|
-
return a.replace(
|
|
52
|
+
if (he.test(a))
|
|
53
|
+
return a.replace(Ae, ie);
|
|
54
|
+
} else if (pe.test(a))
|
|
55
|
+
return a.replace(Ee, ie);
|
|
46
56
|
return a;
|
|
47
57
|
}
|
|
48
|
-
const
|
|
49
|
-
function
|
|
50
|
-
return a.replace(
|
|
58
|
+
const Le = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
59
|
+
function ve(a) {
|
|
60
|
+
return a.replace(Le, (t, e) => (e = e.toLowerCase(), e === "colon" ? ":" : e.charAt(0) === "#" ? e.charAt(1) === "x" ? String.fromCharCode(parseInt(e.substring(2), 16)) : String.fromCharCode(+e.substring(1)) : ""));
|
|
51
61
|
}
|
|
52
|
-
const
|
|
62
|
+
const Pe = /(^|[^\[])\^/g;
|
|
53
63
|
function k(a, t) {
|
|
54
64
|
let e = typeof a == "string" ? a : a.source;
|
|
55
65
|
t = t || "";
|
|
56
66
|
const n = {
|
|
57
|
-
replace: (
|
|
58
|
-
let s = typeof
|
|
59
|
-
return s = s.replace(
|
|
67
|
+
replace: (r, i) => {
|
|
68
|
+
let s = typeof i == "string" ? i : i.source;
|
|
69
|
+
return s = s.replace(Pe, "$1"), e = e.replace(r, s), n;
|
|
60
70
|
},
|
|
61
71
|
getRegex: () => new RegExp(e, t)
|
|
62
72
|
};
|
|
63
73
|
return n;
|
|
64
74
|
}
|
|
65
|
-
function
|
|
75
|
+
function re(a) {
|
|
66
76
|
try {
|
|
67
77
|
a = encodeURI(a).replace(/%25/g, "%");
|
|
68
|
-
} catch {
|
|
78
|
+
} catch (t) {
|
|
69
79
|
return null;
|
|
70
80
|
}
|
|
71
81
|
return a;
|
|
72
82
|
}
|
|
73
|
-
const
|
|
74
|
-
function
|
|
75
|
-
const e = a.replace(/\|/g, (
|
|
83
|
+
const I = { exec: () => null };
|
|
84
|
+
function le(a, t) {
|
|
85
|
+
const e = a.replace(/\|/g, (i, s, l) => {
|
|
76
86
|
let o = !1, p = s;
|
|
77
87
|
for (; --p >= 0 && l[p] === "\\"; )
|
|
78
88
|
o = !o;
|
|
79
89
|
return o ? "|" : " |";
|
|
80
90
|
}), n = e.split(/ \|/);
|
|
81
|
-
let
|
|
91
|
+
let r = 0;
|
|
82
92
|
if (n[0].trim() || n.shift(), n.length > 0 && !n[n.length - 1].trim() && n.pop(), t)
|
|
83
93
|
if (n.length > t)
|
|
84
94
|
n.splice(t);
|
|
85
95
|
else
|
|
86
96
|
for (; n.length < t; )
|
|
87
97
|
n.push("");
|
|
88
|
-
for (;
|
|
89
|
-
n[
|
|
98
|
+
for (; r < n.length; r++)
|
|
99
|
+
n[r] = n[r].trim().replace(/\\\|/g, "|");
|
|
90
100
|
return n;
|
|
91
101
|
}
|
|
92
|
-
function
|
|
102
|
+
function P(a, t, e) {
|
|
93
103
|
const n = a.length;
|
|
94
104
|
if (n === 0)
|
|
95
105
|
return "";
|
|
96
|
-
let
|
|
97
|
-
for (;
|
|
98
|
-
const
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
else if (
|
|
102
|
-
|
|
106
|
+
let r = 0;
|
|
107
|
+
for (; r < n; ) {
|
|
108
|
+
const i = a.charAt(n - r - 1);
|
|
109
|
+
if (i === t && !e)
|
|
110
|
+
r++;
|
|
111
|
+
else if (i !== t && e)
|
|
112
|
+
r++;
|
|
103
113
|
else
|
|
104
114
|
break;
|
|
105
115
|
}
|
|
106
|
-
return a.slice(0, n -
|
|
116
|
+
return a.slice(0, n - r);
|
|
107
117
|
}
|
|
108
|
-
function
|
|
118
|
+
function Ze(a, t) {
|
|
109
119
|
if (a.indexOf(t[1]) === -1)
|
|
110
120
|
return -1;
|
|
111
121
|
let e = 0;
|
|
@@ -118,15 +128,15 @@ function Ie(a, t) {
|
|
|
118
128
|
return n;
|
|
119
129
|
return -1;
|
|
120
130
|
}
|
|
121
|
-
function
|
|
122
|
-
const
|
|
131
|
+
function oe(a, t, e, n) {
|
|
132
|
+
const r = t.href, i = t.title ? m(t.title) : null, s = a[1].replace(/\\([\[\]])/g, "$1");
|
|
123
133
|
if (a[0].charAt(0) !== "!") {
|
|
124
134
|
n.state.inLink = !0;
|
|
125
135
|
const l = {
|
|
126
136
|
type: "link",
|
|
127
137
|
raw: e,
|
|
128
|
-
href:
|
|
129
|
-
title:
|
|
138
|
+
href: r,
|
|
139
|
+
title: i,
|
|
130
140
|
text: s,
|
|
131
141
|
tokens: n.inlineTokens(s)
|
|
132
142
|
};
|
|
@@ -135,34 +145,34 @@ function se(a, t, e, n) {
|
|
|
135
145
|
return {
|
|
136
146
|
type: "image",
|
|
137
147
|
raw: e,
|
|
138
|
-
href:
|
|
139
|
-
title:
|
|
140
|
-
text:
|
|
148
|
+
href: r,
|
|
149
|
+
title: i,
|
|
150
|
+
text: m(s)
|
|
141
151
|
};
|
|
142
152
|
}
|
|
143
|
-
function
|
|
153
|
+
function Be(a, t) {
|
|
144
154
|
const e = a.match(/^(\s+)(?:```)/);
|
|
145
155
|
if (e === null)
|
|
146
156
|
return t;
|
|
147
157
|
const n = e[1];
|
|
148
158
|
return t.split(`
|
|
149
|
-
`).map((
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
return
|
|
153
|
-
const [s] =
|
|
154
|
-
return s.length >= n.length ?
|
|
159
|
+
`).map((r) => {
|
|
160
|
+
const i = r.match(/^\s+/);
|
|
161
|
+
if (i === null)
|
|
162
|
+
return r;
|
|
163
|
+
const [s] = i;
|
|
164
|
+
return s.length >= n.length ? r.slice(n.length) : r;
|
|
155
165
|
}).join(`
|
|
156
166
|
`);
|
|
157
167
|
}
|
|
158
|
-
class
|
|
168
|
+
class B {
|
|
159
169
|
// set by the lexer
|
|
160
170
|
constructor(t) {
|
|
161
171
|
d(this, "options");
|
|
162
172
|
d(this, "rules");
|
|
163
173
|
// set by the lexer
|
|
164
174
|
d(this, "lexer");
|
|
165
|
-
this.options = t ||
|
|
175
|
+
this.options = t || z;
|
|
166
176
|
}
|
|
167
177
|
space(t) {
|
|
168
178
|
const e = this.rules.block.newline.exec(t);
|
|
@@ -180,7 +190,7 @@ class P {
|
|
|
180
190
|
type: "code",
|
|
181
191
|
raw: e[0],
|
|
182
192
|
codeBlockStyle: "indented",
|
|
183
|
-
text: this.options.pedantic ? n :
|
|
193
|
+
text: this.options.pedantic ? n : P(n, `
|
|
184
194
|
`)
|
|
185
195
|
};
|
|
186
196
|
}
|
|
@@ -188,12 +198,12 @@ class P {
|
|
|
188
198
|
fences(t) {
|
|
189
199
|
const e = this.rules.block.fences.exec(t);
|
|
190
200
|
if (e) {
|
|
191
|
-
const n = e[0],
|
|
201
|
+
const n = e[0], r = Be(n, e[3] || "");
|
|
192
202
|
return {
|
|
193
203
|
type: "code",
|
|
194
204
|
raw: n,
|
|
195
205
|
lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
|
|
196
|
-
text:
|
|
206
|
+
text: r
|
|
197
207
|
};
|
|
198
208
|
}
|
|
199
209
|
}
|
|
@@ -202,8 +212,8 @@ class P {
|
|
|
202
212
|
if (e) {
|
|
203
213
|
let n = e[2].trim();
|
|
204
214
|
if (/#$/.test(n)) {
|
|
205
|
-
const
|
|
206
|
-
(this.options.pedantic || !
|
|
215
|
+
const r = P(n, "#");
|
|
216
|
+
(this.options.pedantic || !r || / $/.test(r)) && (n = r.trim());
|
|
207
217
|
}
|
|
208
218
|
return {
|
|
209
219
|
type: "heading",
|
|
@@ -225,14 +235,14 @@ class P {
|
|
|
225
235
|
blockquote(t) {
|
|
226
236
|
const e = this.rules.block.blockquote.exec(t);
|
|
227
237
|
if (e) {
|
|
228
|
-
const n =
|
|
229
|
-
`),
|
|
238
|
+
const n = P(e[0].replace(/^ *>[ \t]?/gm, ""), `
|
|
239
|
+
`), r = this.lexer.state.top;
|
|
230
240
|
this.lexer.state.top = !0;
|
|
231
|
-
const
|
|
232
|
-
return this.lexer.state.top =
|
|
241
|
+
const i = this.lexer.blockTokens(n);
|
|
242
|
+
return this.lexer.state.top = r, {
|
|
233
243
|
type: "blockquote",
|
|
234
244
|
raw: e[0],
|
|
235
|
-
tokens:
|
|
245
|
+
tokens: i,
|
|
236
246
|
text: n
|
|
237
247
|
};
|
|
238
248
|
}
|
|
@@ -241,15 +251,15 @@ class P {
|
|
|
241
251
|
let e = this.rules.block.list.exec(t);
|
|
242
252
|
if (e) {
|
|
243
253
|
let n = e[1].trim();
|
|
244
|
-
const
|
|
254
|
+
const r = n.length > 1, i = {
|
|
245
255
|
type: "list",
|
|
246
256
|
raw: "",
|
|
247
|
-
ordered:
|
|
248
|
-
start:
|
|
257
|
+
ordered: r,
|
|
258
|
+
start: r ? +n.slice(0, -1) : "",
|
|
249
259
|
loose: !1,
|
|
250
260
|
items: []
|
|
251
261
|
};
|
|
252
|
-
n =
|
|
262
|
+
n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
|
|
253
263
|
const s = new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
254
264
|
let l = "", o = "", p = !1;
|
|
255
265
|
for (; t; ) {
|
|
@@ -258,53 +268,53 @@ class P {
|
|
|
258
268
|
break;
|
|
259
269
|
l = e[0], t = t.substring(l.length);
|
|
260
270
|
let u = e[2].split(`
|
|
261
|
-
`, 1)[0].replace(/^\t+/, (
|
|
271
|
+
`, 1)[0].replace(/^\t+/, (O) => " ".repeat(3 * O.length)), h = t.split(`
|
|
262
272
|
`, 1)[0], g = 0;
|
|
263
273
|
this.options.pedantic ? (g = 2, o = u.trimStart()) : (g = e[2].search(/[^ ]/), g = g > 4 ? 1 : g, o = u.slice(g), g += e[1].length);
|
|
264
|
-
let
|
|
274
|
+
let $ = !1;
|
|
265
275
|
if (!u && /^ *$/.test(h) && (l += h + `
|
|
266
276
|
`, t = t.substring(h.length + 1), c = !0), !c) {
|
|
267
|
-
const
|
|
277
|
+
const O = new RegExp(`^ {0,${Math.min(3, g - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), ee = new RegExp(`^ {0,${Math.min(3, g - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), te = new RegExp(`^ {0,${Math.min(3, g - 1)}}(?:\`\`\`|~~~)`), ne = new RegExp(`^ {0,${Math.min(3, g - 1)}}#`);
|
|
268
278
|
for (; t; ) {
|
|
269
|
-
const
|
|
279
|
+
const j = t.split(`
|
|
270
280
|
`, 1)[0];
|
|
271
|
-
if (h =
|
|
281
|
+
if (h = j, this.options.pedantic && (h = h.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), te.test(h) || ne.test(h) || O.test(h) || ee.test(t))
|
|
272
282
|
break;
|
|
273
283
|
if (h.search(/[^ ]/) >= g || !h.trim())
|
|
274
284
|
o += `
|
|
275
285
|
` + h.slice(g);
|
|
276
286
|
else {
|
|
277
|
-
if (
|
|
287
|
+
if ($ || u.search(/[^ ]/) >= 4 || te.test(u) || ne.test(u) || ee.test(u))
|
|
278
288
|
break;
|
|
279
289
|
o += `
|
|
280
290
|
` + h;
|
|
281
291
|
}
|
|
282
|
-
|
|
283
|
-
`, t = t.substring(
|
|
292
|
+
!$ && !h.trim() && ($ = !0), l += j + `
|
|
293
|
+
`, t = t.substring(j.length + 1), u = h.slice(g);
|
|
284
294
|
}
|
|
285
295
|
}
|
|
286
|
-
|
|
287
|
-
let
|
|
288
|
-
this.options.gfm && (
|
|
296
|
+
i.loose || (p ? i.loose = !0 : /\n *\n *$/.test(l) && (p = !0));
|
|
297
|
+
let b = null, T;
|
|
298
|
+
this.options.gfm && (b = /^\[[ xX]\] /.exec(o), b && (T = b[0] !== "[ ] ", o = o.replace(/^\[[ xX]\] +/, ""))), i.items.push({
|
|
289
299
|
type: "list_item",
|
|
290
300
|
raw: l,
|
|
291
|
-
task: !!
|
|
292
|
-
checked:
|
|
301
|
+
task: !!b,
|
|
302
|
+
checked: T,
|
|
293
303
|
loose: !1,
|
|
294
304
|
text: o,
|
|
295
305
|
tokens: []
|
|
296
|
-
}),
|
|
306
|
+
}), i.raw += l;
|
|
297
307
|
}
|
|
298
|
-
|
|
299
|
-
for (let c = 0; c <
|
|
300
|
-
if (this.lexer.state.top = !1,
|
|
301
|
-
const u =
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
if (
|
|
305
|
-
for (let c = 0; c <
|
|
306
|
-
|
|
307
|
-
return
|
|
308
|
+
i.items[i.items.length - 1].raw = l.trimEnd(), i.items[i.items.length - 1].text = o.trimEnd(), i.raw = i.raw.trimEnd();
|
|
309
|
+
for (let c = 0; c < i.items.length; c++)
|
|
310
|
+
if (this.lexer.state.top = !1, i.items[c].tokens = this.lexer.blockTokens(i.items[c].text, []), !i.loose) {
|
|
311
|
+
const u = i.items[c].tokens.filter((g) => g.type === "space"), h = u.length > 0 && u.some((g) => /\n.*\n/.test(g.raw));
|
|
312
|
+
i.loose = h;
|
|
313
|
+
}
|
|
314
|
+
if (i.loose)
|
|
315
|
+
for (let c = 0; c < i.items.length; c++)
|
|
316
|
+
i.items[c].loose = !0;
|
|
317
|
+
return i;
|
|
308
318
|
}
|
|
309
319
|
}
|
|
310
320
|
html(t) {
|
|
@@ -321,13 +331,13 @@ class P {
|
|
|
321
331
|
def(t) {
|
|
322
332
|
const e = this.rules.block.def.exec(t);
|
|
323
333
|
if (e) {
|
|
324
|
-
const n = e[1].toLowerCase().replace(/\s+/g, " "),
|
|
334
|
+
const n = e[1].toLowerCase().replace(/\s+/g, " "), r = e[2] ? e[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", i = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
|
|
325
335
|
return {
|
|
326
336
|
type: "def",
|
|
327
337
|
tag: n,
|
|
328
338
|
raw: e[0],
|
|
329
|
-
href:
|
|
330
|
-
title:
|
|
339
|
+
href: r,
|
|
340
|
+
title: i
|
|
331
341
|
};
|
|
332
342
|
}
|
|
333
343
|
}
|
|
@@ -335,7 +345,7 @@ class P {
|
|
|
335
345
|
const e = this.rules.block.table.exec(t);
|
|
336
346
|
if (!e || !/[:|]/.test(e[2]))
|
|
337
347
|
return;
|
|
338
|
-
const n =
|
|
348
|
+
const n = le(e[1]), r = e[2].replace(/^\||\| *$/g, "").split("|"), i = e[3] && e[3].trim() ? e[3].replace(/\n[ \t]*$/, "").split(`
|
|
339
349
|
`) : [], s = {
|
|
340
350
|
type: "table",
|
|
341
351
|
raw: e[0],
|
|
@@ -343,16 +353,16 @@ class P {
|
|
|
343
353
|
align: [],
|
|
344
354
|
rows: []
|
|
345
355
|
};
|
|
346
|
-
if (n.length ===
|
|
347
|
-
for (const l of
|
|
356
|
+
if (n.length === r.length) {
|
|
357
|
+
for (const l of r)
|
|
348
358
|
/^ *-+: *$/.test(l) ? s.align.push("right") : /^ *:-+: *$/.test(l) ? s.align.push("center") : /^ *:-+ *$/.test(l) ? s.align.push("left") : s.align.push(null);
|
|
349
359
|
for (const l of n)
|
|
350
360
|
s.header.push({
|
|
351
361
|
text: l,
|
|
352
362
|
tokens: this.lexer.inline(l)
|
|
353
363
|
});
|
|
354
|
-
for (const l of
|
|
355
|
-
s.rows.push(
|
|
364
|
+
for (const l of i)
|
|
365
|
+
s.rows.push(le(l, s.header.length).map((o) => ({
|
|
356
366
|
text: o,
|
|
357
367
|
tokens: this.lexer.inline(o)
|
|
358
368
|
})));
|
|
@@ -399,7 +409,7 @@ class P {
|
|
|
399
409
|
return {
|
|
400
410
|
type: "escape",
|
|
401
411
|
raw: e[0],
|
|
402
|
-
text:
|
|
412
|
+
text: m(e[1])
|
|
403
413
|
};
|
|
404
414
|
}
|
|
405
415
|
tag(t) {
|
|
@@ -421,33 +431,33 @@ class P {
|
|
|
421
431
|
if (!this.options.pedantic && /^</.test(n)) {
|
|
422
432
|
if (!/>$/.test(n))
|
|
423
433
|
return;
|
|
424
|
-
const s =
|
|
434
|
+
const s = P(n.slice(0, -1), "\\");
|
|
425
435
|
if ((n.length - s.length) % 2 === 0)
|
|
426
436
|
return;
|
|
427
437
|
} else {
|
|
428
|
-
const s =
|
|
438
|
+
const s = Ze(e[2], "()");
|
|
429
439
|
if (s > -1) {
|
|
430
440
|
const o = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + s;
|
|
431
441
|
e[2] = e[2].substring(0, s), e[0] = e[0].substring(0, o).trim(), e[3] = "";
|
|
432
442
|
}
|
|
433
443
|
}
|
|
434
|
-
let
|
|
444
|
+
let r = e[2], i = "";
|
|
435
445
|
if (this.options.pedantic) {
|
|
436
|
-
const s = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(
|
|
437
|
-
s && (
|
|
446
|
+
const s = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(r);
|
|
447
|
+
s && (r = s[1], i = s[3]);
|
|
438
448
|
} else
|
|
439
|
-
|
|
440
|
-
return
|
|
441
|
-
href:
|
|
442
|
-
title:
|
|
449
|
+
i = e[3] ? e[3].slice(1, -1) : "";
|
|
450
|
+
return r = r.trim(), /^</.test(r) && (this.options.pedantic && !/>$/.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), oe(e, {
|
|
451
|
+
href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
452
|
+
title: i && i.replace(this.rules.inline.anyPunctuation, "$1")
|
|
443
453
|
}, e[0], this.lexer);
|
|
444
454
|
}
|
|
445
455
|
}
|
|
446
456
|
reflink(t, e) {
|
|
447
457
|
let n;
|
|
448
458
|
if ((n = this.rules.inline.reflink.exec(t)) || (n = this.rules.inline.nolink.exec(t))) {
|
|
449
|
-
const
|
|
450
|
-
if (!
|
|
459
|
+
const r = (n[2] || n[1]).replace(/\s+/g, " "), i = e[r.toLowerCase()];
|
|
460
|
+
if (!i) {
|
|
451
461
|
const s = n[0].charAt(0);
|
|
452
462
|
return {
|
|
453
463
|
type: "text",
|
|
@@ -455,46 +465,46 @@ class P {
|
|
|
455
465
|
text: s
|
|
456
466
|
};
|
|
457
467
|
}
|
|
458
|
-
return
|
|
468
|
+
return oe(n, i, n[0], this.lexer);
|
|
459
469
|
}
|
|
460
470
|
}
|
|
461
471
|
emStrong(t, e, n = "") {
|
|
462
|
-
let
|
|
463
|
-
if (!
|
|
472
|
+
let r = this.rules.inline.emStrongLDelim.exec(t);
|
|
473
|
+
if (!r || r[3] && n.match(/[\p{L}\p{N}]/u))
|
|
464
474
|
return;
|
|
465
|
-
if (!(
|
|
466
|
-
const s = [...
|
|
475
|
+
if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
476
|
+
const s = [...r[0]].length - 1;
|
|
467
477
|
let l, o, p = s, c = 0;
|
|
468
|
-
const u =
|
|
469
|
-
for (u.lastIndex = 0, e = e.slice(-1 * t.length + s); (
|
|
470
|
-
if (l =
|
|
478
|
+
const u = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
479
|
+
for (u.lastIndex = 0, e = e.slice(-1 * t.length + s); (r = u.exec(e)) != null; ) {
|
|
480
|
+
if (l = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !l)
|
|
471
481
|
continue;
|
|
472
|
-
if (o = [...l].length,
|
|
482
|
+
if (o = [...l].length, r[3] || r[4]) {
|
|
473
483
|
p += o;
|
|
474
484
|
continue;
|
|
475
|
-
} else if ((
|
|
485
|
+
} else if ((r[5] || r[6]) && s % 3 && !((s + o) % 3)) {
|
|
476
486
|
c += o;
|
|
477
487
|
continue;
|
|
478
488
|
}
|
|
479
489
|
if (p -= o, p > 0)
|
|
480
490
|
continue;
|
|
481
491
|
o = Math.min(o, o + p + c);
|
|
482
|
-
const h = [...
|
|
492
|
+
const h = [...r[0]][0].length, g = t.slice(0, s + r.index + h + o);
|
|
483
493
|
if (Math.min(s, o) % 2) {
|
|
484
|
-
const
|
|
494
|
+
const b = g.slice(1, -1);
|
|
485
495
|
return {
|
|
486
496
|
type: "em",
|
|
487
497
|
raw: g,
|
|
488
|
-
text:
|
|
489
|
-
tokens: this.lexer.inlineTokens(
|
|
498
|
+
text: b,
|
|
499
|
+
tokens: this.lexer.inlineTokens(b)
|
|
490
500
|
};
|
|
491
501
|
}
|
|
492
|
-
const
|
|
502
|
+
const $ = g.slice(2, -2);
|
|
493
503
|
return {
|
|
494
504
|
type: "strong",
|
|
495
505
|
raw: g,
|
|
496
|
-
text:
|
|
497
|
-
tokens: this.lexer.inlineTokens(
|
|
506
|
+
text: $,
|
|
507
|
+
tokens: this.lexer.inlineTokens($)
|
|
498
508
|
};
|
|
499
509
|
}
|
|
500
510
|
}
|
|
@@ -503,8 +513,8 @@ class P {
|
|
|
503
513
|
const e = this.rules.inline.code.exec(t);
|
|
504
514
|
if (e) {
|
|
505
515
|
let n = e[2].replace(/\n/g, " ");
|
|
506
|
-
const
|
|
507
|
-
return
|
|
516
|
+
const r = /[^ ]/.test(n), i = /^ /.test(n) && / $/.test(n);
|
|
517
|
+
return r && i && (n = n.substring(1, n.length - 1)), n = m(n, !0), {
|
|
508
518
|
type: "codespan",
|
|
509
519
|
raw: e[0],
|
|
510
520
|
text: n
|
|
@@ -532,12 +542,12 @@ class P {
|
|
|
532
542
|
autolink(t) {
|
|
533
543
|
const e = this.rules.inline.autolink.exec(t);
|
|
534
544
|
if (e) {
|
|
535
|
-
let n,
|
|
536
|
-
return e[2] === "@" ? (n =
|
|
545
|
+
let n, r;
|
|
546
|
+
return e[2] === "@" ? (n = m(e[1]), r = "mailto:" + n) : (n = m(e[1]), r = n), {
|
|
537
547
|
type: "link",
|
|
538
548
|
raw: e[0],
|
|
539
549
|
text: n,
|
|
540
|
-
href:
|
|
550
|
+
href: r,
|
|
541
551
|
tokens: [
|
|
542
552
|
{
|
|
543
553
|
type: "text",
|
|
@@ -549,24 +559,24 @@ class P {
|
|
|
549
559
|
}
|
|
550
560
|
}
|
|
551
561
|
url(t) {
|
|
552
|
-
var n;
|
|
562
|
+
var n, r;
|
|
553
563
|
let e;
|
|
554
564
|
if (e = this.rules.inline.url.exec(t)) {
|
|
555
|
-
let i,
|
|
565
|
+
let i, s;
|
|
556
566
|
if (e[2] === "@")
|
|
557
|
-
i =
|
|
567
|
+
i = m(e[0]), s = "mailto:" + i;
|
|
558
568
|
else {
|
|
559
|
-
let
|
|
569
|
+
let l;
|
|
560
570
|
do
|
|
561
|
-
|
|
562
|
-
while (
|
|
563
|
-
i =
|
|
571
|
+
l = e[0], e[0] = (r = (n = this.rules.inline._backpedal.exec(e[0])) == null ? void 0 : n[0]) != null ? r : "";
|
|
572
|
+
while (l !== e[0]);
|
|
573
|
+
i = m(e[0]), e[1] === "www." ? s = "http://" + e[0] : s = e[0];
|
|
564
574
|
}
|
|
565
575
|
return {
|
|
566
576
|
type: "link",
|
|
567
577
|
raw: e[0],
|
|
568
578
|
text: i,
|
|
569
|
-
href:
|
|
579
|
+
href: s,
|
|
570
580
|
tokens: [
|
|
571
581
|
{
|
|
572
582
|
type: "text",
|
|
@@ -581,7 +591,7 @@ class P {
|
|
|
581
591
|
const e = this.rules.inline.text.exec(t);
|
|
582
592
|
if (e) {
|
|
583
593
|
let n;
|
|
584
|
-
return this.lexer.state.inRawBlock ? n = e[0] : n =
|
|
594
|
+
return this.lexer.state.inRawBlock ? n = e[0] : n = m(e[0]), {
|
|
585
595
|
type: "text",
|
|
586
596
|
raw: e[0],
|
|
587
597
|
text: n
|
|
@@ -589,118 +599,113 @@ class P {
|
|
|
589
599
|
}
|
|
590
600
|
}
|
|
591
601
|
}
|
|
592
|
-
const
|
|
593
|
-
blockquote:
|
|
594
|
-
code:
|
|
595
|
-
def:
|
|
596
|
-
fences:
|
|
597
|
-
heading:
|
|
598
|
-
hr:
|
|
599
|
-
html:
|
|
600
|
-
lheading:
|
|
601
|
-
list:
|
|
602
|
-
newline:
|
|
603
|
-
paragraph:
|
|
604
|
-
table:
|
|
605
|
-
text:
|
|
606
|
-
},
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
},
|
|
611
|
-
...X,
|
|
612
|
-
html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", V).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
|
|
602
|
+
const qe = /^(?: *(?:\n|$))+/, Me = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Qe = /^ {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+|$)/, De = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, ue = /(?:[*+-]|\d{1,9}[.)])/, fe = k(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, ue).getRegex(), X = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Oe = /^[^\n]+/, G = /(?!\s*\])(?:\\.|[^\[\]\\])+/, je = k(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", G).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), He = k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, ue).getRegex(), D = "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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", W = /<!--(?!-?>)[\s\S]*?(?:-->|$)/, Ne = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", W).replace("tag", D).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), ge = k(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", D).getRegex(), Fe = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ge).getRegex(), J = {
|
|
603
|
+
blockquote: Fe,
|
|
604
|
+
code: Me,
|
|
605
|
+
def: je,
|
|
606
|
+
fences: Qe,
|
|
607
|
+
heading: De,
|
|
608
|
+
hr: C,
|
|
609
|
+
html: Ne,
|
|
610
|
+
lheading: fe,
|
|
611
|
+
list: He,
|
|
612
|
+
newline: qe,
|
|
613
|
+
paragraph: ge,
|
|
614
|
+
table: I,
|
|
615
|
+
text: Oe
|
|
616
|
+
}, ae = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\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", D).getRegex(), Ue = R(x({}, J), {
|
|
617
|
+
table: ae,
|
|
618
|
+
paragraph: k(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", D).getRegex()
|
|
619
|
+
}), Ve = R(x({}, J), {
|
|
620
|
+
html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", W).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(),
|
|
613
621
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
614
622
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
615
|
-
fences:
|
|
623
|
+
fences: I,
|
|
616
624
|
// fences not supported
|
|
617
625
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
618
|
-
paragraph: k(
|
|
619
|
-
]`).replace("lheading",
|
|
620
|
-
},
|
|
621
|
-
_backpedal:
|
|
626
|
+
paragraph: k(X).replace("hr", C).replace("heading", ` *#{1,6} *[^
|
|
627
|
+
]`).replace("lheading", fe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
628
|
+
}), ke = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Xe = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, de = /^( {2,}|\\)\n(?!\s*$)/, Ge = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, L = "\\p{P}$+<=>`^|~", We = k(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, L).getRegex(), Je = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, Ke = k(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, L).getRegex(), Ye = k("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, L).getRegex(), et = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, L).getRegex(), tt = k(/\\([punct])/, "gu").replace(/punct/g, L).getRegex(), nt = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), st = k(W).replace("(?:-->|$)", "-->").getRegex(), it = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", st).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), q = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, rt = k(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), xe = k(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", G).getRegex(), me = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", G).getRegex(), lt = k("reflink|nolink(?!\\()", "g").replace("reflink", xe).replace("nolink", me).getRegex(), K = {
|
|
629
|
+
_backpedal: I,
|
|
622
630
|
// only used for GFM url
|
|
623
|
-
anyPunctuation:
|
|
624
|
-
autolink:
|
|
625
|
-
blockSkip:
|
|
626
|
-
br:
|
|
627
|
-
code:
|
|
628
|
-
del:
|
|
629
|
-
emStrongLDelim:
|
|
630
|
-
emStrongRDelimAst:
|
|
631
|
-
emStrongRDelimUnd:
|
|
632
|
-
escape:
|
|
633
|
-
link:
|
|
634
|
-
nolink:
|
|
635
|
-
punctuation:
|
|
636
|
-
reflink:
|
|
637
|
-
reflinkSearch:
|
|
638
|
-
tag:
|
|
639
|
-
text:
|
|
640
|
-
url:
|
|
641
|
-
},
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
...G,
|
|
647
|
-
escape: k(pe).replace("])", "~|])").getRegex(),
|
|
631
|
+
anyPunctuation: tt,
|
|
632
|
+
autolink: nt,
|
|
633
|
+
blockSkip: Je,
|
|
634
|
+
br: de,
|
|
635
|
+
code: Xe,
|
|
636
|
+
del: I,
|
|
637
|
+
emStrongLDelim: Ke,
|
|
638
|
+
emStrongRDelimAst: Ye,
|
|
639
|
+
emStrongRDelimUnd: et,
|
|
640
|
+
escape: ke,
|
|
641
|
+
link: rt,
|
|
642
|
+
nolink: me,
|
|
643
|
+
punctuation: We,
|
|
644
|
+
reflink: xe,
|
|
645
|
+
reflinkSearch: lt,
|
|
646
|
+
tag: it,
|
|
647
|
+
text: Ge,
|
|
648
|
+
url: I
|
|
649
|
+
}, ot = R(x({}, K), {
|
|
650
|
+
link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(),
|
|
651
|
+
reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex()
|
|
652
|
+
}), F = R(x({}, K), {
|
|
653
|
+
escape: k(ke).replace("])", "~|])").getRegex(),
|
|
648
654
|
url: k(/^((?: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(),
|
|
649
655
|
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
650
656
|
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
651
657
|
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
652
|
-
},
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
pedantic: et
|
|
658
|
+
}), at = R(x({}, F), {
|
|
659
|
+
br: k(de).replace("{2,}", "*").getRegex(),
|
|
660
|
+
text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
661
|
+
}), Z = {
|
|
662
|
+
normal: J,
|
|
663
|
+
gfm: Ue,
|
|
664
|
+
pedantic: Ve
|
|
665
|
+
}, S = {
|
|
666
|
+
normal: K,
|
|
667
|
+
gfm: F,
|
|
668
|
+
breaks: at,
|
|
669
|
+
pedantic: ot
|
|
665
670
|
};
|
|
666
|
-
class
|
|
671
|
+
class w {
|
|
667
672
|
constructor(t) {
|
|
668
673
|
d(this, "tokens");
|
|
669
674
|
d(this, "options");
|
|
670
675
|
d(this, "state");
|
|
671
676
|
d(this, "tokenizer");
|
|
672
677
|
d(this, "inlineQueue");
|
|
673
|
-
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = t ||
|
|
678
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = t || z, this.options.tokenizer = this.options.tokenizer || new B(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
674
679
|
inLink: !1,
|
|
675
680
|
inRawBlock: !1,
|
|
676
681
|
top: !0
|
|
677
682
|
};
|
|
678
683
|
const e = {
|
|
679
|
-
block:
|
|
680
|
-
inline:
|
|
684
|
+
block: Z.normal,
|
|
685
|
+
inline: S.normal
|
|
681
686
|
};
|
|
682
|
-
this.options.pedantic ? (e.block =
|
|
687
|
+
this.options.pedantic ? (e.block = Z.pedantic, e.inline = S.pedantic) : this.options.gfm && (e.block = Z.gfm, this.options.breaks ? e.inline = S.breaks : e.inline = S.gfm), this.tokenizer.rules = e;
|
|
683
688
|
}
|
|
684
689
|
/**
|
|
685
690
|
* Expose Rules
|
|
686
691
|
*/
|
|
687
692
|
static get rules() {
|
|
688
693
|
return {
|
|
689
|
-
block:
|
|
690
|
-
inline:
|
|
694
|
+
block: Z,
|
|
695
|
+
inline: S
|
|
691
696
|
};
|
|
692
697
|
}
|
|
693
698
|
/**
|
|
694
699
|
* Static Lex Method
|
|
695
700
|
*/
|
|
696
701
|
static lex(t, e) {
|
|
697
|
-
return new
|
|
702
|
+
return new w(e).lex(t);
|
|
698
703
|
}
|
|
699
704
|
/**
|
|
700
705
|
* Static Lex Inline Method
|
|
701
706
|
*/
|
|
702
707
|
static lexInline(t, e) {
|
|
703
|
-
return new
|
|
708
|
+
return new w(e).inlineTokens(t);
|
|
704
709
|
}
|
|
705
710
|
/**
|
|
706
711
|
* Preprocessing
|
|
@@ -708,14 +713,15 @@ class b {
|
|
|
708
713
|
lex(t) {
|
|
709
714
|
t = t.replace(/\r\n|\r/g, `
|
|
710
715
|
`), this.blockTokens(t, this.tokens);
|
|
711
|
-
let e;
|
|
712
|
-
|
|
713
|
-
this.inlineTokens(
|
|
714
|
-
|
|
716
|
+
for (let e = 0; e < this.inlineQueue.length; e++) {
|
|
717
|
+
const n = this.inlineQueue[e];
|
|
718
|
+
this.inlineTokens(n.src, n.tokens);
|
|
719
|
+
}
|
|
720
|
+
return this.inlineQueue = [], this.tokens;
|
|
715
721
|
}
|
|
716
722
|
blockTokens(t, e = []) {
|
|
717
723
|
this.options.pedantic ? t = t.replace(/\t/g, " ").replace(/^ +$/gm, "") : t = t.replace(/^( *)(\t+)/gm, (l, o, p) => o + " ".repeat(p.length));
|
|
718
|
-
let n,
|
|
724
|
+
let n, r, i, s;
|
|
719
725
|
for (; t; )
|
|
720
726
|
if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((l) => (n = l.call({ lexer: this }, t, e)) ? (t = t.substring(n.raw.length), e.push(n), !0) : !1))) {
|
|
721
727
|
if (n = this.tokenizer.space(t)) {
|
|
@@ -724,9 +730,9 @@ class b {
|
|
|
724
730
|
continue;
|
|
725
731
|
}
|
|
726
732
|
if (n = this.tokenizer.code(t)) {
|
|
727
|
-
t = t.substring(n.raw.length),
|
|
728
|
-
` + n.raw,
|
|
729
|
-
` + n.text, this.inlineQueue[this.inlineQueue.length - 1].src =
|
|
733
|
+
t = t.substring(n.raw.length), r = e[e.length - 1], r && (r.type === "paragraph" || r.type === "text") ? (r.raw += `
|
|
734
|
+
` + n.raw, r.text += `
|
|
735
|
+
` + n.text, this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : e.push(n);
|
|
730
736
|
continue;
|
|
731
737
|
}
|
|
732
738
|
if (n = this.tokenizer.fences(t)) {
|
|
@@ -754,9 +760,9 @@ class b {
|
|
|
754
760
|
continue;
|
|
755
761
|
}
|
|
756
762
|
if (n = this.tokenizer.def(t)) {
|
|
757
|
-
t = t.substring(n.raw.length),
|
|
758
|
-
` + n.raw,
|
|
759
|
-
` + n.raw, this.inlineQueue[this.inlineQueue.length - 1].src =
|
|
763
|
+
t = t.substring(n.raw.length), r = e[e.length - 1], r && (r.type === "paragraph" || r.type === "text") ? (r.raw += `
|
|
764
|
+
` + n.raw, r.text += `
|
|
765
|
+
` + n.raw, this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = {
|
|
760
766
|
href: n.href,
|
|
761
767
|
title: n.title
|
|
762
768
|
});
|
|
@@ -770,24 +776,24 @@ class b {
|
|
|
770
776
|
t = t.substring(n.raw.length), e.push(n);
|
|
771
777
|
continue;
|
|
772
778
|
}
|
|
773
|
-
if (
|
|
779
|
+
if (i = t, this.options.extensions && this.options.extensions.startBlock) {
|
|
774
780
|
let l = 1 / 0;
|
|
775
781
|
const o = t.slice(1);
|
|
776
782
|
let p;
|
|
777
783
|
this.options.extensions.startBlock.forEach((c) => {
|
|
778
784
|
p = c.call({ lexer: this }, o), typeof p == "number" && p >= 0 && (l = Math.min(l, p));
|
|
779
|
-
}), l < 1 / 0 && l >= 0 && (
|
|
785
|
+
}), l < 1 / 0 && l >= 0 && (i = t.substring(0, l + 1));
|
|
780
786
|
}
|
|
781
|
-
if (this.state.top && (n = this.tokenizer.paragraph(
|
|
782
|
-
|
|
783
|
-
` + n.raw,
|
|
784
|
-
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src =
|
|
787
|
+
if (this.state.top && (n = this.tokenizer.paragraph(i))) {
|
|
788
|
+
r = e[e.length - 1], s && r.type === "paragraph" ? (r.raw += `
|
|
789
|
+
` + n.raw, r.text += `
|
|
790
|
+
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : e.push(n), s = i.length !== t.length, t = t.substring(n.raw.length);
|
|
785
791
|
continue;
|
|
786
792
|
}
|
|
787
793
|
if (n = this.tokenizer.text(t)) {
|
|
788
|
-
t = t.substring(n.raw.length),
|
|
789
|
-
` + n.raw,
|
|
790
|
-
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src =
|
|
794
|
+
t = t.substring(n.raw.length), r = e[e.length - 1], r && r.type === "text" ? (r.raw += `
|
|
795
|
+
` + n.raw, r.text += `
|
|
796
|
+
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : e.push(n);
|
|
791
797
|
continue;
|
|
792
798
|
}
|
|
793
799
|
if (t) {
|
|
@@ -808,7 +814,7 @@ class b {
|
|
|
808
814
|
* Lexing/Compiling
|
|
809
815
|
*/
|
|
810
816
|
inlineTokens(t, e = []) {
|
|
811
|
-
let n,
|
|
817
|
+
let n, r, i, s = t, l, o, p;
|
|
812
818
|
if (this.tokens.links) {
|
|
813
819
|
const c = Object.keys(this.tokens.links);
|
|
814
820
|
if (c.length > 0)
|
|
@@ -826,7 +832,7 @@ class b {
|
|
|
826
832
|
continue;
|
|
827
833
|
}
|
|
828
834
|
if (n = this.tokenizer.tag(t)) {
|
|
829
|
-
t = t.substring(n.raw.length),
|
|
835
|
+
t = t.substring(n.raw.length), r = e[e.length - 1], r && n.type === "text" && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : e.push(n);
|
|
830
836
|
continue;
|
|
831
837
|
}
|
|
832
838
|
if (n = this.tokenizer.link(t)) {
|
|
@@ -834,7 +840,7 @@ class b {
|
|
|
834
840
|
continue;
|
|
835
841
|
}
|
|
836
842
|
if (n = this.tokenizer.reflink(t, this.tokens.links)) {
|
|
837
|
-
t = t.substring(n.raw.length),
|
|
843
|
+
t = t.substring(n.raw.length), r = e[e.length - 1], r && n.type === "text" && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : e.push(n);
|
|
838
844
|
continue;
|
|
839
845
|
}
|
|
840
846
|
if (n = this.tokenizer.emStrong(t, s, p)) {
|
|
@@ -861,16 +867,16 @@ class b {
|
|
|
861
867
|
t = t.substring(n.raw.length), e.push(n);
|
|
862
868
|
continue;
|
|
863
869
|
}
|
|
864
|
-
if (
|
|
870
|
+
if (i = t, this.options.extensions && this.options.extensions.startInline) {
|
|
865
871
|
let c = 1 / 0;
|
|
866
872
|
const u = t.slice(1);
|
|
867
873
|
let h;
|
|
868
874
|
this.options.extensions.startInline.forEach((g) => {
|
|
869
875
|
h = g.call({ lexer: this }, u), typeof h == "number" && h >= 0 && (c = Math.min(c, h));
|
|
870
|
-
}), c < 1 / 0 && c >= 0 && (
|
|
876
|
+
}), c < 1 / 0 && c >= 0 && (i = t.substring(0, c + 1));
|
|
871
877
|
}
|
|
872
|
-
if (n = this.tokenizer.inlineText(
|
|
873
|
-
t = t.substring(n.raw.length), n.raw.slice(-1) !== "_" && (p = n.raw.slice(-1)), o = !0,
|
|
878
|
+
if (n = this.tokenizer.inlineText(i)) {
|
|
879
|
+
t = t.substring(n.raw.length), n.raw.slice(-1) !== "_" && (p = n.raw.slice(-1)), o = !0, r = e[e.length - 1], r && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : e.push(n);
|
|
874
880
|
continue;
|
|
875
881
|
}
|
|
876
882
|
if (t) {
|
|
@@ -885,17 +891,17 @@ class b {
|
|
|
885
891
|
return e;
|
|
886
892
|
}
|
|
887
893
|
}
|
|
888
|
-
class
|
|
894
|
+
class M {
|
|
889
895
|
constructor(t) {
|
|
890
896
|
d(this, "options");
|
|
891
|
-
this.options = t ||
|
|
897
|
+
this.options = t || z;
|
|
892
898
|
}
|
|
893
899
|
code(t, e, n) {
|
|
894
|
-
var
|
|
895
|
-
const
|
|
900
|
+
var i;
|
|
901
|
+
const r = (i = (e || "").match(/^\S*/)) == null ? void 0 : i[0];
|
|
896
902
|
return t = t.replace(/\n$/, "") + `
|
|
897
|
-
`,
|
|
898
|
-
` : "<pre><code>" + (n ? t :
|
|
903
|
+
`, r ? '<pre><code class="language-' + m(r) + '">' + (n ? t : m(t, !0)) + `</code></pre>
|
|
904
|
+
` : "<pre><code>" + (n ? t : m(t, !0)) + `</code></pre>
|
|
899
905
|
`;
|
|
900
906
|
}
|
|
901
907
|
blockquote(t) {
|
|
@@ -915,9 +921,9 @@ ${t}</blockquote>
|
|
|
915
921
|
`;
|
|
916
922
|
}
|
|
917
923
|
list(t, e, n) {
|
|
918
|
-
const
|
|
919
|
-
return "<" +
|
|
920
|
-
` + t + "</" +
|
|
924
|
+
const r = e ? "ol" : "ul", i = e && n !== 1 ? ' start="' + n + '"' : "";
|
|
925
|
+
return "<" + r + i + `>
|
|
926
|
+
` + t + "</" + r + `>
|
|
921
927
|
`;
|
|
922
928
|
}
|
|
923
929
|
listitem(t, e, n) {
|
|
@@ -967,26 +973,26 @@ ${t}</tr>
|
|
|
967
973
|
return `<del>${t}</del>`;
|
|
968
974
|
}
|
|
969
975
|
link(t, e, n) {
|
|
970
|
-
const
|
|
971
|
-
if (
|
|
976
|
+
const r = re(t);
|
|
977
|
+
if (r === null)
|
|
972
978
|
return n;
|
|
973
|
-
t =
|
|
974
|
-
let
|
|
975
|
-
return e && (
|
|
979
|
+
t = r;
|
|
980
|
+
let i = '<a href="' + t + '"';
|
|
981
|
+
return e && (i += ' title="' + e + '"'), i += ">" + n + "</a>", i;
|
|
976
982
|
}
|
|
977
983
|
image(t, e, n) {
|
|
978
|
-
const
|
|
979
|
-
if (
|
|
984
|
+
const r = re(t);
|
|
985
|
+
if (r === null)
|
|
980
986
|
return n;
|
|
981
|
-
t =
|
|
982
|
-
let
|
|
983
|
-
return e && (
|
|
987
|
+
t = r;
|
|
988
|
+
let i = `<img src="${t}" alt="${n}"`;
|
|
989
|
+
return e && (i += ` title="${e}"`), i += ">", i;
|
|
984
990
|
}
|
|
985
991
|
text(t) {
|
|
986
992
|
return t;
|
|
987
993
|
}
|
|
988
994
|
}
|
|
989
|
-
class
|
|
995
|
+
class Y {
|
|
990
996
|
// no need for block level renderers
|
|
991
997
|
strong(t) {
|
|
992
998
|
return t;
|
|
@@ -1016,40 +1022,40 @@ class W {
|
|
|
1016
1022
|
return "";
|
|
1017
1023
|
}
|
|
1018
1024
|
}
|
|
1019
|
-
class
|
|
1025
|
+
class y {
|
|
1020
1026
|
constructor(t) {
|
|
1021
1027
|
d(this, "options");
|
|
1022
1028
|
d(this, "renderer");
|
|
1023
1029
|
d(this, "textRenderer");
|
|
1024
|
-
this.options = t ||
|
|
1030
|
+
this.options = t || z, this.options.renderer = this.options.renderer || new M(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new Y();
|
|
1025
1031
|
}
|
|
1026
1032
|
/**
|
|
1027
1033
|
* Static Parse Method
|
|
1028
1034
|
*/
|
|
1029
1035
|
static parse(t, e) {
|
|
1030
|
-
return new
|
|
1036
|
+
return new y(e).parse(t);
|
|
1031
1037
|
}
|
|
1032
1038
|
/**
|
|
1033
1039
|
* Static Parse Inline Method
|
|
1034
1040
|
*/
|
|
1035
1041
|
static parseInline(t, e) {
|
|
1036
|
-
return new
|
|
1042
|
+
return new y(e).parseInline(t);
|
|
1037
1043
|
}
|
|
1038
1044
|
/**
|
|
1039
1045
|
* Parse Loop
|
|
1040
1046
|
*/
|
|
1041
1047
|
parse(t, e = !0) {
|
|
1042
1048
|
let n = "";
|
|
1043
|
-
for (let
|
|
1044
|
-
const
|
|
1045
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[
|
|
1046
|
-
const s =
|
|
1049
|
+
for (let r = 0; r < t.length; r++) {
|
|
1050
|
+
const i = t[r];
|
|
1051
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[i.type]) {
|
|
1052
|
+
const s = i, l = this.options.extensions.renderers[s.type].call({ parser: this }, s);
|
|
1047
1053
|
if (l !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(s.type)) {
|
|
1048
1054
|
n += l || "";
|
|
1049
1055
|
continue;
|
|
1050
1056
|
}
|
|
1051
1057
|
}
|
|
1052
|
-
switch (
|
|
1058
|
+
switch (i.type) {
|
|
1053
1059
|
case "space":
|
|
1054
1060
|
continue;
|
|
1055
1061
|
case "hr": {
|
|
@@ -1057,17 +1063,17 @@ class w {
|
|
|
1057
1063
|
continue;
|
|
1058
1064
|
}
|
|
1059
1065
|
case "heading": {
|
|
1060
|
-
const s =
|
|
1061
|
-
n += this.renderer.heading(this.parseInline(s.tokens), s.depth,
|
|
1066
|
+
const s = i;
|
|
1067
|
+
n += this.renderer.heading(this.parseInline(s.tokens), s.depth, ve(this.parseInline(s.tokens, this.textRenderer)));
|
|
1062
1068
|
continue;
|
|
1063
1069
|
}
|
|
1064
1070
|
case "code": {
|
|
1065
|
-
const s =
|
|
1071
|
+
const s = i;
|
|
1066
1072
|
n += this.renderer.code(s.text, s.lang, !!s.escaped);
|
|
1067
1073
|
continue;
|
|
1068
1074
|
}
|
|
1069
1075
|
case "table": {
|
|
1070
|
-
const s =
|
|
1076
|
+
const s = i;
|
|
1071
1077
|
let l = "", o = "";
|
|
1072
1078
|
for (let c = 0; c < s.header.length; c++)
|
|
1073
1079
|
o += this.renderer.tablecell(this.parseInline(s.header[c].tokens), { header: !0, align: s.align[c] });
|
|
@@ -1084,48 +1090,48 @@ class w {
|
|
|
1084
1090
|
continue;
|
|
1085
1091
|
}
|
|
1086
1092
|
case "blockquote": {
|
|
1087
|
-
const s =
|
|
1093
|
+
const s = i, l = this.parse(s.tokens);
|
|
1088
1094
|
n += this.renderer.blockquote(l);
|
|
1089
1095
|
continue;
|
|
1090
1096
|
}
|
|
1091
1097
|
case "list": {
|
|
1092
|
-
const s =
|
|
1098
|
+
const s = i, l = s.ordered, o = s.start, p = s.loose;
|
|
1093
1099
|
let c = "";
|
|
1094
1100
|
for (let u = 0; u < s.items.length; u++) {
|
|
1095
|
-
const h = s.items[u], g = h.checked,
|
|
1096
|
-
let
|
|
1101
|
+
const h = s.items[u], g = h.checked, $ = h.task;
|
|
1102
|
+
let b = "";
|
|
1097
1103
|
if (h.task) {
|
|
1098
|
-
const
|
|
1099
|
-
p ? h.tokens.length > 0 && h.tokens[0].type === "paragraph" ? (h.tokens[0].text =
|
|
1104
|
+
const T = this.renderer.checkbox(!!g);
|
|
1105
|
+
p ? h.tokens.length > 0 && h.tokens[0].type === "paragraph" ? (h.tokens[0].text = T + " " + h.tokens[0].text, h.tokens[0].tokens && h.tokens[0].tokens.length > 0 && h.tokens[0].tokens[0].type === "text" && (h.tokens[0].tokens[0].text = T + " " + h.tokens[0].tokens[0].text)) : h.tokens.unshift({
|
|
1100
1106
|
type: "text",
|
|
1101
|
-
text:
|
|
1102
|
-
}) :
|
|
1107
|
+
text: T + " "
|
|
1108
|
+
}) : b += T + " ";
|
|
1103
1109
|
}
|
|
1104
|
-
|
|
1110
|
+
b += this.parse(h.tokens, p), c += this.renderer.listitem(b, $, !!g);
|
|
1105
1111
|
}
|
|
1106
1112
|
n += this.renderer.list(c, l, o);
|
|
1107
1113
|
continue;
|
|
1108
1114
|
}
|
|
1109
1115
|
case "html": {
|
|
1110
|
-
const s =
|
|
1116
|
+
const s = i;
|
|
1111
1117
|
n += this.renderer.html(s.text, s.block);
|
|
1112
1118
|
continue;
|
|
1113
1119
|
}
|
|
1114
1120
|
case "paragraph": {
|
|
1115
|
-
const s =
|
|
1121
|
+
const s = i;
|
|
1116
1122
|
n += this.renderer.paragraph(this.parseInline(s.tokens));
|
|
1117
1123
|
continue;
|
|
1118
1124
|
}
|
|
1119
1125
|
case "text": {
|
|
1120
|
-
let s =
|
|
1121
|
-
for (;
|
|
1122
|
-
s = t[++
|
|
1126
|
+
let s = i, l = s.tokens ? this.parseInline(s.tokens) : s.text;
|
|
1127
|
+
for (; r + 1 < t.length && t[r + 1].type === "text"; )
|
|
1128
|
+
s = t[++r], l += `
|
|
1123
1129
|
` + (s.tokens ? this.parseInline(s.tokens) : s.text);
|
|
1124
1130
|
n += e ? this.renderer.paragraph(l) : l;
|
|
1125
1131
|
continue;
|
|
1126
1132
|
}
|
|
1127
1133
|
default: {
|
|
1128
|
-
const s = 'Token with "' +
|
|
1134
|
+
const s = 'Token with "' + i.type + '" type was not found.';
|
|
1129
1135
|
if (this.options.silent)
|
|
1130
1136
|
return console.error(s), "";
|
|
1131
1137
|
throw new Error(s);
|
|
@@ -1140,48 +1146,48 @@ class w {
|
|
|
1140
1146
|
parseInline(t, e) {
|
|
1141
1147
|
e = e || this.renderer;
|
|
1142
1148
|
let n = "";
|
|
1143
|
-
for (let
|
|
1144
|
-
const
|
|
1145
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[
|
|
1146
|
-
const s = this.options.extensions.renderers[
|
|
1147
|
-
if (s !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(
|
|
1149
|
+
for (let r = 0; r < t.length; r++) {
|
|
1150
|
+
const i = t[r];
|
|
1151
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[i.type]) {
|
|
1152
|
+
const s = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
1153
|
+
if (s !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
|
|
1148
1154
|
n += s || "";
|
|
1149
1155
|
continue;
|
|
1150
1156
|
}
|
|
1151
1157
|
}
|
|
1152
|
-
switch (
|
|
1158
|
+
switch (i.type) {
|
|
1153
1159
|
case "escape": {
|
|
1154
|
-
const s =
|
|
1160
|
+
const s = i;
|
|
1155
1161
|
n += e.text(s.text);
|
|
1156
1162
|
break;
|
|
1157
1163
|
}
|
|
1158
1164
|
case "html": {
|
|
1159
|
-
const s =
|
|
1165
|
+
const s = i;
|
|
1160
1166
|
n += e.html(s.text);
|
|
1161
1167
|
break;
|
|
1162
1168
|
}
|
|
1163
1169
|
case "link": {
|
|
1164
|
-
const s =
|
|
1170
|
+
const s = i;
|
|
1165
1171
|
n += e.link(s.href, s.title, this.parseInline(s.tokens, e));
|
|
1166
1172
|
break;
|
|
1167
1173
|
}
|
|
1168
1174
|
case "image": {
|
|
1169
|
-
const s =
|
|
1175
|
+
const s = i;
|
|
1170
1176
|
n += e.image(s.href, s.title, s.text);
|
|
1171
1177
|
break;
|
|
1172
1178
|
}
|
|
1173
1179
|
case "strong": {
|
|
1174
|
-
const s =
|
|
1180
|
+
const s = i;
|
|
1175
1181
|
n += e.strong(this.parseInline(s.tokens, e));
|
|
1176
1182
|
break;
|
|
1177
1183
|
}
|
|
1178
1184
|
case "em": {
|
|
1179
|
-
const s =
|
|
1185
|
+
const s = i;
|
|
1180
1186
|
n += e.em(this.parseInline(s.tokens, e));
|
|
1181
1187
|
break;
|
|
1182
1188
|
}
|
|
1183
1189
|
case "codespan": {
|
|
1184
|
-
const s =
|
|
1190
|
+
const s = i;
|
|
1185
1191
|
n += e.codespan(s.text);
|
|
1186
1192
|
break;
|
|
1187
1193
|
}
|
|
@@ -1190,17 +1196,17 @@ class w {
|
|
|
1190
1196
|
break;
|
|
1191
1197
|
}
|
|
1192
1198
|
case "del": {
|
|
1193
|
-
const s =
|
|
1199
|
+
const s = i;
|
|
1194
1200
|
n += e.del(this.parseInline(s.tokens, e));
|
|
1195
1201
|
break;
|
|
1196
1202
|
}
|
|
1197
1203
|
case "text": {
|
|
1198
|
-
const s =
|
|
1204
|
+
const s = i;
|
|
1199
1205
|
n += e.text(s.text);
|
|
1200
1206
|
break;
|
|
1201
1207
|
}
|
|
1202
1208
|
default: {
|
|
1203
|
-
const s = 'Token with "' +
|
|
1209
|
+
const s = 'Token with "' + i.type + '" type was not found.';
|
|
1204
1210
|
if (this.options.silent)
|
|
1205
1211
|
return console.error(s), "";
|
|
1206
1212
|
throw new Error(s);
|
|
@@ -1210,10 +1216,10 @@ class w {
|
|
|
1210
1216
|
return n;
|
|
1211
1217
|
}
|
|
1212
1218
|
}
|
|
1213
|
-
class
|
|
1219
|
+
class A {
|
|
1214
1220
|
constructor(t) {
|
|
1215
1221
|
d(this, "options");
|
|
1216
|
-
this.options = t ||
|
|
1222
|
+
this.options = t || z;
|
|
1217
1223
|
}
|
|
1218
1224
|
/**
|
|
1219
1225
|
* Process markdown before marked
|
|
@@ -1227,33 +1233,40 @@ class S {
|
|
|
1227
1233
|
postprocess(t) {
|
|
1228
1234
|
return t;
|
|
1229
1235
|
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Process all tokens before walk tokens
|
|
1238
|
+
*/
|
|
1239
|
+
processAllTokens(t) {
|
|
1240
|
+
return t;
|
|
1241
|
+
}
|
|
1230
1242
|
}
|
|
1231
|
-
d(
|
|
1243
|
+
d(A, "passThroughHooks", /* @__PURE__ */ new Set([
|
|
1232
1244
|
"preprocess",
|
|
1233
|
-
"postprocess"
|
|
1245
|
+
"postprocess",
|
|
1246
|
+
"processAllTokens"
|
|
1234
1247
|
]));
|
|
1235
|
-
var
|
|
1236
|
-
class
|
|
1248
|
+
var E, U, Q, be;
|
|
1249
|
+
class ct {
|
|
1237
1250
|
constructor(...t) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
d(this, "defaults",
|
|
1251
|
+
N(this, E);
|
|
1252
|
+
N(this, Q);
|
|
1253
|
+
d(this, "defaults", V());
|
|
1241
1254
|
d(this, "options", this.setOptions);
|
|
1242
|
-
d(this, "parse",
|
|
1243
|
-
d(this, "parseInline",
|
|
1244
|
-
d(this, "Parser",
|
|
1245
|
-
d(this, "Renderer",
|
|
1246
|
-
d(this, "TextRenderer",
|
|
1247
|
-
d(this, "Lexer",
|
|
1248
|
-
d(this, "Tokenizer",
|
|
1249
|
-
d(this, "Hooks",
|
|
1255
|
+
d(this, "parse", v(this, E, U).call(this, w.lex, y.parse));
|
|
1256
|
+
d(this, "parseInline", v(this, E, U).call(this, w.lexInline, y.parseInline));
|
|
1257
|
+
d(this, "Parser", y);
|
|
1258
|
+
d(this, "Renderer", M);
|
|
1259
|
+
d(this, "TextRenderer", Y);
|
|
1260
|
+
d(this, "Lexer", w);
|
|
1261
|
+
d(this, "Tokenizer", B);
|
|
1262
|
+
d(this, "Hooks", A);
|
|
1250
1263
|
this.use(...t);
|
|
1251
1264
|
}
|
|
1252
1265
|
/**
|
|
1253
1266
|
* Run callback for every token
|
|
1254
1267
|
*/
|
|
1255
1268
|
walkTokens(t, e) {
|
|
1256
|
-
var
|
|
1269
|
+
var r, i;
|
|
1257
1270
|
let n = [];
|
|
1258
1271
|
for (const s of t)
|
|
1259
1272
|
switch (n = n.concat(e.call(this, s)), s.type) {
|
|
@@ -1273,7 +1286,7 @@ class nt {
|
|
|
1273
1286
|
}
|
|
1274
1287
|
default: {
|
|
1275
1288
|
const l = s;
|
|
1276
|
-
(
|
|
1289
|
+
(i = (r = this.defaults.extensions) == null ? void 0 : r.childTokens) != null && i[l.type] ? this.defaults.extensions.childTokens[l.type].forEach((o) => {
|
|
1277
1290
|
n = n.concat(this.walkTokens(l[o], e));
|
|
1278
1291
|
}) : l.tokens && (n = n.concat(this.walkTokens(l.tokens, e)));
|
|
1279
1292
|
}
|
|
@@ -1283,177 +1296,183 @@ class nt {
|
|
|
1283
1296
|
use(...t) {
|
|
1284
1297
|
const e = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1285
1298
|
return t.forEach((n) => {
|
|
1286
|
-
const
|
|
1287
|
-
if (
|
|
1288
|
-
if (!
|
|
1299
|
+
const r = x({}, n);
|
|
1300
|
+
if (r.async = this.defaults.async || r.async || !1, n.extensions && (n.extensions.forEach((i) => {
|
|
1301
|
+
if (!i.name)
|
|
1289
1302
|
throw new Error("extension name required");
|
|
1290
|
-
if ("renderer" in
|
|
1291
|
-
const s = e.renderers[
|
|
1292
|
-
s ? e.renderers[
|
|
1293
|
-
let o =
|
|
1303
|
+
if ("renderer" in i) {
|
|
1304
|
+
const s = e.renderers[i.name];
|
|
1305
|
+
s ? e.renderers[i.name] = function(...l) {
|
|
1306
|
+
let o = i.renderer.apply(this, l);
|
|
1294
1307
|
return o === !1 && (o = s.apply(this, l)), o;
|
|
1295
|
-
} : e.renderers[
|
|
1308
|
+
} : e.renderers[i.name] = i.renderer;
|
|
1296
1309
|
}
|
|
1297
|
-
if ("tokenizer" in
|
|
1298
|
-
if (!
|
|
1310
|
+
if ("tokenizer" in i) {
|
|
1311
|
+
if (!i.level || i.level !== "block" && i.level !== "inline")
|
|
1299
1312
|
throw new Error("extension level must be 'block' or 'inline'");
|
|
1300
|
-
const s = e[
|
|
1301
|
-
s ? s.unshift(
|
|
1313
|
+
const s = e[i.level];
|
|
1314
|
+
s ? s.unshift(i.tokenizer) : e[i.level] = [i.tokenizer], i.start && (i.level === "block" ? e.startBlock ? e.startBlock.push(i.start) : e.startBlock = [i.start] : i.level === "inline" && (e.startInline ? e.startInline.push(i.start) : e.startInline = [i.start]));
|
|
1302
1315
|
}
|
|
1303
|
-
"childTokens" in
|
|
1304
|
-
}),
|
|
1305
|
-
const
|
|
1316
|
+
"childTokens" in i && i.childTokens && (e.childTokens[i.name] = i.childTokens);
|
|
1317
|
+
}), r.extensions = e), n.renderer) {
|
|
1318
|
+
const i = this.defaults.renderer || new M(this.defaults);
|
|
1306
1319
|
for (const s in n.renderer) {
|
|
1307
|
-
if (!(s in
|
|
1320
|
+
if (!(s in i))
|
|
1308
1321
|
throw new Error(`renderer '${s}' does not exist`);
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1322
|
+
if (s === "options")
|
|
1323
|
+
continue;
|
|
1324
|
+
const l = s, o = n.renderer[l], p = i[l];
|
|
1325
|
+
i[l] = (...c) => {
|
|
1326
|
+
let u = o.apply(i, c);
|
|
1327
|
+
return u === !1 && (u = p.apply(i, c)), u || "";
|
|
1313
1328
|
};
|
|
1314
1329
|
}
|
|
1315
|
-
|
|
1330
|
+
r.renderer = i;
|
|
1316
1331
|
}
|
|
1317
1332
|
if (n.tokenizer) {
|
|
1318
|
-
const
|
|
1333
|
+
const i = this.defaults.tokenizer || new B(this.defaults);
|
|
1319
1334
|
for (const s in n.tokenizer) {
|
|
1320
|
-
if (!(s in
|
|
1335
|
+
if (!(s in i))
|
|
1321
1336
|
throw new Error(`tokenizer '${s}' does not exist`);
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1337
|
+
if (["options", "rules", "lexer"].includes(s))
|
|
1338
|
+
continue;
|
|
1339
|
+
const l = s, o = n.tokenizer[l], p = i[l];
|
|
1340
|
+
i[l] = (...c) => {
|
|
1341
|
+
let u = o.apply(i, c);
|
|
1342
|
+
return u === !1 && (u = p.apply(i, c)), u;
|
|
1326
1343
|
};
|
|
1327
1344
|
}
|
|
1328
|
-
|
|
1345
|
+
r.tokenizer = i;
|
|
1329
1346
|
}
|
|
1330
1347
|
if (n.hooks) {
|
|
1331
|
-
const
|
|
1348
|
+
const i = this.defaults.hooks || new A();
|
|
1332
1349
|
for (const s in n.hooks) {
|
|
1333
|
-
if (!(s in
|
|
1350
|
+
if (!(s in i))
|
|
1334
1351
|
throw new Error(`hook '${s}' does not exist`);
|
|
1335
|
-
|
|
1336
|
-
|
|
1352
|
+
if (s === "options")
|
|
1353
|
+
continue;
|
|
1354
|
+
const l = s, o = n.hooks[l], p = i[l];
|
|
1355
|
+
A.passThroughHooks.has(s) ? i[l] = (c) => {
|
|
1337
1356
|
if (this.defaults.async)
|
|
1338
|
-
return Promise.resolve(o.call(
|
|
1339
|
-
const u = o.call(
|
|
1340
|
-
return p.call(
|
|
1341
|
-
} :
|
|
1342
|
-
let u = o.apply(
|
|
1343
|
-
return u === !1 && (u = p.apply(
|
|
1357
|
+
return Promise.resolve(o.call(i, c)).then((h) => p.call(i, h));
|
|
1358
|
+
const u = o.call(i, c);
|
|
1359
|
+
return p.call(i, u);
|
|
1360
|
+
} : i[l] = (...c) => {
|
|
1361
|
+
let u = o.apply(i, c);
|
|
1362
|
+
return u === !1 && (u = p.apply(i, c)), u;
|
|
1344
1363
|
};
|
|
1345
1364
|
}
|
|
1346
|
-
|
|
1365
|
+
r.hooks = i;
|
|
1347
1366
|
}
|
|
1348
1367
|
if (n.walkTokens) {
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1368
|
+
const i = this.defaults.walkTokens, s = n.walkTokens;
|
|
1369
|
+
r.walkTokens = function(l) {
|
|
1351
1370
|
let o = [];
|
|
1352
|
-
return o.push(s.call(this, l)),
|
|
1371
|
+
return o.push(s.call(this, l)), i && (o = o.concat(i.call(this, l))), o;
|
|
1353
1372
|
};
|
|
1354
1373
|
}
|
|
1355
|
-
this.defaults = {
|
|
1374
|
+
this.defaults = x(x({}, this.defaults), r);
|
|
1356
1375
|
}), this;
|
|
1357
1376
|
}
|
|
1358
1377
|
setOptions(t) {
|
|
1359
|
-
return this.defaults = {
|
|
1378
|
+
return this.defaults = x(x({}, this.defaults), t), this;
|
|
1360
1379
|
}
|
|
1361
1380
|
lexer(t, e) {
|
|
1362
|
-
return
|
|
1381
|
+
return w.lex(t, e != null ? e : this.defaults);
|
|
1363
1382
|
}
|
|
1364
1383
|
parser(t, e) {
|
|
1365
|
-
return
|
|
1384
|
+
return y.parse(t, e != null ? e : this.defaults);
|
|
1366
1385
|
}
|
|
1367
1386
|
}
|
|
1368
|
-
|
|
1369
|
-
return (n,
|
|
1370
|
-
const
|
|
1371
|
-
this.defaults.async === !0 &&
|
|
1372
|
-
const l =
|
|
1373
|
-
if (typeof n
|
|
1387
|
+
E = new WeakSet(), U = function(t, e) {
|
|
1388
|
+
return (n, r) => {
|
|
1389
|
+
const i = x({}, r), s = x(x({}, this.defaults), i);
|
|
1390
|
+
this.defaults.async === !0 && i.async === !1 && (s.silent || console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."), s.async = !0);
|
|
1391
|
+
const l = v(this, Q, be).call(this, !!s.silent, !!s.async);
|
|
1392
|
+
if (typeof n == "undefined" || n === null)
|
|
1374
1393
|
return l(new Error("marked(): input parameter is undefined or null"));
|
|
1375
1394
|
if (typeof n != "string")
|
|
1376
1395
|
return l(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
1377
1396
|
if (s.hooks && (s.hooks.options = s), s.async)
|
|
1378
|
-
return Promise.resolve(s.hooks ? s.hooks.preprocess(n) : n).then((o) => t(o, s)).then((o) => s.walkTokens ? Promise.all(this.walkTokens(o, s.walkTokens)).then(() => o) : o).then((o) => e(o, s)).then((o) => s.hooks ? s.hooks.postprocess(o) : o).catch(l);
|
|
1397
|
+
return Promise.resolve(s.hooks ? s.hooks.preprocess(n) : n).then((o) => t(o, s)).then((o) => s.hooks ? s.hooks.processAllTokens(o) : o).then((o) => s.walkTokens ? Promise.all(this.walkTokens(o, s.walkTokens)).then(() => o) : o).then((o) => e(o, s)).then((o) => s.hooks ? s.hooks.postprocess(o) : o).catch(l);
|
|
1379
1398
|
try {
|
|
1380
1399
|
s.hooks && (n = s.hooks.preprocess(n));
|
|
1381
|
-
|
|
1382
|
-
s.walkTokens && this.walkTokens(o, s.walkTokens);
|
|
1400
|
+
let o = t(n, s);
|
|
1401
|
+
s.hooks && (o = s.hooks.processAllTokens(o)), s.walkTokens && this.walkTokens(o, s.walkTokens);
|
|
1383
1402
|
let p = e(o, s);
|
|
1384
1403
|
return s.hooks && (p = s.hooks.postprocess(p)), p;
|
|
1385
1404
|
} catch (o) {
|
|
1386
1405
|
return l(o);
|
|
1387
1406
|
}
|
|
1388
1407
|
};
|
|
1389
|
-
},
|
|
1408
|
+
}, Q = new WeakSet(), be = function(t, e) {
|
|
1390
1409
|
return (n) => {
|
|
1391
1410
|
if (n.message += `
|
|
1392
1411
|
Please report this to https://github.com/markedjs/marked.`, t) {
|
|
1393
|
-
const
|
|
1394
|
-
return e ? Promise.resolve(
|
|
1412
|
+
const r = "<p>An error occurred:</p><pre>" + m(n.message + "", !0) + "</pre>";
|
|
1413
|
+
return e ? Promise.resolve(r) : r;
|
|
1395
1414
|
}
|
|
1396
1415
|
if (e)
|
|
1397
1416
|
return Promise.reject(n);
|
|
1398
1417
|
throw n;
|
|
1399
1418
|
};
|
|
1400
1419
|
};
|
|
1401
|
-
const _ = new
|
|
1420
|
+
const _ = new ct();
|
|
1402
1421
|
function f(a, t) {
|
|
1403
1422
|
return _.parse(a, t);
|
|
1404
1423
|
}
|
|
1405
1424
|
f.options = f.setOptions = function(a) {
|
|
1406
|
-
return _.setOptions(a), f.defaults = _.defaults,
|
|
1425
|
+
return _.setOptions(a), f.defaults = _.defaults, ce(f.defaults), f;
|
|
1407
1426
|
};
|
|
1408
|
-
f.getDefaults =
|
|
1409
|
-
f.defaults =
|
|
1427
|
+
f.getDefaults = V;
|
|
1428
|
+
f.defaults = z;
|
|
1410
1429
|
f.use = function(...a) {
|
|
1411
|
-
return _.use(...a), f.defaults = _.defaults,
|
|
1430
|
+
return _.use(...a), f.defaults = _.defaults, ce(f.defaults), f;
|
|
1412
1431
|
};
|
|
1413
1432
|
f.walkTokens = function(a, t) {
|
|
1414
1433
|
return _.walkTokens(a, t);
|
|
1415
1434
|
};
|
|
1416
1435
|
f.parseInline = _.parseInline;
|
|
1417
|
-
f.Parser =
|
|
1418
|
-
f.parser =
|
|
1419
|
-
f.Renderer =
|
|
1420
|
-
f.TextRenderer =
|
|
1421
|
-
f.Lexer =
|
|
1422
|
-
f.lexer =
|
|
1423
|
-
f.Tokenizer =
|
|
1424
|
-
f.Hooks =
|
|
1436
|
+
f.Parser = y;
|
|
1437
|
+
f.parser = y.parse;
|
|
1438
|
+
f.Renderer = M;
|
|
1439
|
+
f.TextRenderer = Y;
|
|
1440
|
+
f.Lexer = w;
|
|
1441
|
+
f.lexer = w.lex;
|
|
1442
|
+
f.Tokenizer = B;
|
|
1443
|
+
f.Hooks = A;
|
|
1425
1444
|
f.parse = f;
|
|
1426
1445
|
f.options;
|
|
1427
1446
|
f.setOptions;
|
|
1428
1447
|
f.use;
|
|
1429
1448
|
f.walkTokens;
|
|
1430
1449
|
f.parseInline;
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
const
|
|
1450
|
+
y.parse;
|
|
1451
|
+
w.lex;
|
|
1452
|
+
const ht = /* @__PURE__ */ Re({
|
|
1434
1453
|
__name: "MarkdownViewer",
|
|
1435
1454
|
props: {
|
|
1436
1455
|
data: null
|
|
1437
1456
|
},
|
|
1438
1457
|
setup(a) {
|
|
1439
|
-
const t = a, e =
|
|
1458
|
+
const t = a, e = Se(() => f(t.data));
|
|
1440
1459
|
return { __sfc: !0, props: t, html: e };
|
|
1441
1460
|
}
|
|
1442
1461
|
});
|
|
1443
|
-
var
|
|
1462
|
+
var pt = function() {
|
|
1444
1463
|
var t = this, e = t._self._c, n = t._self._setupProxy;
|
|
1445
1464
|
return e("div", { staticClass: "markdown-body", domProps: { innerHTML: t._s(n.html) } });
|
|
1446
|
-
},
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1465
|
+
}, ut = [], ft = /* @__PURE__ */ Ie(
|
|
1466
|
+
ht,
|
|
1467
|
+
pt,
|
|
1468
|
+
ut,
|
|
1450
1469
|
!1,
|
|
1451
1470
|
null,
|
|
1452
1471
|
"e0bd8a5a",
|
|
1453
1472
|
null,
|
|
1454
1473
|
null
|
|
1455
1474
|
);
|
|
1456
|
-
const
|
|
1475
|
+
const xt = ft.exports;
|
|
1457
1476
|
export {
|
|
1458
|
-
|
|
1477
|
+
xt as default
|
|
1459
1478
|
};
|