@wsxjs/wsx-press 0.0.22 → 0.0.24
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/client.cjs +1 -1
- package/dist/client.js +521 -501
- package/dist/node.cjs +41 -41
- package/dist/node.js +529 -518
- package/package.json +7 -7
- package/src/client/components/DocPage.wsx +32 -16
- package/src/client/components/DocSidebar.css +98 -3
- package/src/client/components/DocSidebar.wsx +17 -2
- package/src/client/components/DocTOC.wsx +9 -3
- package/src/node/metadata.ts +30 -3
- package/src/types.ts +2 -0
package/dist/node.js
CHANGED
|
@@ -2,63 +2,74 @@ var Te = Object.defineProperty;
|
|
|
2
2
|
var ne = (a) => {
|
|
3
3
|
throw TypeError(a);
|
|
4
4
|
};
|
|
5
|
-
var ze = (a,
|
|
6
|
-
var k = (a,
|
|
7
|
-
var se = (a,
|
|
8
|
-
var v = (a,
|
|
5
|
+
var ze = (a, n, e) => n in a ? Te(a, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[n] = e;
|
|
6
|
+
var k = (a, n, e) => ze(a, typeof n != "symbol" ? n + "" : n, e), Re = (a, n, e) => n.has(a) || ne("Cannot " + e);
|
|
7
|
+
var se = (a, n, e) => n.has(a) ? ne("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(a) : n.set(a, e);
|
|
8
|
+
var v = (a, n, e) => (Re(a, n, "access private method"), e);
|
|
9
9
|
import { glob as Se } from "glob";
|
|
10
10
|
import x from "path";
|
|
11
11
|
import m from "fs-extra";
|
|
12
|
-
import { Application as _e, TSConfigReader as
|
|
13
|
-
import { c as
|
|
12
|
+
import { Application as _e, TSConfigReader as Ae, TypeDocReader as Ie } from "typedoc";
|
|
13
|
+
import { c as Ee } from "./index-RqS0LFTH.js";
|
|
14
14
|
async function O(a) {
|
|
15
|
-
const
|
|
16
|
-
for (const
|
|
17
|
-
const i = x.relative(a,
|
|
15
|
+
const n = await Se("**/*.md", { cwd: a, absolute: !0 }), e = {};
|
|
16
|
+
for (const t of n) {
|
|
17
|
+
const i = x.relative(a, t), r = await m.readFile(t, "utf-8"), s = Ce(r), l = i.replace(/\.md$/, ""), o = x.dirname(i);
|
|
18
18
|
e[l] = {
|
|
19
|
-
title: s.title || x.basename(
|
|
20
|
-
|
|
19
|
+
title: s.title || x.basename(t, ".md"),
|
|
20
|
+
// 优先使用 frontmatter 中的 category,如果没有则使用 dirname
|
|
21
|
+
category: s.category || (o === "." ? "." : o),
|
|
21
22
|
route: `/docs/${l}`,
|
|
22
23
|
...s
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
return
|
|
26
|
+
return je(e);
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
28
|
+
function Ce(a) {
|
|
29
|
+
const n = a.match(/^---\n([\s\S]*?)\n---/);
|
|
30
|
+
if (!n)
|
|
30
31
|
return {};
|
|
31
|
-
const e =
|
|
32
|
+
const e = n[1], t = {};
|
|
32
33
|
return e.split(`
|
|
33
34
|
`).forEach((i) => {
|
|
34
35
|
const r = i.indexOf(":");
|
|
35
36
|
if (r === -1)
|
|
36
37
|
return;
|
|
37
38
|
const s = i.substring(0, r).trim(), l = i.substring(r + 1).trim();
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
if (s && l)
|
|
40
|
+
if (s === "title" || s === "description" || s === "category") {
|
|
41
|
+
let o = l.replace(/^["']|["']$/g, "");
|
|
42
|
+
o.includes("&") && (o = o.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&")), t[s] = o;
|
|
43
|
+
} else if (s === "order") {
|
|
44
|
+
const o = Number.parseInt(l, 10);
|
|
45
|
+
Number.isNaN(o) || (t.order = o);
|
|
46
|
+
} else s === "tags" ? t.tags = l.replace(/[[\]]/g, "").split(",").map((o) => o.trim()) : t[s] = l;
|
|
47
|
+
}), t;
|
|
40
48
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
for (const [e,
|
|
44
|
-
const i =
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
for (const [e,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
function je(a) {
|
|
50
|
+
const n = /* @__PURE__ */ new Map();
|
|
51
|
+
for (const [e, t] of Object.entries(a)) {
|
|
52
|
+
const i = t.category;
|
|
53
|
+
n.has(i) || n.set(i, []), n.get(i).push(e);
|
|
54
|
+
}
|
|
55
|
+
for (const [e, t] of n) {
|
|
56
|
+
t.sort((i, r) => {
|
|
57
|
+
const s = a[i].order ?? Number.MAX_SAFE_INTEGER, l = a[r].order ?? Number.MAX_SAFE_INTEGER;
|
|
58
|
+
return s !== l ? s - l : i.localeCompare(r);
|
|
59
|
+
});
|
|
60
|
+
for (let i = 0; i < t.length; i++) {
|
|
61
|
+
const r = t[i];
|
|
62
|
+
a[r].prev = i > 0 ? `/docs/${t[i - 1]}` : null, a[r].next = i < t.length - 1 ? `/docs/${t[i + 1]}` : null;
|
|
52
63
|
}
|
|
53
64
|
}
|
|
54
65
|
return a;
|
|
55
66
|
}
|
|
56
|
-
async function ie(a,
|
|
67
|
+
async function ie(a, n) {
|
|
57
68
|
const e = [];
|
|
58
|
-
for (const [
|
|
59
|
-
const r = x.join(
|
|
69
|
+
for (const [t, i] of Object.entries(a)) {
|
|
70
|
+
const r = x.join(n, `${t}.md`), l = (await m.readFile(r, "utf-8")).replace(/^---[\s\S]*?---/, "").replace(/```[\s\S]*?```/g, "").replace(/[#*`_[\]()]/g, "").trim();
|
|
60
71
|
e.push({
|
|
61
|
-
id:
|
|
72
|
+
id: t,
|
|
62
73
|
title: i.title,
|
|
63
74
|
category: i.category,
|
|
64
75
|
route: i.route,
|
|
@@ -80,23 +91,23 @@ async function ie(a, t) {
|
|
|
80
91
|
}
|
|
81
92
|
async function Pe(a) {
|
|
82
93
|
const {
|
|
83
|
-
entryPoints:
|
|
94
|
+
entryPoints: n,
|
|
84
95
|
tsconfig: e,
|
|
85
|
-
outputDir:
|
|
96
|
+
outputDir: t,
|
|
86
97
|
excludePrivate: i = !0,
|
|
87
98
|
excludeProtected: r = !1,
|
|
88
99
|
excludeInternal: s = !0,
|
|
89
100
|
publicPath: l = "/api/"
|
|
90
101
|
} = a;
|
|
91
|
-
for (const o of
|
|
102
|
+
for (const o of n)
|
|
92
103
|
if (!await m.pathExists(o))
|
|
93
104
|
throw new Error(`Entry point not found: ${o}`);
|
|
94
105
|
if (!await m.pathExists(e))
|
|
95
106
|
throw new Error(`TypeScript config not found: ${e}`);
|
|
96
|
-
await m.ensureDir(
|
|
107
|
+
await m.ensureDir(t);
|
|
97
108
|
try {
|
|
98
109
|
const o = await _e.bootstrapWithPlugins({
|
|
99
|
-
entryPoints:
|
|
110
|
+
entryPoints: n,
|
|
100
111
|
tsconfig: e,
|
|
101
112
|
plugin: ["typedoc-plugin-markdown"],
|
|
102
113
|
theme: "markdown",
|
|
@@ -107,11 +118,11 @@ async function Pe(a) {
|
|
|
107
118
|
excludeInternal: s,
|
|
108
119
|
publicPath: l
|
|
109
120
|
});
|
|
110
|
-
o.options.addReader(new
|
|
121
|
+
o.options.addReader(new Ae()), o.options.addReader(new Ie());
|
|
111
122
|
const p = await o.convert();
|
|
112
123
|
if (!p)
|
|
113
124
|
throw new Error("Failed to convert TypeScript project");
|
|
114
|
-
await o.generateDocs(p,
|
|
125
|
+
await o.generateDocs(p, t);
|
|
115
126
|
} catch (o) {
|
|
116
127
|
throw new Error(
|
|
117
128
|
`Failed to generate API documentation: ${o instanceof Error ? o.message : String(o)}`
|
|
@@ -132,9 +143,9 @@ function J() {
|
|
|
132
143
|
walkTokens: null
|
|
133
144
|
};
|
|
134
145
|
}
|
|
135
|
-
let
|
|
146
|
+
let A = J();
|
|
136
147
|
function pe(a) {
|
|
137
|
-
|
|
148
|
+
A = a;
|
|
138
149
|
}
|
|
139
150
|
const ue = /[&<>"']/, ve = new RegExp(ue.source, "g"), fe = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, Oe = new RegExp(fe.source, "g"), Le = {
|
|
140
151
|
"&": "&",
|
|
@@ -143,8 +154,8 @@ const ue = /[&<>"']/, ve = new RegExp(ue.source, "g"), fe = /[<>"']|&(?!(#\d{1,7
|
|
|
143
154
|
'"': """,
|
|
144
155
|
"'": "'"
|
|
145
156
|
}, re = (a) => Le[a];
|
|
146
|
-
function b(a,
|
|
147
|
-
if (
|
|
157
|
+
function b(a, n) {
|
|
158
|
+
if (n) {
|
|
148
159
|
if (ue.test(a))
|
|
149
160
|
return a.replace(ve, re);
|
|
150
161
|
} else if (fe.test(a))
|
|
@@ -152,21 +163,21 @@ function b(a, t) {
|
|
|
152
163
|
return a;
|
|
153
164
|
}
|
|
154
165
|
const De = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
155
|
-
function
|
|
156
|
-
return a.replace(De, (
|
|
166
|
+
function Ne(a) {
|
|
167
|
+
return a.replace(De, (n, 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)) : ""));
|
|
157
168
|
}
|
|
158
|
-
const
|
|
159
|
-
function d(a,
|
|
169
|
+
const Ze = /(^|[^\[])\^/g;
|
|
170
|
+
function d(a, n) {
|
|
160
171
|
let e = typeof a == "string" ? a : a.source;
|
|
161
|
-
|
|
162
|
-
const
|
|
172
|
+
n = n || "";
|
|
173
|
+
const t = {
|
|
163
174
|
replace: (i, r) => {
|
|
164
175
|
let s = typeof r == "string" ? r : r.source;
|
|
165
|
-
return s = s.replace(
|
|
176
|
+
return s = s.replace(Ze, "$1"), e = e.replace(i, s), t;
|
|
166
177
|
},
|
|
167
|
-
getRegex: () => new RegExp(e,
|
|
178
|
+
getRegex: () => new RegExp(e, n)
|
|
168
179
|
};
|
|
169
|
-
return
|
|
180
|
+
return t;
|
|
170
181
|
}
|
|
171
182
|
function oe(a) {
|
|
172
183
|
try {
|
|
@@ -176,60 +187,60 @@ function oe(a) {
|
|
|
176
187
|
}
|
|
177
188
|
return a;
|
|
178
189
|
}
|
|
179
|
-
const
|
|
180
|
-
function le(a,
|
|
190
|
+
const E = { exec: () => null };
|
|
191
|
+
function le(a, n) {
|
|
181
192
|
const e = a.replace(/\|/g, (r, s, l) => {
|
|
182
193
|
let o = !1, p = s;
|
|
183
194
|
for (; --p >= 0 && l[p] === "\\"; )
|
|
184
195
|
o = !o;
|
|
185
196
|
return o ? "|" : " |";
|
|
186
|
-
}),
|
|
197
|
+
}), t = e.split(/ \|/);
|
|
187
198
|
let i = 0;
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
|
|
199
|
+
if (t[0].trim() || t.shift(), t.length > 0 && !t[t.length - 1].trim() && t.pop(), n)
|
|
200
|
+
if (t.length > n)
|
|
201
|
+
t.splice(n);
|
|
191
202
|
else
|
|
192
|
-
for (;
|
|
193
|
-
|
|
194
|
-
for (; i <
|
|
195
|
-
|
|
196
|
-
return
|
|
203
|
+
for (; t.length < n; )
|
|
204
|
+
t.push("");
|
|
205
|
+
for (; i < t.length; i++)
|
|
206
|
+
t[i] = t[i].trim().replace(/\\\|/g, "|");
|
|
207
|
+
return t;
|
|
197
208
|
}
|
|
198
|
-
function L(a,
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
209
|
+
function L(a, n, e) {
|
|
210
|
+
const t = a.length;
|
|
211
|
+
if (t === 0)
|
|
201
212
|
return "";
|
|
202
213
|
let i = 0;
|
|
203
|
-
for (; i <
|
|
214
|
+
for (; i < t && a.charAt(t - i - 1) === n; )
|
|
204
215
|
i++;
|
|
205
|
-
return a.slice(0,
|
|
216
|
+
return a.slice(0, t - i);
|
|
206
217
|
}
|
|
207
|
-
function
|
|
208
|
-
if (a.indexOf(
|
|
218
|
+
function qe(a, n) {
|
|
219
|
+
if (a.indexOf(n[1]) === -1)
|
|
209
220
|
return -1;
|
|
210
221
|
let e = 0;
|
|
211
|
-
for (let
|
|
212
|
-
if (a[
|
|
213
|
-
|
|
214
|
-
else if (a[
|
|
222
|
+
for (let t = 0; t < a.length; t++)
|
|
223
|
+
if (a[t] === "\\")
|
|
224
|
+
t++;
|
|
225
|
+
else if (a[t] === n[0])
|
|
215
226
|
e++;
|
|
216
|
-
else if (a[
|
|
217
|
-
return
|
|
227
|
+
else if (a[t] === n[1] && (e--, e < 0))
|
|
228
|
+
return t;
|
|
218
229
|
return -1;
|
|
219
230
|
}
|
|
220
|
-
function ae(a,
|
|
221
|
-
const i =
|
|
231
|
+
function ae(a, n, e, t) {
|
|
232
|
+
const i = n.href, r = n.title ? b(n.title) : null, s = a[1].replace(/\\([\[\]])/g, "$1");
|
|
222
233
|
if (a[0].charAt(0) !== "!") {
|
|
223
|
-
|
|
234
|
+
t.state.inLink = !0;
|
|
224
235
|
const l = {
|
|
225
236
|
type: "link",
|
|
226
237
|
raw: e,
|
|
227
238
|
href: i,
|
|
228
239
|
title: r,
|
|
229
240
|
text: s,
|
|
230
|
-
tokens:
|
|
241
|
+
tokens: t.inlineTokens(s)
|
|
231
242
|
};
|
|
232
|
-
return
|
|
243
|
+
return t.state.inLink = !1, l;
|
|
233
244
|
}
|
|
234
245
|
return {
|
|
235
246
|
type: "image",
|
|
@@ -239,138 +250,138 @@ function ae(a, t, e, n) {
|
|
|
239
250
|
text: b(s)
|
|
240
251
|
};
|
|
241
252
|
}
|
|
242
|
-
function
|
|
253
|
+
function Be(a, n) {
|
|
243
254
|
const e = a.match(/^(\s+)(?:```)/);
|
|
244
255
|
if (e === null)
|
|
245
|
-
return
|
|
246
|
-
const
|
|
247
|
-
return
|
|
256
|
+
return n;
|
|
257
|
+
const t = e[1];
|
|
258
|
+
return n.split(`
|
|
248
259
|
`).map((i) => {
|
|
249
260
|
const r = i.match(/^\s+/);
|
|
250
261
|
if (r === null)
|
|
251
262
|
return i;
|
|
252
263
|
const [s] = r;
|
|
253
|
-
return s.length >=
|
|
264
|
+
return s.length >= t.length ? i.slice(t.length) : i;
|
|
254
265
|
}).join(`
|
|
255
266
|
`);
|
|
256
267
|
}
|
|
257
|
-
class
|
|
268
|
+
class N {
|
|
258
269
|
// set by the lexer
|
|
259
|
-
constructor(
|
|
270
|
+
constructor(n) {
|
|
260
271
|
k(this, "options");
|
|
261
272
|
k(this, "rules");
|
|
262
273
|
// set by the lexer
|
|
263
274
|
k(this, "lexer");
|
|
264
|
-
this.options =
|
|
275
|
+
this.options = n || A;
|
|
265
276
|
}
|
|
266
|
-
space(
|
|
267
|
-
const e = this.rules.block.newline.exec(
|
|
277
|
+
space(n) {
|
|
278
|
+
const e = this.rules.block.newline.exec(n);
|
|
268
279
|
if (e && e[0].length > 0)
|
|
269
280
|
return {
|
|
270
281
|
type: "space",
|
|
271
282
|
raw: e[0]
|
|
272
283
|
};
|
|
273
284
|
}
|
|
274
|
-
code(
|
|
275
|
-
const e = this.rules.block.code.exec(
|
|
285
|
+
code(n) {
|
|
286
|
+
const e = this.rules.block.code.exec(n);
|
|
276
287
|
if (e) {
|
|
277
|
-
const
|
|
288
|
+
const t = e[0].replace(/^ {1,4}/gm, "");
|
|
278
289
|
return {
|
|
279
290
|
type: "code",
|
|
280
291
|
raw: e[0],
|
|
281
292
|
codeBlockStyle: "indented",
|
|
282
|
-
text: this.options.pedantic ?
|
|
293
|
+
text: this.options.pedantic ? t : L(t, `
|
|
283
294
|
`)
|
|
284
295
|
};
|
|
285
296
|
}
|
|
286
297
|
}
|
|
287
|
-
fences(
|
|
288
|
-
const e = this.rules.block.fences.exec(
|
|
298
|
+
fences(n) {
|
|
299
|
+
const e = this.rules.block.fences.exec(n);
|
|
289
300
|
if (e) {
|
|
290
|
-
const
|
|
301
|
+
const t = e[0], i = Be(t, e[3] || "");
|
|
291
302
|
return {
|
|
292
303
|
type: "code",
|
|
293
|
-
raw:
|
|
304
|
+
raw: t,
|
|
294
305
|
lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
|
|
295
306
|
text: i
|
|
296
307
|
};
|
|
297
308
|
}
|
|
298
309
|
}
|
|
299
|
-
heading(
|
|
300
|
-
const e = this.rules.block.heading.exec(
|
|
310
|
+
heading(n) {
|
|
311
|
+
const e = this.rules.block.heading.exec(n);
|
|
301
312
|
if (e) {
|
|
302
|
-
let
|
|
303
|
-
if (/#$/.test(
|
|
304
|
-
const i = L(
|
|
305
|
-
(this.options.pedantic || !i || / $/.test(i)) && (
|
|
313
|
+
let t = e[2].trim();
|
|
314
|
+
if (/#$/.test(t)) {
|
|
315
|
+
const i = L(t, "#");
|
|
316
|
+
(this.options.pedantic || !i || / $/.test(i)) && (t = i.trim());
|
|
306
317
|
}
|
|
307
318
|
return {
|
|
308
319
|
type: "heading",
|
|
309
320
|
raw: e[0],
|
|
310
321
|
depth: e[1].length,
|
|
311
|
-
text:
|
|
312
|
-
tokens: this.lexer.inline(
|
|
322
|
+
text: t,
|
|
323
|
+
tokens: this.lexer.inline(t)
|
|
313
324
|
};
|
|
314
325
|
}
|
|
315
326
|
}
|
|
316
|
-
hr(
|
|
317
|
-
const e = this.rules.block.hr.exec(
|
|
327
|
+
hr(n) {
|
|
328
|
+
const e = this.rules.block.hr.exec(n);
|
|
318
329
|
if (e)
|
|
319
330
|
return {
|
|
320
331
|
type: "hr",
|
|
321
332
|
raw: e[0]
|
|
322
333
|
};
|
|
323
334
|
}
|
|
324
|
-
blockquote(
|
|
325
|
-
const e = this.rules.block.blockquote.exec(
|
|
335
|
+
blockquote(n) {
|
|
336
|
+
const e = this.rules.block.blockquote.exec(n);
|
|
326
337
|
if (e) {
|
|
327
|
-
let
|
|
338
|
+
let t = e[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, `
|
|
328
339
|
$1`);
|
|
329
|
-
|
|
340
|
+
t = L(t.replace(/^ *>[ \t]?/gm, ""), `
|
|
330
341
|
`);
|
|
331
342
|
const i = this.lexer.state.top;
|
|
332
343
|
this.lexer.state.top = !0;
|
|
333
|
-
const r = this.lexer.blockTokens(
|
|
344
|
+
const r = this.lexer.blockTokens(t);
|
|
334
345
|
return this.lexer.state.top = i, {
|
|
335
346
|
type: "blockquote",
|
|
336
347
|
raw: e[0],
|
|
337
348
|
tokens: r,
|
|
338
|
-
text:
|
|
349
|
+
text: t
|
|
339
350
|
};
|
|
340
351
|
}
|
|
341
352
|
}
|
|
342
|
-
list(
|
|
343
|
-
let e = this.rules.block.list.exec(
|
|
353
|
+
list(n) {
|
|
354
|
+
let e = this.rules.block.list.exec(n);
|
|
344
355
|
if (e) {
|
|
345
|
-
let
|
|
346
|
-
const i =
|
|
356
|
+
let t = e[1].trim();
|
|
357
|
+
const i = t.length > 1, r = {
|
|
347
358
|
type: "list",
|
|
348
359
|
raw: "",
|
|
349
360
|
ordered: i,
|
|
350
|
-
start: i ? +
|
|
361
|
+
start: i ? +t.slice(0, -1) : "",
|
|
351
362
|
loose: !1,
|
|
352
363
|
items: []
|
|
353
364
|
};
|
|
354
|
-
|
|
355
|
-
const s = new RegExp(`^( {0,3}${
|
|
365
|
+
t = i ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = i ? t : "[*+-]");
|
|
366
|
+
const s = new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
356
367
|
let l = "", o = "", p = !1;
|
|
357
|
-
for (;
|
|
368
|
+
for (; n; ) {
|
|
358
369
|
let c = !1;
|
|
359
|
-
if (!(e = s.exec(
|
|
370
|
+
if (!(e = s.exec(n)) || this.rules.block.hr.test(n))
|
|
360
371
|
break;
|
|
361
|
-
l = e[0],
|
|
372
|
+
l = e[0], n = n.substring(l.length);
|
|
362
373
|
let u = e[2].split(`
|
|
363
|
-
`, 1)[0].replace(/^\t+/, (
|
|
374
|
+
`, 1)[0].replace(/^\t+/, (M) => " ".repeat(3 * M.length)), h = n.split(`
|
|
364
375
|
`, 1)[0], f = 0;
|
|
365
376
|
this.options.pedantic ? (f = 2, o = u.trimStart()) : (f = e[2].search(/[^ ]/), f = f > 4 ? 1 : f, o = u.slice(f), f += e[1].length);
|
|
366
377
|
let w = !1;
|
|
367
378
|
if (!u && /^ *$/.test(h) && (l += h + `
|
|
368
|
-
`,
|
|
369
|
-
const
|
|
370
|
-
for (;
|
|
371
|
-
const F =
|
|
379
|
+
`, n = n.substring(h.length + 1), c = !0), !c) {
|
|
380
|
+
const M = new RegExp(`^ {0,${Math.min(3, f - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), Y = new RegExp(`^ {0,${Math.min(3, f - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), ee = new RegExp(`^ {0,${Math.min(3, f - 1)}}(?:\`\`\`|~~~)`), te = new RegExp(`^ {0,${Math.min(3, f - 1)}}#`);
|
|
381
|
+
for (; n; ) {
|
|
382
|
+
const F = n.split(`
|
|
372
383
|
`, 1)[0];
|
|
373
|
-
if (h = F, this.options.pedantic && (h = h.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), ee.test(h) || te.test(h) ||
|
|
384
|
+
if (h = F, this.options.pedantic && (h = h.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), ee.test(h) || te.test(h) || M.test(h) || Y.test(n))
|
|
374
385
|
break;
|
|
375
386
|
if (h.search(/[^ ]/) >= f || !h.trim())
|
|
376
387
|
o += `
|
|
@@ -382,7 +393,7 @@ class Z {
|
|
|
382
393
|
` + h;
|
|
383
394
|
}
|
|
384
395
|
!w && !h.trim() && (w = !0), l += F + `
|
|
385
|
-
`,
|
|
396
|
+
`, n = n.substring(F.length + 1), u = h.slice(f);
|
|
386
397
|
}
|
|
387
398
|
}
|
|
388
399
|
r.loose || (p ? r.loose = !0 : /\n *\n *$/.test(l) && (p = !0));
|
|
@@ -409,8 +420,8 @@ class Z {
|
|
|
409
420
|
return r;
|
|
410
421
|
}
|
|
411
422
|
}
|
|
412
|
-
html(
|
|
413
|
-
const e = this.rules.block.html.exec(
|
|
423
|
+
html(n) {
|
|
424
|
+
const e = this.rules.block.html.exec(n);
|
|
414
425
|
if (e)
|
|
415
426
|
return {
|
|
416
427
|
type: "html",
|
|
@@ -420,24 +431,24 @@ class Z {
|
|
|
420
431
|
text: e[0]
|
|
421
432
|
};
|
|
422
433
|
}
|
|
423
|
-
def(
|
|
424
|
-
const e = this.rules.block.def.exec(
|
|
434
|
+
def(n) {
|
|
435
|
+
const e = this.rules.block.def.exec(n);
|
|
425
436
|
if (e) {
|
|
426
|
-
const
|
|
437
|
+
const t = e[1].toLowerCase().replace(/\s+/g, " "), i = e[2] ? e[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
|
|
427
438
|
return {
|
|
428
439
|
type: "def",
|
|
429
|
-
tag:
|
|
440
|
+
tag: t,
|
|
430
441
|
raw: e[0],
|
|
431
442
|
href: i,
|
|
432
443
|
title: r
|
|
433
444
|
};
|
|
434
445
|
}
|
|
435
446
|
}
|
|
436
|
-
table(
|
|
437
|
-
const e = this.rules.block.table.exec(
|
|
447
|
+
table(n) {
|
|
448
|
+
const e = this.rules.block.table.exec(n);
|
|
438
449
|
if (!e || !/[:|]/.test(e[2]))
|
|
439
450
|
return;
|
|
440
|
-
const
|
|
451
|
+
const t = le(e[1]), i = e[2].replace(/^\||\| *$/g, "").split("|"), r = e[3] && e[3].trim() ? e[3].replace(/\n[ \t]*$/, "").split(`
|
|
441
452
|
`) : [], s = {
|
|
442
453
|
type: "table",
|
|
443
454
|
raw: e[0],
|
|
@@ -445,10 +456,10 @@ class Z {
|
|
|
445
456
|
align: [],
|
|
446
457
|
rows: []
|
|
447
458
|
};
|
|
448
|
-
if (
|
|
459
|
+
if (t.length === i.length) {
|
|
449
460
|
for (const l of i)
|
|
450
461
|
/^ *-+: *$/.test(l) ? s.align.push("right") : /^ *:-+: *$/.test(l) ? s.align.push("center") : /^ *:-+ *$/.test(l) ? s.align.push("left") : s.align.push(null);
|
|
451
|
-
for (const l of
|
|
462
|
+
for (const l of t)
|
|
452
463
|
s.header.push({
|
|
453
464
|
text: l,
|
|
454
465
|
tokens: this.lexer.inline(l)
|
|
@@ -461,8 +472,8 @@ class Z {
|
|
|
461
472
|
return s;
|
|
462
473
|
}
|
|
463
474
|
}
|
|
464
|
-
lheading(
|
|
465
|
-
const e = this.rules.block.lheading.exec(
|
|
475
|
+
lheading(n) {
|
|
476
|
+
const e = this.rules.block.lheading.exec(n);
|
|
466
477
|
if (e)
|
|
467
478
|
return {
|
|
468
479
|
type: "heading",
|
|
@@ -472,21 +483,21 @@ class Z {
|
|
|
472
483
|
tokens: this.lexer.inline(e[1])
|
|
473
484
|
};
|
|
474
485
|
}
|
|
475
|
-
paragraph(
|
|
476
|
-
const e = this.rules.block.paragraph.exec(
|
|
486
|
+
paragraph(n) {
|
|
487
|
+
const e = this.rules.block.paragraph.exec(n);
|
|
477
488
|
if (e) {
|
|
478
|
-
const
|
|
489
|
+
const t = e[1].charAt(e[1].length - 1) === `
|
|
479
490
|
` ? e[1].slice(0, -1) : e[1];
|
|
480
491
|
return {
|
|
481
492
|
type: "paragraph",
|
|
482
493
|
raw: e[0],
|
|
483
|
-
text:
|
|
484
|
-
tokens: this.lexer.inline(
|
|
494
|
+
text: t,
|
|
495
|
+
tokens: this.lexer.inline(t)
|
|
485
496
|
};
|
|
486
497
|
}
|
|
487
498
|
}
|
|
488
|
-
text(
|
|
489
|
-
const e = this.rules.block.text.exec(
|
|
499
|
+
text(n) {
|
|
500
|
+
const e = this.rules.block.text.exec(n);
|
|
490
501
|
if (e)
|
|
491
502
|
return {
|
|
492
503
|
type: "text",
|
|
@@ -495,8 +506,8 @@ class Z {
|
|
|
495
506
|
tokens: this.lexer.inline(e[0])
|
|
496
507
|
};
|
|
497
508
|
}
|
|
498
|
-
escape(
|
|
499
|
-
const e = this.rules.inline.escape.exec(
|
|
509
|
+
escape(n) {
|
|
510
|
+
const e = this.rules.inline.escape.exec(n);
|
|
500
511
|
if (e)
|
|
501
512
|
return {
|
|
502
513
|
type: "escape",
|
|
@@ -504,8 +515,8 @@ class Z {
|
|
|
504
515
|
text: b(e[1])
|
|
505
516
|
};
|
|
506
517
|
}
|
|
507
|
-
tag(
|
|
508
|
-
const e = this.rules.inline.tag.exec(
|
|
518
|
+
tag(n) {
|
|
519
|
+
const e = this.rules.inline.tag.exec(n);
|
|
509
520
|
if (e)
|
|
510
521
|
return !this.lexer.state.inLink && /^<a /i.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && /^<\/a>/i.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(e[0]) && (this.lexer.state.inRawBlock = !1), {
|
|
511
522
|
type: "html",
|
|
@@ -516,18 +527,18 @@ class Z {
|
|
|
516
527
|
text: e[0]
|
|
517
528
|
};
|
|
518
529
|
}
|
|
519
|
-
link(
|
|
520
|
-
const e = this.rules.inline.link.exec(
|
|
530
|
+
link(n) {
|
|
531
|
+
const e = this.rules.inline.link.exec(n);
|
|
521
532
|
if (e) {
|
|
522
|
-
const
|
|
523
|
-
if (!this.options.pedantic && /^</.test(
|
|
524
|
-
if (!/>$/.test(
|
|
533
|
+
const t = e[2].trim();
|
|
534
|
+
if (!this.options.pedantic && /^</.test(t)) {
|
|
535
|
+
if (!/>$/.test(t))
|
|
525
536
|
return;
|
|
526
|
-
const s = L(
|
|
527
|
-
if ((
|
|
537
|
+
const s = L(t.slice(0, -1), "\\");
|
|
538
|
+
if ((t.length - s.length) % 2 === 0)
|
|
528
539
|
return;
|
|
529
540
|
} else {
|
|
530
|
-
const s =
|
|
541
|
+
const s = qe(e[2], "()");
|
|
531
542
|
if (s > -1) {
|
|
532
543
|
const o = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + s;
|
|
533
544
|
e[2] = e[2].substring(0, s), e[0] = e[0].substring(0, o).trim(), e[3] = "";
|
|
@@ -539,36 +550,36 @@ class Z {
|
|
|
539
550
|
s && (i = s[1], r = s[3]);
|
|
540
551
|
} else
|
|
541
552
|
r = e[3] ? e[3].slice(1, -1) : "";
|
|
542
|
-
return i = i.trim(), /^</.test(i) && (this.options.pedantic && !/>$/.test(
|
|
553
|
+
return i = i.trim(), /^</.test(i) && (this.options.pedantic && !/>$/.test(t) ? i = i.slice(1) : i = i.slice(1, -1)), ae(e, {
|
|
543
554
|
href: i && i.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
544
555
|
title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
|
|
545
556
|
}, e[0], this.lexer);
|
|
546
557
|
}
|
|
547
558
|
}
|
|
548
|
-
reflink(
|
|
549
|
-
let
|
|
550
|
-
if ((
|
|
551
|
-
const i = (
|
|
559
|
+
reflink(n, e) {
|
|
560
|
+
let t;
|
|
561
|
+
if ((t = this.rules.inline.reflink.exec(n)) || (t = this.rules.inline.nolink.exec(n))) {
|
|
562
|
+
const i = (t[2] || t[1]).replace(/\s+/g, " "), r = e[i.toLowerCase()];
|
|
552
563
|
if (!r) {
|
|
553
|
-
const s =
|
|
564
|
+
const s = t[0].charAt(0);
|
|
554
565
|
return {
|
|
555
566
|
type: "text",
|
|
556
567
|
raw: s,
|
|
557
568
|
text: s
|
|
558
569
|
};
|
|
559
570
|
}
|
|
560
|
-
return ae(
|
|
571
|
+
return ae(t, r, t[0], this.lexer);
|
|
561
572
|
}
|
|
562
573
|
}
|
|
563
|
-
emStrong(
|
|
564
|
-
let i = this.rules.inline.emStrongLDelim.exec(
|
|
565
|
-
if (!i || i[3] &&
|
|
574
|
+
emStrong(n, e, t = "") {
|
|
575
|
+
let i = this.rules.inline.emStrongLDelim.exec(n);
|
|
576
|
+
if (!i || i[3] && t.match(/[\p{L}\p{N}]/u))
|
|
566
577
|
return;
|
|
567
|
-
if (!(i[1] || i[2] || "") || !
|
|
578
|
+
if (!(i[1] || i[2] || "") || !t || this.rules.inline.punctuation.exec(t)) {
|
|
568
579
|
const s = [...i[0]].length - 1;
|
|
569
580
|
let l, o, p = s, c = 0;
|
|
570
581
|
const u = i[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
571
|
-
for (u.lastIndex = 0, e = e.slice(-1 *
|
|
582
|
+
for (u.lastIndex = 0, e = e.slice(-1 * n.length + s); (i = u.exec(e)) != null; ) {
|
|
572
583
|
if (l = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !l)
|
|
573
584
|
continue;
|
|
574
585
|
if (o = [...l].length, i[3] || i[4]) {
|
|
@@ -581,7 +592,7 @@ class Z {
|
|
|
581
592
|
if (p -= o, p > 0)
|
|
582
593
|
continue;
|
|
583
594
|
o = Math.min(o, o + p + c);
|
|
584
|
-
const h = [...i[0]][0].length, f =
|
|
595
|
+
const h = [...i[0]][0].length, f = n.slice(0, s + i.index + h + o);
|
|
585
596
|
if (Math.min(s, o) % 2) {
|
|
586
597
|
const y = f.slice(1, -1);
|
|
587
598
|
return {
|
|
@@ -601,28 +612,28 @@ class Z {
|
|
|
601
612
|
}
|
|
602
613
|
}
|
|
603
614
|
}
|
|
604
|
-
codespan(
|
|
605
|
-
const e = this.rules.inline.code.exec(
|
|
615
|
+
codespan(n) {
|
|
616
|
+
const e = this.rules.inline.code.exec(n);
|
|
606
617
|
if (e) {
|
|
607
|
-
let
|
|
608
|
-
const i = /[^ ]/.test(
|
|
609
|
-
return i && r && (
|
|
618
|
+
let t = e[2].replace(/\n/g, " ");
|
|
619
|
+
const i = /[^ ]/.test(t), r = /^ /.test(t) && / $/.test(t);
|
|
620
|
+
return i && r && (t = t.substring(1, t.length - 1)), t = b(t, !0), {
|
|
610
621
|
type: "codespan",
|
|
611
622
|
raw: e[0],
|
|
612
|
-
text:
|
|
623
|
+
text: t
|
|
613
624
|
};
|
|
614
625
|
}
|
|
615
626
|
}
|
|
616
|
-
br(
|
|
617
|
-
const e = this.rules.inline.br.exec(
|
|
627
|
+
br(n) {
|
|
628
|
+
const e = this.rules.inline.br.exec(n);
|
|
618
629
|
if (e)
|
|
619
630
|
return {
|
|
620
631
|
type: "br",
|
|
621
632
|
raw: e[0]
|
|
622
633
|
};
|
|
623
634
|
}
|
|
624
|
-
del(
|
|
625
|
-
const e = this.rules.inline.del.exec(
|
|
635
|
+
del(n) {
|
|
636
|
+
const e = this.rules.inline.del.exec(n);
|
|
626
637
|
if (e)
|
|
627
638
|
return {
|
|
628
639
|
type: "del",
|
|
@@ -631,36 +642,36 @@ class Z {
|
|
|
631
642
|
tokens: this.lexer.inlineTokens(e[2])
|
|
632
643
|
};
|
|
633
644
|
}
|
|
634
|
-
autolink(
|
|
635
|
-
const e = this.rules.inline.autolink.exec(
|
|
645
|
+
autolink(n) {
|
|
646
|
+
const e = this.rules.inline.autolink.exec(n);
|
|
636
647
|
if (e) {
|
|
637
|
-
let
|
|
638
|
-
return e[2] === "@" ? (
|
|
648
|
+
let t, i;
|
|
649
|
+
return e[2] === "@" ? (t = b(e[1]), i = "mailto:" + t) : (t = b(e[1]), i = t), {
|
|
639
650
|
type: "link",
|
|
640
651
|
raw: e[0],
|
|
641
|
-
text:
|
|
652
|
+
text: t,
|
|
642
653
|
href: i,
|
|
643
654
|
tokens: [
|
|
644
655
|
{
|
|
645
656
|
type: "text",
|
|
646
|
-
raw:
|
|
647
|
-
text:
|
|
657
|
+
raw: t,
|
|
658
|
+
text: t
|
|
648
659
|
}
|
|
649
660
|
]
|
|
650
661
|
};
|
|
651
662
|
}
|
|
652
663
|
}
|
|
653
|
-
url(
|
|
654
|
-
var
|
|
664
|
+
url(n) {
|
|
665
|
+
var t;
|
|
655
666
|
let e;
|
|
656
|
-
if (e = this.rules.inline.url.exec(
|
|
667
|
+
if (e = this.rules.inline.url.exec(n)) {
|
|
657
668
|
let i, r;
|
|
658
669
|
if (e[2] === "@")
|
|
659
670
|
i = b(e[0]), r = "mailto:" + i;
|
|
660
671
|
else {
|
|
661
672
|
let s;
|
|
662
673
|
do
|
|
663
|
-
s = e[0], e[0] = ((
|
|
674
|
+
s = e[0], e[0] = ((t = this.rules.inline._backpedal.exec(e[0])) == null ? void 0 : t[0]) ?? "";
|
|
664
675
|
while (s !== e[0]);
|
|
665
676
|
i = b(e[0]), e[1] === "www." ? r = "http://" + e[0] : r = e[0];
|
|
666
677
|
}
|
|
@@ -679,55 +690,55 @@ class Z {
|
|
|
679
690
|
};
|
|
680
691
|
}
|
|
681
692
|
}
|
|
682
|
-
inlineText(
|
|
683
|
-
const e = this.rules.inline.text.exec(
|
|
693
|
+
inlineText(n) {
|
|
694
|
+
const e = this.rules.inline.text.exec(n);
|
|
684
695
|
if (e) {
|
|
685
|
-
let
|
|
686
|
-
return this.lexer.state.inRawBlock ?
|
|
696
|
+
let t;
|
|
697
|
+
return this.lexer.state.inRawBlock ? t = e[0] : t = b(e[0]), {
|
|
687
698
|
type: "text",
|
|
688
699
|
raw: e[0],
|
|
689
|
-
text:
|
|
700
|
+
text: t
|
|
690
701
|
};
|
|
691
702
|
}
|
|
692
703
|
}
|
|
693
704
|
}
|
|
694
|
-
const
|
|
705
|
+
const Me = /^(?: *(?:\n|$))+/, Fe = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Qe = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, j = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, He = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, ge = /(?:[*+-]|\d{1,9}[.)])/, de = d(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, ge).replace(/blockCode/g, / {4}/).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/).getRegex(), W = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Je = /^[^\n]+/, G = /(?!\s*\])(?:\\.|[^\[\]\\])+/, We = d(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", G).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Ge = d(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, ge).getRegex(), B = "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", U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Ue = 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", U).replace("tag", B).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), ke = d(W).replace("hr", j).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", B).getRegex(), Xe = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ke).getRegex(), X = {
|
|
695
706
|
blockquote: Xe,
|
|
696
707
|
code: Fe,
|
|
697
708
|
def: We,
|
|
698
709
|
fences: Qe,
|
|
699
710
|
heading: He,
|
|
700
|
-
hr:
|
|
711
|
+
hr: j,
|
|
701
712
|
html: Ue,
|
|
702
713
|
lheading: de,
|
|
703
714
|
list: Ge,
|
|
704
|
-
newline:
|
|
715
|
+
newline: Me,
|
|
705
716
|
paragraph: ke,
|
|
706
|
-
table:
|
|
717
|
+
table: E,
|
|
707
718
|
text: Je
|
|
708
|
-
}, ce = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",
|
|
719
|
+
}, ce = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", j).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\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", B).getRegex(), Ve = {
|
|
709
720
|
...X,
|
|
710
721
|
table: ce,
|
|
711
|
-
paragraph: d(W).replace("hr",
|
|
712
|
-
},
|
|
722
|
+
paragraph: d(W).replace("hr", j).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ce).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", B).getRegex()
|
|
723
|
+
}, Ke = {
|
|
713
724
|
...X,
|
|
714
725
|
html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).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(),
|
|
715
726
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
716
727
|
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
717
|
-
fences:
|
|
728
|
+
fences: E,
|
|
718
729
|
// fences not supported
|
|
719
730
|
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
720
|
-
paragraph: d(W).replace("hr",
|
|
731
|
+
paragraph: d(W).replace("hr", j).replace("heading", ` *#{1,6} *[^
|
|
721
732
|
]`).replace("lheading", de).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
722
|
-
}, xe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ye = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, me = /^( {2,}|\\)\n(?!\s*$)/, et = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, P = "\\p{P}\\p{S}", tt = d(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, P).getRegex(), nt = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, st = d(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, P).getRegex(), it = d("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, P).getRegex(), rt = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, P).getRegex(), ot = d(/\\([punct])/, "gu").replace(/punct/g, P).getRegex(), lt = 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(), at = d(U).replace("(?:-->|$)", "-->").getRegex(), ct = 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", at).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),
|
|
723
|
-
_backpedal:
|
|
733
|
+
}, xe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ye = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, me = /^( {2,}|\\)\n(?!\s*$)/, et = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, P = "\\p{P}\\p{S}", tt = d(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, P).getRegex(), nt = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, st = d(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, P).getRegex(), it = d("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, P).getRegex(), rt = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, P).getRegex(), ot = d(/\\([punct])/, "gu").replace(/punct/g, P).getRegex(), lt = 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(), at = d(U).replace("(?:-->|$)", "-->").getRegex(), ct = 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", at).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Z = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, ht = d(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Z).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), we = d(/^!?\[(label)\]\[(ref)\]/).replace("label", Z).replace("ref", G).getRegex(), be = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", G).getRegex(), pt = d("reflink|nolink(?!\\()", "g").replace("reflink", we).replace("nolink", be).getRegex(), V = {
|
|
734
|
+
_backpedal: E,
|
|
724
735
|
// only used for GFM url
|
|
725
736
|
anyPunctuation: ot,
|
|
726
737
|
autolink: lt,
|
|
727
738
|
blockSkip: nt,
|
|
728
739
|
br: me,
|
|
729
740
|
code: Ye,
|
|
730
|
-
del:
|
|
741
|
+
del: E,
|
|
731
742
|
emStrongLDelim: st,
|
|
732
743
|
emStrongRDelimAst: it,
|
|
733
744
|
emStrongRDelimUnd: rt,
|
|
@@ -739,13 +750,13 @@ const Ne = /^(?: *(?:\n|$))+/, Fe = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Qe =
|
|
|
739
750
|
reflinkSearch: pt,
|
|
740
751
|
tag: ct,
|
|
741
752
|
text: et,
|
|
742
|
-
url:
|
|
753
|
+
url: E
|
|
743
754
|
}, ut = {
|
|
744
|
-
...
|
|
745
|
-
link: d(/^!?\[(label)\]\((.*?)\)/).replace("label",
|
|
746
|
-
reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",
|
|
755
|
+
...V,
|
|
756
|
+
link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", Z).getRegex(),
|
|
757
|
+
reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Z).getRegex()
|
|
747
758
|
}, Q = {
|
|
748
|
-
...
|
|
759
|
+
...V,
|
|
749
760
|
escape: d(xe).replace("])", "~|])").getRegex(),
|
|
750
761
|
url: d(/^((?: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(),
|
|
751
762
|
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
@@ -757,31 +768,31 @@ const Ne = /^(?: *(?:\n|$))+/, Fe = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Qe =
|
|
|
757
768
|
text: d(Q.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
758
769
|
}, D = {
|
|
759
770
|
normal: X,
|
|
760
|
-
gfm:
|
|
761
|
-
pedantic:
|
|
762
|
-
},
|
|
763
|
-
normal:
|
|
771
|
+
gfm: Ve,
|
|
772
|
+
pedantic: Ke
|
|
773
|
+
}, I = {
|
|
774
|
+
normal: V,
|
|
764
775
|
gfm: Q,
|
|
765
776
|
breaks: ft,
|
|
766
777
|
pedantic: ut
|
|
767
778
|
};
|
|
768
779
|
class T {
|
|
769
|
-
constructor(
|
|
780
|
+
constructor(n) {
|
|
770
781
|
k(this, "tokens");
|
|
771
782
|
k(this, "options");
|
|
772
783
|
k(this, "state");
|
|
773
784
|
k(this, "tokenizer");
|
|
774
785
|
k(this, "inlineQueue");
|
|
775
|
-
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options =
|
|
786
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = n || A, this.options.tokenizer = this.options.tokenizer || new N(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
776
787
|
inLink: !1,
|
|
777
788
|
inRawBlock: !1,
|
|
778
789
|
top: !0
|
|
779
790
|
};
|
|
780
791
|
const e = {
|
|
781
792
|
block: D.normal,
|
|
782
|
-
inline:
|
|
793
|
+
inline: I.normal
|
|
783
794
|
};
|
|
784
|
-
this.options.pedantic ? (e.block = D.pedantic, e.inline =
|
|
795
|
+
this.options.pedantic ? (e.block = D.pedantic, e.inline = I.pedantic) : this.options.gfm && (e.block = D.gfm, this.options.breaks ? e.inline = I.breaks : e.inline = I.gfm), this.tokenizer.rules = e;
|
|
785
796
|
}
|
|
786
797
|
/**
|
|
787
798
|
* Expose Rules
|
|
@@ -789,112 +800,112 @@ class T {
|
|
|
789
800
|
static get rules() {
|
|
790
801
|
return {
|
|
791
802
|
block: D,
|
|
792
|
-
inline:
|
|
803
|
+
inline: I
|
|
793
804
|
};
|
|
794
805
|
}
|
|
795
806
|
/**
|
|
796
807
|
* Static Lex Method
|
|
797
808
|
*/
|
|
798
|
-
static lex(
|
|
799
|
-
return new T(e).lex(
|
|
809
|
+
static lex(n, e) {
|
|
810
|
+
return new T(e).lex(n);
|
|
800
811
|
}
|
|
801
812
|
/**
|
|
802
813
|
* Static Lex Inline Method
|
|
803
814
|
*/
|
|
804
|
-
static lexInline(
|
|
805
|
-
return new T(e).inlineTokens(
|
|
815
|
+
static lexInline(n, e) {
|
|
816
|
+
return new T(e).inlineTokens(n);
|
|
806
817
|
}
|
|
807
818
|
/**
|
|
808
819
|
* Preprocessing
|
|
809
820
|
*/
|
|
810
|
-
lex(
|
|
811
|
-
|
|
812
|
-
`), this.blockTokens(
|
|
821
|
+
lex(n) {
|
|
822
|
+
n = n.replace(/\r\n|\r/g, `
|
|
823
|
+
`), this.blockTokens(n, this.tokens);
|
|
813
824
|
for (let e = 0; e < this.inlineQueue.length; e++) {
|
|
814
|
-
const
|
|
815
|
-
this.inlineTokens(
|
|
825
|
+
const t = this.inlineQueue[e];
|
|
826
|
+
this.inlineTokens(t.src, t.tokens);
|
|
816
827
|
}
|
|
817
828
|
return this.inlineQueue = [], this.tokens;
|
|
818
829
|
}
|
|
819
|
-
blockTokens(
|
|
820
|
-
this.options.pedantic ?
|
|
821
|
-
let
|
|
822
|
-
for (;
|
|
823
|
-
if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((l) => (
|
|
824
|
-
if (
|
|
825
|
-
|
|
826
|
-
` : e.push(
|
|
830
|
+
blockTokens(n, e = []) {
|
|
831
|
+
this.options.pedantic ? n = n.replace(/\t/g, " ").replace(/^ +$/gm, "") : n = n.replace(/^( *)(\t+)/gm, (l, o, p) => o + " ".repeat(p.length));
|
|
832
|
+
let t, i, r, s;
|
|
833
|
+
for (; n; )
|
|
834
|
+
if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((l) => (t = l.call({ lexer: this }, n, e)) ? (n = n.substring(t.raw.length), e.push(t), !0) : !1))) {
|
|
835
|
+
if (t = this.tokenizer.space(n)) {
|
|
836
|
+
n = n.substring(t.raw.length), t.raw.length === 1 && e.length > 0 ? e[e.length - 1].raw += `
|
|
837
|
+
` : e.push(t);
|
|
827
838
|
continue;
|
|
828
839
|
}
|
|
829
|
-
if (
|
|
830
|
-
|
|
831
|
-
` +
|
|
832
|
-
` +
|
|
840
|
+
if (t = this.tokenizer.code(n)) {
|
|
841
|
+
n = n.substring(t.raw.length), i = e[e.length - 1], i && (i.type === "paragraph" || i.type === "text") ? (i.raw += `
|
|
842
|
+
` + t.raw, i.text += `
|
|
843
|
+
` + t.text, this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : e.push(t);
|
|
833
844
|
continue;
|
|
834
845
|
}
|
|
835
|
-
if (
|
|
836
|
-
|
|
846
|
+
if (t = this.tokenizer.fences(n)) {
|
|
847
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
837
848
|
continue;
|
|
838
849
|
}
|
|
839
|
-
if (
|
|
840
|
-
|
|
850
|
+
if (t = this.tokenizer.heading(n)) {
|
|
851
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
841
852
|
continue;
|
|
842
853
|
}
|
|
843
|
-
if (
|
|
844
|
-
|
|
854
|
+
if (t = this.tokenizer.hr(n)) {
|
|
855
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
845
856
|
continue;
|
|
846
857
|
}
|
|
847
|
-
if (
|
|
848
|
-
|
|
858
|
+
if (t = this.tokenizer.blockquote(n)) {
|
|
859
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
849
860
|
continue;
|
|
850
861
|
}
|
|
851
|
-
if (
|
|
852
|
-
|
|
862
|
+
if (t = this.tokenizer.list(n)) {
|
|
863
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
853
864
|
continue;
|
|
854
865
|
}
|
|
855
|
-
if (
|
|
856
|
-
|
|
866
|
+
if (t = this.tokenizer.html(n)) {
|
|
867
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
857
868
|
continue;
|
|
858
869
|
}
|
|
859
|
-
if (
|
|
860
|
-
|
|
861
|
-
` +
|
|
862
|
-
` +
|
|
863
|
-
href:
|
|
864
|
-
title:
|
|
870
|
+
if (t = this.tokenizer.def(n)) {
|
|
871
|
+
n = n.substring(t.raw.length), i = e[e.length - 1], i && (i.type === "paragraph" || i.type === "text") ? (i.raw += `
|
|
872
|
+
` + t.raw, i.text += `
|
|
873
|
+
` + t.raw, this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : this.tokens.links[t.tag] || (this.tokens.links[t.tag] = {
|
|
874
|
+
href: t.href,
|
|
875
|
+
title: t.title
|
|
865
876
|
});
|
|
866
877
|
continue;
|
|
867
878
|
}
|
|
868
|
-
if (
|
|
869
|
-
|
|
879
|
+
if (t = this.tokenizer.table(n)) {
|
|
880
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
870
881
|
continue;
|
|
871
882
|
}
|
|
872
|
-
if (
|
|
873
|
-
|
|
883
|
+
if (t = this.tokenizer.lheading(n)) {
|
|
884
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
874
885
|
continue;
|
|
875
886
|
}
|
|
876
|
-
if (r =
|
|
887
|
+
if (r = n, this.options.extensions && this.options.extensions.startBlock) {
|
|
877
888
|
let l = 1 / 0;
|
|
878
|
-
const o =
|
|
889
|
+
const o = n.slice(1);
|
|
879
890
|
let p;
|
|
880
891
|
this.options.extensions.startBlock.forEach((c) => {
|
|
881
892
|
p = c.call({ lexer: this }, o), typeof p == "number" && p >= 0 && (l = Math.min(l, p));
|
|
882
|
-
}), l < 1 / 0 && l >= 0 && (r =
|
|
893
|
+
}), l < 1 / 0 && l >= 0 && (r = n.substring(0, l + 1));
|
|
883
894
|
}
|
|
884
|
-
if (this.state.top && (
|
|
895
|
+
if (this.state.top && (t = this.tokenizer.paragraph(r))) {
|
|
885
896
|
i = e[e.length - 1], s && i.type === "paragraph" ? (i.raw += `
|
|
886
|
-
` +
|
|
887
|
-
` +
|
|
897
|
+
` + t.raw, i.text += `
|
|
898
|
+
` + t.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : e.push(t), s = r.length !== n.length, n = n.substring(t.raw.length);
|
|
888
899
|
continue;
|
|
889
900
|
}
|
|
890
|
-
if (
|
|
891
|
-
|
|
892
|
-
` +
|
|
893
|
-
` +
|
|
901
|
+
if (t = this.tokenizer.text(n)) {
|
|
902
|
+
n = n.substring(t.raw.length), i = e[e.length - 1], i && i.type === "text" ? (i.raw += `
|
|
903
|
+
` + t.raw, i.text += `
|
|
904
|
+
` + t.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : e.push(t);
|
|
894
905
|
continue;
|
|
895
906
|
}
|
|
896
|
-
if (
|
|
897
|
-
const l = "Infinite loop on byte: " +
|
|
907
|
+
if (n) {
|
|
908
|
+
const l = "Infinite loop on byte: " + n.charCodeAt(0);
|
|
898
909
|
if (this.options.silent) {
|
|
899
910
|
console.error(l);
|
|
900
911
|
break;
|
|
@@ -904,14 +915,14 @@ class T {
|
|
|
904
915
|
}
|
|
905
916
|
return this.state.top = !0, e;
|
|
906
917
|
}
|
|
907
|
-
inline(
|
|
908
|
-
return this.inlineQueue.push({ src:
|
|
918
|
+
inline(n, e = []) {
|
|
919
|
+
return this.inlineQueue.push({ src: n, tokens: e }), e;
|
|
909
920
|
}
|
|
910
921
|
/**
|
|
911
922
|
* Lexing/Compiling
|
|
912
923
|
*/
|
|
913
|
-
inlineTokens(
|
|
914
|
-
let
|
|
924
|
+
inlineTokens(n, e = []) {
|
|
925
|
+
let t, i, r, s = n, l, o, p;
|
|
915
926
|
if (this.tokens.links) {
|
|
916
927
|
const c = Object.keys(this.tokens.links);
|
|
917
928
|
if (c.length > 0)
|
|
@@ -922,62 +933,62 @@ class T {
|
|
|
922
933
|
s = s.slice(0, l.index) + "[" + "a".repeat(l[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
923
934
|
for (; (l = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; )
|
|
924
935
|
s = s.slice(0, l.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
925
|
-
for (;
|
|
926
|
-
if (o || (p = ""), o = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((c) => (
|
|
927
|
-
if (
|
|
928
|
-
|
|
936
|
+
for (; n; )
|
|
937
|
+
if (o || (p = ""), o = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((c) => (t = c.call({ lexer: this }, n, e)) ? (n = n.substring(t.raw.length), e.push(t), !0) : !1))) {
|
|
938
|
+
if (t = this.tokenizer.escape(n)) {
|
|
939
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
929
940
|
continue;
|
|
930
941
|
}
|
|
931
|
-
if (
|
|
932
|
-
|
|
942
|
+
if (t = this.tokenizer.tag(n)) {
|
|
943
|
+
n = n.substring(t.raw.length), i = e[e.length - 1], i && t.type === "text" && i.type === "text" ? (i.raw += t.raw, i.text += t.text) : e.push(t);
|
|
933
944
|
continue;
|
|
934
945
|
}
|
|
935
|
-
if (
|
|
936
|
-
|
|
946
|
+
if (t = this.tokenizer.link(n)) {
|
|
947
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
937
948
|
continue;
|
|
938
949
|
}
|
|
939
|
-
if (
|
|
940
|
-
|
|
950
|
+
if (t = this.tokenizer.reflink(n, this.tokens.links)) {
|
|
951
|
+
n = n.substring(t.raw.length), i = e[e.length - 1], i && t.type === "text" && i.type === "text" ? (i.raw += t.raw, i.text += t.text) : e.push(t);
|
|
941
952
|
continue;
|
|
942
953
|
}
|
|
943
|
-
if (
|
|
944
|
-
|
|
954
|
+
if (t = this.tokenizer.emStrong(n, s, p)) {
|
|
955
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
945
956
|
continue;
|
|
946
957
|
}
|
|
947
|
-
if (
|
|
948
|
-
|
|
958
|
+
if (t = this.tokenizer.codespan(n)) {
|
|
959
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
949
960
|
continue;
|
|
950
961
|
}
|
|
951
|
-
if (
|
|
952
|
-
|
|
962
|
+
if (t = this.tokenizer.br(n)) {
|
|
963
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
953
964
|
continue;
|
|
954
965
|
}
|
|
955
|
-
if (
|
|
956
|
-
|
|
966
|
+
if (t = this.tokenizer.del(n)) {
|
|
967
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
957
968
|
continue;
|
|
958
969
|
}
|
|
959
|
-
if (
|
|
960
|
-
|
|
970
|
+
if (t = this.tokenizer.autolink(n)) {
|
|
971
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
961
972
|
continue;
|
|
962
973
|
}
|
|
963
|
-
if (!this.state.inLink && (
|
|
964
|
-
|
|
974
|
+
if (!this.state.inLink && (t = this.tokenizer.url(n))) {
|
|
975
|
+
n = n.substring(t.raw.length), e.push(t);
|
|
965
976
|
continue;
|
|
966
977
|
}
|
|
967
|
-
if (r =
|
|
978
|
+
if (r = n, this.options.extensions && this.options.extensions.startInline) {
|
|
968
979
|
let c = 1 / 0;
|
|
969
|
-
const u =
|
|
980
|
+
const u = n.slice(1);
|
|
970
981
|
let h;
|
|
971
982
|
this.options.extensions.startInline.forEach((f) => {
|
|
972
983
|
h = f.call({ lexer: this }, u), typeof h == "number" && h >= 0 && (c = Math.min(c, h));
|
|
973
|
-
}), c < 1 / 0 && c >= 0 && (r =
|
|
984
|
+
}), c < 1 / 0 && c >= 0 && (r = n.substring(0, c + 1));
|
|
974
985
|
}
|
|
975
|
-
if (
|
|
976
|
-
|
|
986
|
+
if (t = this.tokenizer.inlineText(r)) {
|
|
987
|
+
n = n.substring(t.raw.length), t.raw.slice(-1) !== "_" && (p = t.raw.slice(-1)), o = !0, i = e[e.length - 1], i && i.type === "text" ? (i.raw += t.raw, i.text += t.text) : e.push(t);
|
|
977
988
|
continue;
|
|
978
989
|
}
|
|
979
|
-
if (
|
|
980
|
-
const c = "Infinite loop on byte: " +
|
|
990
|
+
if (n) {
|
|
991
|
+
const c = "Infinite loop on byte: " + n.charCodeAt(0);
|
|
981
992
|
if (this.options.silent) {
|
|
982
993
|
console.error(c);
|
|
983
994
|
break;
|
|
@@ -988,167 +999,167 @@ class T {
|
|
|
988
999
|
return e;
|
|
989
1000
|
}
|
|
990
1001
|
}
|
|
991
|
-
class
|
|
992
|
-
constructor(
|
|
1002
|
+
class q {
|
|
1003
|
+
constructor(n) {
|
|
993
1004
|
k(this, "options");
|
|
994
|
-
this.options =
|
|
1005
|
+
this.options = n || A;
|
|
995
1006
|
}
|
|
996
|
-
code(
|
|
1007
|
+
code(n, e, t) {
|
|
997
1008
|
var r;
|
|
998
1009
|
const i = (r = (e || "").match(/^\S*/)) == null ? void 0 : r[0];
|
|
999
|
-
return
|
|
1000
|
-
`, i ? '<pre><code class="language-' + b(i) + '">' + (
|
|
1001
|
-
` : "<pre><code>" + (
|
|
1010
|
+
return n = n.replace(/\n$/, "") + `
|
|
1011
|
+
`, i ? '<pre><code class="language-' + b(i) + '">' + (t ? n : b(n, !0)) + `</code></pre>
|
|
1012
|
+
` : "<pre><code>" + (t ? n : b(n, !0)) + `</code></pre>
|
|
1002
1013
|
`;
|
|
1003
1014
|
}
|
|
1004
|
-
blockquote(
|
|
1015
|
+
blockquote(n) {
|
|
1005
1016
|
return `<blockquote>
|
|
1006
|
-
${
|
|
1017
|
+
${n}</blockquote>
|
|
1007
1018
|
`;
|
|
1008
1019
|
}
|
|
1009
|
-
html(
|
|
1010
|
-
return
|
|
1020
|
+
html(n, e) {
|
|
1021
|
+
return n;
|
|
1011
1022
|
}
|
|
1012
|
-
heading(
|
|
1013
|
-
return `<h${e}>${
|
|
1023
|
+
heading(n, e, t) {
|
|
1024
|
+
return `<h${e}>${n}</h${e}>
|
|
1014
1025
|
`;
|
|
1015
1026
|
}
|
|
1016
1027
|
hr() {
|
|
1017
1028
|
return `<hr>
|
|
1018
1029
|
`;
|
|
1019
1030
|
}
|
|
1020
|
-
list(
|
|
1021
|
-
const i = e ? "ol" : "ul", r = e &&
|
|
1031
|
+
list(n, e, t) {
|
|
1032
|
+
const i = e ? "ol" : "ul", r = e && t !== 1 ? ' start="' + t + '"' : "";
|
|
1022
1033
|
return "<" + i + r + `>
|
|
1023
|
-
` +
|
|
1034
|
+
` + n + "</" + i + `>
|
|
1024
1035
|
`;
|
|
1025
1036
|
}
|
|
1026
|
-
listitem(
|
|
1027
|
-
return `<li>${
|
|
1037
|
+
listitem(n, e, t) {
|
|
1038
|
+
return `<li>${n}</li>
|
|
1028
1039
|
`;
|
|
1029
1040
|
}
|
|
1030
|
-
checkbox(
|
|
1031
|
-
return "<input " + (
|
|
1041
|
+
checkbox(n) {
|
|
1042
|
+
return "<input " + (n ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
1032
1043
|
}
|
|
1033
|
-
paragraph(
|
|
1034
|
-
return `<p>${
|
|
1044
|
+
paragraph(n) {
|
|
1045
|
+
return `<p>${n}</p>
|
|
1035
1046
|
`;
|
|
1036
1047
|
}
|
|
1037
|
-
table(
|
|
1048
|
+
table(n, e) {
|
|
1038
1049
|
return e && (e = `<tbody>${e}</tbody>`), `<table>
|
|
1039
1050
|
<thead>
|
|
1040
|
-
` +
|
|
1051
|
+
` + n + `</thead>
|
|
1041
1052
|
` + e + `</table>
|
|
1042
1053
|
`;
|
|
1043
1054
|
}
|
|
1044
|
-
tablerow(
|
|
1055
|
+
tablerow(n) {
|
|
1045
1056
|
return `<tr>
|
|
1046
|
-
${
|
|
1057
|
+
${n}</tr>
|
|
1047
1058
|
`;
|
|
1048
1059
|
}
|
|
1049
|
-
tablecell(
|
|
1050
|
-
const
|
|
1051
|
-
return (e.align ? `<${
|
|
1060
|
+
tablecell(n, e) {
|
|
1061
|
+
const t = e.header ? "th" : "td";
|
|
1062
|
+
return (e.align ? `<${t} align="${e.align}">` : `<${t}>`) + n + `</${t}>
|
|
1052
1063
|
`;
|
|
1053
1064
|
}
|
|
1054
1065
|
/**
|
|
1055
1066
|
* span level renderer
|
|
1056
1067
|
*/
|
|
1057
|
-
strong(
|
|
1058
|
-
return `<strong>${
|
|
1068
|
+
strong(n) {
|
|
1069
|
+
return `<strong>${n}</strong>`;
|
|
1059
1070
|
}
|
|
1060
|
-
em(
|
|
1061
|
-
return `<em>${
|
|
1071
|
+
em(n) {
|
|
1072
|
+
return `<em>${n}</em>`;
|
|
1062
1073
|
}
|
|
1063
|
-
codespan(
|
|
1064
|
-
return `<code>${
|
|
1074
|
+
codespan(n) {
|
|
1075
|
+
return `<code>${n}</code>`;
|
|
1065
1076
|
}
|
|
1066
1077
|
br() {
|
|
1067
1078
|
return "<br>";
|
|
1068
1079
|
}
|
|
1069
|
-
del(
|
|
1070
|
-
return `<del>${
|
|
1080
|
+
del(n) {
|
|
1081
|
+
return `<del>${n}</del>`;
|
|
1071
1082
|
}
|
|
1072
|
-
link(
|
|
1073
|
-
const i = oe(
|
|
1083
|
+
link(n, e, t) {
|
|
1084
|
+
const i = oe(n);
|
|
1074
1085
|
if (i === null)
|
|
1075
|
-
return
|
|
1076
|
-
|
|
1077
|
-
let r = '<a href="' +
|
|
1078
|
-
return e && (r += ' title="' + e + '"'), r += ">" +
|
|
1086
|
+
return t;
|
|
1087
|
+
n = i;
|
|
1088
|
+
let r = '<a href="' + n + '"';
|
|
1089
|
+
return e && (r += ' title="' + e + '"'), r += ">" + t + "</a>", r;
|
|
1079
1090
|
}
|
|
1080
|
-
image(
|
|
1081
|
-
const i = oe(
|
|
1091
|
+
image(n, e, t) {
|
|
1092
|
+
const i = oe(n);
|
|
1082
1093
|
if (i === null)
|
|
1083
|
-
return
|
|
1084
|
-
|
|
1085
|
-
let r = `<img src="${
|
|
1094
|
+
return t;
|
|
1095
|
+
n = i;
|
|
1096
|
+
let r = `<img src="${n}" alt="${t}"`;
|
|
1086
1097
|
return e && (r += ` title="${e}"`), r += ">", r;
|
|
1087
1098
|
}
|
|
1088
|
-
text(
|
|
1089
|
-
return
|
|
1099
|
+
text(n) {
|
|
1100
|
+
return n;
|
|
1090
1101
|
}
|
|
1091
1102
|
}
|
|
1092
|
-
class
|
|
1103
|
+
class K {
|
|
1093
1104
|
// no need for block level renderers
|
|
1094
|
-
strong(
|
|
1095
|
-
return
|
|
1105
|
+
strong(n) {
|
|
1106
|
+
return n;
|
|
1096
1107
|
}
|
|
1097
|
-
em(
|
|
1098
|
-
return
|
|
1108
|
+
em(n) {
|
|
1109
|
+
return n;
|
|
1099
1110
|
}
|
|
1100
|
-
codespan(
|
|
1101
|
-
return
|
|
1111
|
+
codespan(n) {
|
|
1112
|
+
return n;
|
|
1102
1113
|
}
|
|
1103
|
-
del(
|
|
1104
|
-
return
|
|
1114
|
+
del(n) {
|
|
1115
|
+
return n;
|
|
1105
1116
|
}
|
|
1106
|
-
html(
|
|
1107
|
-
return
|
|
1117
|
+
html(n) {
|
|
1118
|
+
return n;
|
|
1108
1119
|
}
|
|
1109
|
-
text(
|
|
1110
|
-
return
|
|
1120
|
+
text(n) {
|
|
1121
|
+
return n;
|
|
1111
1122
|
}
|
|
1112
|
-
link(
|
|
1113
|
-
return "" +
|
|
1123
|
+
link(n, e, t) {
|
|
1124
|
+
return "" + t;
|
|
1114
1125
|
}
|
|
1115
|
-
image(
|
|
1116
|
-
return "" +
|
|
1126
|
+
image(n, e, t) {
|
|
1127
|
+
return "" + t;
|
|
1117
1128
|
}
|
|
1118
1129
|
br() {
|
|
1119
1130
|
return "";
|
|
1120
1131
|
}
|
|
1121
1132
|
}
|
|
1122
1133
|
class z {
|
|
1123
|
-
constructor(
|
|
1134
|
+
constructor(n) {
|
|
1124
1135
|
k(this, "options");
|
|
1125
1136
|
k(this, "renderer");
|
|
1126
1137
|
k(this, "textRenderer");
|
|
1127
|
-
this.options =
|
|
1138
|
+
this.options = n || A, this.options.renderer = this.options.renderer || new q(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new K();
|
|
1128
1139
|
}
|
|
1129
1140
|
/**
|
|
1130
1141
|
* Static Parse Method
|
|
1131
1142
|
*/
|
|
1132
|
-
static parse(
|
|
1133
|
-
return new z(e).parse(
|
|
1143
|
+
static parse(n, e) {
|
|
1144
|
+
return new z(e).parse(n);
|
|
1134
1145
|
}
|
|
1135
1146
|
/**
|
|
1136
1147
|
* Static Parse Inline Method
|
|
1137
1148
|
*/
|
|
1138
|
-
static parseInline(
|
|
1139
|
-
return new z(e).parseInline(
|
|
1149
|
+
static parseInline(n, e) {
|
|
1150
|
+
return new z(e).parseInline(n);
|
|
1140
1151
|
}
|
|
1141
1152
|
/**
|
|
1142
1153
|
* Parse Loop
|
|
1143
1154
|
*/
|
|
1144
|
-
parse(
|
|
1145
|
-
let
|
|
1146
|
-
for (let i = 0; i <
|
|
1147
|
-
const r =
|
|
1155
|
+
parse(n, e = !0) {
|
|
1156
|
+
let t = "";
|
|
1157
|
+
for (let i = 0; i < n.length; i++) {
|
|
1158
|
+
const r = n[i];
|
|
1148
1159
|
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[r.type]) {
|
|
1149
1160
|
const s = r, l = this.options.extensions.renderers[s.type].call({ parser: this }, s);
|
|
1150
1161
|
if (l !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(s.type)) {
|
|
1151
|
-
|
|
1162
|
+
t += l || "";
|
|
1152
1163
|
continue;
|
|
1153
1164
|
}
|
|
1154
1165
|
}
|
|
@@ -1156,17 +1167,17 @@ class z {
|
|
|
1156
1167
|
case "space":
|
|
1157
1168
|
continue;
|
|
1158
1169
|
case "hr": {
|
|
1159
|
-
|
|
1170
|
+
t += this.renderer.hr();
|
|
1160
1171
|
continue;
|
|
1161
1172
|
}
|
|
1162
1173
|
case "heading": {
|
|
1163
1174
|
const s = r;
|
|
1164
|
-
|
|
1175
|
+
t += this.renderer.heading(this.parseInline(s.tokens), s.depth, Ne(this.parseInline(s.tokens, this.textRenderer)));
|
|
1165
1176
|
continue;
|
|
1166
1177
|
}
|
|
1167
1178
|
case "code": {
|
|
1168
1179
|
const s = r;
|
|
1169
|
-
|
|
1180
|
+
t += this.renderer.code(s.text, s.lang, !!s.escaped);
|
|
1170
1181
|
continue;
|
|
1171
1182
|
}
|
|
1172
1183
|
case "table": {
|
|
@@ -1183,12 +1194,12 @@ class z {
|
|
|
1183
1194
|
o += this.renderer.tablecell(this.parseInline(u[h].tokens), { header: !1, align: s.align[h] });
|
|
1184
1195
|
p += this.renderer.tablerow(o);
|
|
1185
1196
|
}
|
|
1186
|
-
|
|
1197
|
+
t += this.renderer.table(l, p);
|
|
1187
1198
|
continue;
|
|
1188
1199
|
}
|
|
1189
1200
|
case "blockquote": {
|
|
1190
1201
|
const s = r, l = this.parse(s.tokens);
|
|
1191
|
-
|
|
1202
|
+
t += this.renderer.blockquote(l);
|
|
1192
1203
|
continue;
|
|
1193
1204
|
}
|
|
1194
1205
|
case "list": {
|
|
@@ -1206,25 +1217,25 @@ class z {
|
|
|
1206
1217
|
}
|
|
1207
1218
|
y += this.parse(h.tokens, p), c += this.renderer.listitem(y, w, !!f);
|
|
1208
1219
|
}
|
|
1209
|
-
|
|
1220
|
+
t += this.renderer.list(c, l, o);
|
|
1210
1221
|
continue;
|
|
1211
1222
|
}
|
|
1212
1223
|
case "html": {
|
|
1213
1224
|
const s = r;
|
|
1214
|
-
|
|
1225
|
+
t += this.renderer.html(s.text, s.block);
|
|
1215
1226
|
continue;
|
|
1216
1227
|
}
|
|
1217
1228
|
case "paragraph": {
|
|
1218
1229
|
const s = r;
|
|
1219
|
-
|
|
1230
|
+
t += this.renderer.paragraph(this.parseInline(s.tokens));
|
|
1220
1231
|
continue;
|
|
1221
1232
|
}
|
|
1222
1233
|
case "text": {
|
|
1223
1234
|
let s = r, l = s.tokens ? this.parseInline(s.tokens) : s.text;
|
|
1224
|
-
for (; i + 1 <
|
|
1225
|
-
s =
|
|
1235
|
+
for (; i + 1 < n.length && n[i + 1].type === "text"; )
|
|
1236
|
+
s = n[++i], l += `
|
|
1226
1237
|
` + (s.tokens ? this.parseInline(s.tokens) : s.text);
|
|
1227
|
-
|
|
1238
|
+
t += e ? this.renderer.paragraph(l) : l;
|
|
1228
1239
|
continue;
|
|
1229
1240
|
}
|
|
1230
1241
|
default: {
|
|
@@ -1235,71 +1246,71 @@ class z {
|
|
|
1235
1246
|
}
|
|
1236
1247
|
}
|
|
1237
1248
|
}
|
|
1238
|
-
return
|
|
1249
|
+
return t;
|
|
1239
1250
|
}
|
|
1240
1251
|
/**
|
|
1241
1252
|
* Parse Inline Tokens
|
|
1242
1253
|
*/
|
|
1243
|
-
parseInline(
|
|
1254
|
+
parseInline(n, e) {
|
|
1244
1255
|
e = e || this.renderer;
|
|
1245
|
-
let
|
|
1246
|
-
for (let i = 0; i <
|
|
1247
|
-
const r =
|
|
1256
|
+
let t = "";
|
|
1257
|
+
for (let i = 0; i < n.length; i++) {
|
|
1258
|
+
const r = n[i];
|
|
1248
1259
|
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[r.type]) {
|
|
1249
1260
|
const s = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
1250
1261
|
if (s !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
1251
|
-
|
|
1262
|
+
t += s || "";
|
|
1252
1263
|
continue;
|
|
1253
1264
|
}
|
|
1254
1265
|
}
|
|
1255
1266
|
switch (r.type) {
|
|
1256
1267
|
case "escape": {
|
|
1257
1268
|
const s = r;
|
|
1258
|
-
|
|
1269
|
+
t += e.text(s.text);
|
|
1259
1270
|
break;
|
|
1260
1271
|
}
|
|
1261
1272
|
case "html": {
|
|
1262
1273
|
const s = r;
|
|
1263
|
-
|
|
1274
|
+
t += e.html(s.text);
|
|
1264
1275
|
break;
|
|
1265
1276
|
}
|
|
1266
1277
|
case "link": {
|
|
1267
1278
|
const s = r;
|
|
1268
|
-
|
|
1279
|
+
t += e.link(s.href, s.title, this.parseInline(s.tokens, e));
|
|
1269
1280
|
break;
|
|
1270
1281
|
}
|
|
1271
1282
|
case "image": {
|
|
1272
1283
|
const s = r;
|
|
1273
|
-
|
|
1284
|
+
t += e.image(s.href, s.title, s.text);
|
|
1274
1285
|
break;
|
|
1275
1286
|
}
|
|
1276
1287
|
case "strong": {
|
|
1277
1288
|
const s = r;
|
|
1278
|
-
|
|
1289
|
+
t += e.strong(this.parseInline(s.tokens, e));
|
|
1279
1290
|
break;
|
|
1280
1291
|
}
|
|
1281
1292
|
case "em": {
|
|
1282
1293
|
const s = r;
|
|
1283
|
-
|
|
1294
|
+
t += e.em(this.parseInline(s.tokens, e));
|
|
1284
1295
|
break;
|
|
1285
1296
|
}
|
|
1286
1297
|
case "codespan": {
|
|
1287
1298
|
const s = r;
|
|
1288
|
-
|
|
1299
|
+
t += e.codespan(s.text);
|
|
1289
1300
|
break;
|
|
1290
1301
|
}
|
|
1291
1302
|
case "br": {
|
|
1292
|
-
|
|
1303
|
+
t += e.br();
|
|
1293
1304
|
break;
|
|
1294
1305
|
}
|
|
1295
1306
|
case "del": {
|
|
1296
1307
|
const s = r;
|
|
1297
|
-
|
|
1308
|
+
t += e.del(this.parseInline(s.tokens, e));
|
|
1298
1309
|
break;
|
|
1299
1310
|
}
|
|
1300
1311
|
case "text": {
|
|
1301
1312
|
const s = r;
|
|
1302
|
-
|
|
1313
|
+
t += e.text(s.text);
|
|
1303
1314
|
break;
|
|
1304
1315
|
}
|
|
1305
1316
|
default: {
|
|
@@ -1310,91 +1321,91 @@ class z {
|
|
|
1310
1321
|
}
|
|
1311
1322
|
}
|
|
1312
1323
|
}
|
|
1313
|
-
return
|
|
1324
|
+
return t;
|
|
1314
1325
|
}
|
|
1315
1326
|
}
|
|
1316
|
-
class
|
|
1317
|
-
constructor(
|
|
1327
|
+
class C {
|
|
1328
|
+
constructor(n) {
|
|
1318
1329
|
k(this, "options");
|
|
1319
|
-
this.options =
|
|
1330
|
+
this.options = n || A;
|
|
1320
1331
|
}
|
|
1321
1332
|
/**
|
|
1322
1333
|
* Process markdown before marked
|
|
1323
1334
|
*/
|
|
1324
|
-
preprocess(
|
|
1325
|
-
return
|
|
1335
|
+
preprocess(n) {
|
|
1336
|
+
return n;
|
|
1326
1337
|
}
|
|
1327
1338
|
/**
|
|
1328
1339
|
* Process HTML after marked is finished
|
|
1329
1340
|
*/
|
|
1330
|
-
postprocess(
|
|
1331
|
-
return
|
|
1341
|
+
postprocess(n) {
|
|
1342
|
+
return n;
|
|
1332
1343
|
}
|
|
1333
1344
|
/**
|
|
1334
1345
|
* Process all tokens before walk tokens
|
|
1335
1346
|
*/
|
|
1336
|
-
processAllTokens(
|
|
1337
|
-
return
|
|
1347
|
+
processAllTokens(n) {
|
|
1348
|
+
return n;
|
|
1338
1349
|
}
|
|
1339
1350
|
}
|
|
1340
|
-
k(
|
|
1351
|
+
k(C, "passThroughHooks", /* @__PURE__ */ new Set([
|
|
1341
1352
|
"preprocess",
|
|
1342
1353
|
"postprocess",
|
|
1343
1354
|
"processAllTokens"
|
|
1344
1355
|
]));
|
|
1345
1356
|
var _, H, ye;
|
|
1346
1357
|
class gt {
|
|
1347
|
-
constructor(...
|
|
1358
|
+
constructor(...n) {
|
|
1348
1359
|
se(this, _);
|
|
1349
1360
|
k(this, "defaults", J());
|
|
1350
1361
|
k(this, "options", this.setOptions);
|
|
1351
1362
|
k(this, "parse", v(this, _, H).call(this, T.lex, z.parse));
|
|
1352
1363
|
k(this, "parseInline", v(this, _, H).call(this, T.lexInline, z.parseInline));
|
|
1353
1364
|
k(this, "Parser", z);
|
|
1354
|
-
k(this, "Renderer",
|
|
1355
|
-
k(this, "TextRenderer",
|
|
1365
|
+
k(this, "Renderer", q);
|
|
1366
|
+
k(this, "TextRenderer", K);
|
|
1356
1367
|
k(this, "Lexer", T);
|
|
1357
|
-
k(this, "Tokenizer",
|
|
1358
|
-
k(this, "Hooks",
|
|
1359
|
-
this.use(...
|
|
1368
|
+
k(this, "Tokenizer", N);
|
|
1369
|
+
k(this, "Hooks", C);
|
|
1370
|
+
this.use(...n);
|
|
1360
1371
|
}
|
|
1361
1372
|
/**
|
|
1362
1373
|
* Run callback for every token
|
|
1363
1374
|
*/
|
|
1364
|
-
walkTokens(
|
|
1375
|
+
walkTokens(n, e) {
|
|
1365
1376
|
var i, r;
|
|
1366
|
-
let
|
|
1367
|
-
for (const s of
|
|
1368
|
-
switch (
|
|
1377
|
+
let t = [];
|
|
1378
|
+
for (const s of n)
|
|
1379
|
+
switch (t = t.concat(e.call(this, s)), s.type) {
|
|
1369
1380
|
case "table": {
|
|
1370
1381
|
const l = s;
|
|
1371
1382
|
for (const o of l.header)
|
|
1372
|
-
|
|
1383
|
+
t = t.concat(this.walkTokens(o.tokens, e));
|
|
1373
1384
|
for (const o of l.rows)
|
|
1374
1385
|
for (const p of o)
|
|
1375
|
-
|
|
1386
|
+
t = t.concat(this.walkTokens(p.tokens, e));
|
|
1376
1387
|
break;
|
|
1377
1388
|
}
|
|
1378
1389
|
case "list": {
|
|
1379
1390
|
const l = s;
|
|
1380
|
-
|
|
1391
|
+
t = t.concat(this.walkTokens(l.items, e));
|
|
1381
1392
|
break;
|
|
1382
1393
|
}
|
|
1383
1394
|
default: {
|
|
1384
1395
|
const l = s;
|
|
1385
1396
|
(r = (i = this.defaults.extensions) == null ? void 0 : i.childTokens) != null && r[l.type] ? this.defaults.extensions.childTokens[l.type].forEach((o) => {
|
|
1386
1397
|
const p = l[o].flat(1 / 0);
|
|
1387
|
-
|
|
1388
|
-
}) : l.tokens && (
|
|
1398
|
+
t = t.concat(this.walkTokens(p, e));
|
|
1399
|
+
}) : l.tokens && (t = t.concat(this.walkTokens(l.tokens, e)));
|
|
1389
1400
|
}
|
|
1390
1401
|
}
|
|
1391
|
-
return
|
|
1402
|
+
return t;
|
|
1392
1403
|
}
|
|
1393
|
-
use(...
|
|
1404
|
+
use(...n) {
|
|
1394
1405
|
const e = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1395
|
-
return
|
|
1396
|
-
const i = { ...
|
|
1397
|
-
if (i.async = this.defaults.async || i.async || !1,
|
|
1406
|
+
return n.forEach((t) => {
|
|
1407
|
+
const i = { ...t };
|
|
1408
|
+
if (i.async = this.defaults.async || i.async || !1, t.extensions && (t.extensions.forEach((r) => {
|
|
1398
1409
|
if (!r.name)
|
|
1399
1410
|
throw new Error("extension name required");
|
|
1400
1411
|
if ("renderer" in r) {
|
|
@@ -1411,14 +1422,14 @@ class gt {
|
|
|
1411
1422
|
s ? s.unshift(r.tokenizer) : e[r.level] = [r.tokenizer], r.start && (r.level === "block" ? e.startBlock ? e.startBlock.push(r.start) : e.startBlock = [r.start] : r.level === "inline" && (e.startInline ? e.startInline.push(r.start) : e.startInline = [r.start]));
|
|
1412
1423
|
}
|
|
1413
1424
|
"childTokens" in r && r.childTokens && (e.childTokens[r.name] = r.childTokens);
|
|
1414
|
-
}), i.extensions = e),
|
|
1415
|
-
const r = this.defaults.renderer || new
|
|
1416
|
-
for (const s in
|
|
1425
|
+
}), i.extensions = e), t.renderer) {
|
|
1426
|
+
const r = this.defaults.renderer || new q(this.defaults);
|
|
1427
|
+
for (const s in t.renderer) {
|
|
1417
1428
|
if (!(s in r))
|
|
1418
1429
|
throw new Error(`renderer '${s}' does not exist`);
|
|
1419
1430
|
if (s === "options")
|
|
1420
1431
|
continue;
|
|
1421
|
-
const l = s, o =
|
|
1432
|
+
const l = s, o = t.renderer[l], p = r[l];
|
|
1422
1433
|
r[l] = (...c) => {
|
|
1423
1434
|
let u = o.apply(r, c);
|
|
1424
1435
|
return u === !1 && (u = p.apply(r, c)), u || "";
|
|
@@ -1426,14 +1437,14 @@ class gt {
|
|
|
1426
1437
|
}
|
|
1427
1438
|
i.renderer = r;
|
|
1428
1439
|
}
|
|
1429
|
-
if (
|
|
1430
|
-
const r = this.defaults.tokenizer || new
|
|
1431
|
-
for (const s in
|
|
1440
|
+
if (t.tokenizer) {
|
|
1441
|
+
const r = this.defaults.tokenizer || new N(this.defaults);
|
|
1442
|
+
for (const s in t.tokenizer) {
|
|
1432
1443
|
if (!(s in r))
|
|
1433
1444
|
throw new Error(`tokenizer '${s}' does not exist`);
|
|
1434
1445
|
if (["options", "rules", "lexer"].includes(s))
|
|
1435
1446
|
continue;
|
|
1436
|
-
const l = s, o =
|
|
1447
|
+
const l = s, o = t.tokenizer[l], p = r[l];
|
|
1437
1448
|
r[l] = (...c) => {
|
|
1438
1449
|
let u = o.apply(r, c);
|
|
1439
1450
|
return u === !1 && (u = p.apply(r, c)), u;
|
|
@@ -1441,15 +1452,15 @@ class gt {
|
|
|
1441
1452
|
}
|
|
1442
1453
|
i.tokenizer = r;
|
|
1443
1454
|
}
|
|
1444
|
-
if (
|
|
1445
|
-
const r = this.defaults.hooks || new
|
|
1446
|
-
for (const s in
|
|
1455
|
+
if (t.hooks) {
|
|
1456
|
+
const r = this.defaults.hooks || new C();
|
|
1457
|
+
for (const s in t.hooks) {
|
|
1447
1458
|
if (!(s in r))
|
|
1448
1459
|
throw new Error(`hook '${s}' does not exist`);
|
|
1449
1460
|
if (s === "options")
|
|
1450
1461
|
continue;
|
|
1451
|
-
const l = s, o =
|
|
1452
|
-
|
|
1462
|
+
const l = s, o = t.hooks[l], p = r[l];
|
|
1463
|
+
C.passThroughHooks.has(s) ? r[l] = (c) => {
|
|
1453
1464
|
if (this.defaults.async)
|
|
1454
1465
|
return Promise.resolve(o.call(r, c)).then((h) => p.call(r, h));
|
|
1455
1466
|
const u = o.call(r, c);
|
|
@@ -1461,8 +1472,8 @@ class gt {
|
|
|
1461
1472
|
}
|
|
1462
1473
|
i.hooks = r;
|
|
1463
1474
|
}
|
|
1464
|
-
if (
|
|
1465
|
-
const r = this.defaults.walkTokens, s =
|
|
1475
|
+
if (t.walkTokens) {
|
|
1476
|
+
const r = this.defaults.walkTokens, s = t.walkTokens;
|
|
1466
1477
|
i.walkTokens = function(l) {
|
|
1467
1478
|
let o = [];
|
|
1468
1479
|
return o.push(s.call(this, l)), r && (o = o.concat(r.call(this, l))), o;
|
|
@@ -1471,30 +1482,30 @@ class gt {
|
|
|
1471
1482
|
this.defaults = { ...this.defaults, ...i };
|
|
1472
1483
|
}), this;
|
|
1473
1484
|
}
|
|
1474
|
-
setOptions(
|
|
1475
|
-
return this.defaults = { ...this.defaults, ...
|
|
1485
|
+
setOptions(n) {
|
|
1486
|
+
return this.defaults = { ...this.defaults, ...n }, this;
|
|
1476
1487
|
}
|
|
1477
|
-
lexer(
|
|
1478
|
-
return T.lex(
|
|
1488
|
+
lexer(n, e) {
|
|
1489
|
+
return T.lex(n, e ?? this.defaults);
|
|
1479
1490
|
}
|
|
1480
|
-
parser(
|
|
1481
|
-
return z.parse(
|
|
1491
|
+
parser(n, e) {
|
|
1492
|
+
return z.parse(n, e ?? this.defaults);
|
|
1482
1493
|
}
|
|
1483
1494
|
}
|
|
1484
|
-
_ = new WeakSet(), H = function(
|
|
1485
|
-
return (
|
|
1495
|
+
_ = new WeakSet(), H = function(n, e) {
|
|
1496
|
+
return (t, i) => {
|
|
1486
1497
|
const r = { ...i }, s = { ...this.defaults, ...r };
|
|
1487
1498
|
this.defaults.async === !0 && r.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);
|
|
1488
1499
|
const l = v(this, _, ye).call(this, !!s.silent, !!s.async);
|
|
1489
|
-
if (typeof
|
|
1500
|
+
if (typeof t > "u" || t === null)
|
|
1490
1501
|
return l(new Error("marked(): input parameter is undefined or null"));
|
|
1491
|
-
if (typeof
|
|
1492
|
-
return l(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(
|
|
1502
|
+
if (typeof t != "string")
|
|
1503
|
+
return l(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
|
|
1493
1504
|
if (s.hooks && (s.hooks.options = s), s.async)
|
|
1494
|
-
return Promise.resolve(s.hooks ? s.hooks.preprocess(
|
|
1505
|
+
return Promise.resolve(s.hooks ? s.hooks.preprocess(t) : t).then((o) => n(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);
|
|
1495
1506
|
try {
|
|
1496
|
-
s.hooks && (
|
|
1497
|
-
let o = t
|
|
1507
|
+
s.hooks && (t = s.hooks.preprocess(t));
|
|
1508
|
+
let o = n(t, s);
|
|
1498
1509
|
s.hooks && (o = s.hooks.processAllTokens(o)), s.walkTokens && this.walkTokens(o, s.walkTokens);
|
|
1499
1510
|
let p = e(o, s);
|
|
1500
1511
|
return s.hooks && (p = s.hooks.postprocess(p)), p;
|
|
@@ -1502,42 +1513,42 @@ _ = new WeakSet(), H = function(t, e) {
|
|
|
1502
1513
|
return l(o);
|
|
1503
1514
|
}
|
|
1504
1515
|
};
|
|
1505
|
-
}, ye = function(
|
|
1506
|
-
return (
|
|
1507
|
-
if (
|
|
1508
|
-
Please report this to https://github.com/markedjs/marked.`,
|
|
1509
|
-
const i = "<p>An error occurred:</p><pre>" + b(
|
|
1516
|
+
}, ye = function(n, e) {
|
|
1517
|
+
return (t) => {
|
|
1518
|
+
if (t.message += `
|
|
1519
|
+
Please report this to https://github.com/markedjs/marked.`, n) {
|
|
1520
|
+
const i = "<p>An error occurred:</p><pre>" + b(t.message + "", !0) + "</pre>";
|
|
1510
1521
|
return e ? Promise.resolve(i) : i;
|
|
1511
1522
|
}
|
|
1512
1523
|
if (e)
|
|
1513
|
-
return Promise.reject(
|
|
1514
|
-
throw
|
|
1524
|
+
return Promise.reject(t);
|
|
1525
|
+
throw t;
|
|
1515
1526
|
};
|
|
1516
1527
|
};
|
|
1517
1528
|
const S = new gt();
|
|
1518
|
-
function g(a,
|
|
1519
|
-
return S.parse(a,
|
|
1529
|
+
function g(a, n) {
|
|
1530
|
+
return S.parse(a, n);
|
|
1520
1531
|
}
|
|
1521
1532
|
g.options = g.setOptions = function(a) {
|
|
1522
1533
|
return S.setOptions(a), g.defaults = S.defaults, pe(g.defaults), g;
|
|
1523
1534
|
};
|
|
1524
1535
|
g.getDefaults = J;
|
|
1525
|
-
g.defaults =
|
|
1536
|
+
g.defaults = A;
|
|
1526
1537
|
g.use = function(...a) {
|
|
1527
1538
|
return S.use(...a), g.defaults = S.defaults, pe(g.defaults), g;
|
|
1528
1539
|
};
|
|
1529
|
-
g.walkTokens = function(a,
|
|
1530
|
-
return S.walkTokens(a,
|
|
1540
|
+
g.walkTokens = function(a, n) {
|
|
1541
|
+
return S.walkTokens(a, n);
|
|
1531
1542
|
};
|
|
1532
1543
|
g.parseInline = S.parseInline;
|
|
1533
1544
|
g.Parser = z;
|
|
1534
1545
|
g.parser = z.parse;
|
|
1535
|
-
g.Renderer =
|
|
1536
|
-
g.TextRenderer =
|
|
1546
|
+
g.Renderer = q;
|
|
1547
|
+
g.TextRenderer = K;
|
|
1537
1548
|
g.Lexer = T;
|
|
1538
1549
|
g.lexer = T.lex;
|
|
1539
|
-
g.Tokenizer =
|
|
1540
|
-
g.Hooks =
|
|
1550
|
+
g.Tokenizer = N;
|
|
1551
|
+
g.Hooks = C;
|
|
1541
1552
|
g.parse = g;
|
|
1542
1553
|
g.options;
|
|
1543
1554
|
g.setOptions;
|
|
@@ -1547,9 +1558,9 @@ g.parseInline;
|
|
|
1547
1558
|
z.parse;
|
|
1548
1559
|
T.lex;
|
|
1549
1560
|
function dt(a) {
|
|
1550
|
-
const
|
|
1561
|
+
const n = a.replace(/^---[\s\S]*?---\n/, "");
|
|
1551
1562
|
try {
|
|
1552
|
-
const e = g.lexer(
|
|
1563
|
+
const e = g.lexer(n), t = [], i = [];
|
|
1553
1564
|
for (const r of e)
|
|
1554
1565
|
if (r.type === "heading") {
|
|
1555
1566
|
const s = r, l = s.depth, o = $e(s.tokens), p = kt(o), c = {
|
|
@@ -1560,19 +1571,19 @@ function dt(a) {
|
|
|
1560
1571
|
};
|
|
1561
1572
|
for (; i.length > 0 && i[i.length - 1].level >= l; )
|
|
1562
1573
|
i.pop();
|
|
1563
|
-
i.length === 0 ?
|
|
1574
|
+
i.length === 0 ? t.push(c) : i[i.length - 1].children.push(c), i.push(c);
|
|
1564
1575
|
}
|
|
1565
|
-
return
|
|
1576
|
+
return t;
|
|
1566
1577
|
} catch (e) {
|
|
1567
1578
|
return console.warn("Failed to extract TOC from markdown:", e), [];
|
|
1568
1579
|
}
|
|
1569
1580
|
}
|
|
1570
1581
|
function $e(a) {
|
|
1571
|
-
return a.map((
|
|
1572
|
-
if (
|
|
1573
|
-
return
|
|
1574
|
-
if (
|
|
1575
|
-
const e =
|
|
1582
|
+
return a.map((n) => {
|
|
1583
|
+
if (n.type === "text")
|
|
1584
|
+
return n.text;
|
|
1585
|
+
if (n.type === "strong" || n.type === "em") {
|
|
1586
|
+
const e = n;
|
|
1576
1587
|
if ("tokens" in e && Array.isArray(e.tokens))
|
|
1577
1588
|
return $e(e.tokens);
|
|
1578
1589
|
}
|
|
@@ -1582,20 +1593,20 @@ function $e(a) {
|
|
|
1582
1593
|
function kt(a) {
|
|
1583
1594
|
return a.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").trim();
|
|
1584
1595
|
}
|
|
1585
|
-
async function he(a,
|
|
1596
|
+
async function he(a, n) {
|
|
1586
1597
|
const e = {};
|
|
1587
|
-
for (const [
|
|
1588
|
-
const r = x.join(
|
|
1598
|
+
for (const [t, i] of Object.entries(a)) {
|
|
1599
|
+
const r = x.join(n, `${t}.md`);
|
|
1589
1600
|
if (await m.pathExists(r)) {
|
|
1590
1601
|
const s = await m.readFile(r, "utf-8"), l = dt(s);
|
|
1591
|
-
e[
|
|
1602
|
+
e[t] = l;
|
|
1592
1603
|
}
|
|
1593
1604
|
}
|
|
1594
1605
|
return e;
|
|
1595
1606
|
}
|
|
1596
|
-
const $ =
|
|
1607
|
+
const $ = Ee("WSXPress");
|
|
1597
1608
|
function Tt(a) {
|
|
1598
|
-
const { docsRoot:
|
|
1609
|
+
const { docsRoot: n, api: e, outputDir: t = ".wsx-press" } = a;
|
|
1599
1610
|
let i, r;
|
|
1600
1611
|
return {
|
|
1601
1612
|
name: "vite-plugin-wsx-press",
|
|
@@ -1605,7 +1616,7 @@ function Tt(a) {
|
|
|
1605
1616
|
*/
|
|
1606
1617
|
configResolved(s) {
|
|
1607
1618
|
const l = (o) => o.startsWith("/") || /^[A-Za-z]:/.test(o) || o.startsWith("\\\\");
|
|
1608
|
-
i = l(
|
|
1619
|
+
i = l(t) ? t : x.resolve(s.root, t), r = l(n) ? n : x.resolve(s.root, n);
|
|
1609
1620
|
},
|
|
1610
1621
|
/**
|
|
1611
1622
|
* 构建开始时生成元数据和搜索索引
|
|
@@ -1614,7 +1625,7 @@ function Tt(a) {
|
|
|
1614
1625
|
try {
|
|
1615
1626
|
if (!i || !r) {
|
|
1616
1627
|
const c = (u) => u.startsWith("/") || /^[A-Za-z]:/.test(u) || u.startsWith("\\\\");
|
|
1617
|
-
i = c(
|
|
1628
|
+
i = c(t) ? t : x.resolve(process.cwd(), t), r = c(n) ? n : x.resolve(process.cwd(), n);
|
|
1618
1629
|
}
|
|
1619
1630
|
await m.ensureDir(i), $.info("Starting documentation generation..."), $.info(`Docs root: ${r}`), $.info(`Output dir: ${i}`);
|
|
1620
1631
|
const s = await O(r), l = x.join(i, "docs-meta.json");
|
|
@@ -1699,8 +1710,8 @@ function Tt(a) {
|
|
|
1699
1710
|
};
|
|
1700
1711
|
}
|
|
1701
1712
|
export {
|
|
1702
|
-
|
|
1703
|
-
|
|
1713
|
+
je as addPrevNextLinks,
|
|
1714
|
+
Ce as extractFrontmatter,
|
|
1704
1715
|
Pe as generateApiDocs,
|
|
1705
1716
|
ie as generateSearchIndex,
|
|
1706
1717
|
O as scanDocsMetadata,
|