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