turnish 1.5.0 → 1.6.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/dist/index.cjs +76 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +76 -27
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +735 -229
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +76 -27
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +13 -2
- package/dist/types/utilities.d.ts +3 -0
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,489 @@
|
|
|
1
|
-
|
|
1
|
+
class ae extends Error {
|
|
2
|
+
reason;
|
|
3
|
+
filename;
|
|
4
|
+
line;
|
|
5
|
+
column;
|
|
6
|
+
source;
|
|
7
|
+
constructor(e, n, i, r, s) {
|
|
8
|
+
super(`${e}:${i}:${r}: ${n}`), this.reason = n, this.filename = e, this.line = i, this.column = r, this.source = s;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
class ce {
|
|
12
|
+
start;
|
|
13
|
+
end;
|
|
14
|
+
source;
|
|
15
|
+
constructor(e, n, i) {
|
|
16
|
+
this.start = e, this.end = n, this.source = i;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
var f;
|
|
20
|
+
(function(t) {
|
|
21
|
+
t.stylesheet = "stylesheet", t.rule = "rule", t.declaration = "declaration", t.comment = "comment", t.container = "container", t.charset = "charset", t.document = "document", t.customMedia = "custom-media", t.fontFace = "font-face", t.host = "host", t.import = "import", t.keyframes = "keyframes", t.keyframe = "keyframe", t.layer = "layer", t.media = "media", t.namespace = "namespace", t.page = "page", t.startingStyle = "starting-style", t.supports = "supports";
|
|
22
|
+
})(f || (f = {}));
|
|
23
|
+
const U = (t, e, n) => {
|
|
24
|
+
let i = n, r = 1e4;
|
|
25
|
+
do {
|
|
26
|
+
const s = e.map((c) => t.indexOf(c, i));
|
|
27
|
+
s.push(t.indexOf("\\", i));
|
|
28
|
+
const l = s.filter((c) => c !== -1);
|
|
29
|
+
if (l.length === 0) return -1;
|
|
30
|
+
const u = Math.min(...l);
|
|
31
|
+
if (t[u] !== "\\") return u;
|
|
32
|
+
i = u + 2, r--;
|
|
33
|
+
} while (r > 0);
|
|
34
|
+
throw new Error("Too many escaping");
|
|
35
|
+
}, M = (t, e, n) => {
|
|
36
|
+
let i = n, r = 1e4;
|
|
37
|
+
do {
|
|
38
|
+
const s = e.map((c) => t.indexOf(c, i));
|
|
39
|
+
s.push(t.indexOf("(", i)), s.push(t.indexOf('"', i)), s.push(t.indexOf("'", i)), s.push(t.indexOf("\\", i));
|
|
40
|
+
const l = s.filter((c) => c !== -1);
|
|
41
|
+
if (l.length === 0) return -1;
|
|
42
|
+
const u = Math.min(...l);
|
|
43
|
+
switch (t[u]) {
|
|
44
|
+
case "\\":
|
|
45
|
+
i = u + 2;
|
|
46
|
+
break;
|
|
47
|
+
case "(":
|
|
48
|
+
{
|
|
49
|
+
const c = M(t, [")"], u + 1);
|
|
50
|
+
if (c === -1) return -1;
|
|
51
|
+
i = c + 1;
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case '"':
|
|
55
|
+
{
|
|
56
|
+
const c = U(t, ['"'], u + 1);
|
|
57
|
+
if (c === -1) return -1;
|
|
58
|
+
i = c + 1;
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case "'":
|
|
62
|
+
{
|
|
63
|
+
const c = U(t, ["'"], u + 1);
|
|
64
|
+
if (c === -1) return -1;
|
|
65
|
+
i = c + 1;
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
return u;
|
|
70
|
+
}
|
|
71
|
+
r--;
|
|
72
|
+
} while (r > 0);
|
|
73
|
+
throw new Error("Too many escaping");
|
|
74
|
+
}, w = /\/\*[^]*?(?:\*\/|$)/g;
|
|
75
|
+
function T(t) {
|
|
76
|
+
return t ? t.trim() : "";
|
|
77
|
+
}
|
|
78
|
+
function L(t, e) {
|
|
79
|
+
const n = t && typeof t.type == "string", i = n ? t : e;
|
|
80
|
+
for (const r in t) {
|
|
81
|
+
const s = t[r];
|
|
82
|
+
Array.isArray(s) ? s.forEach((l) => {
|
|
83
|
+
L(l, i);
|
|
84
|
+
}) : s && typeof s == "object" && L(s, i);
|
|
85
|
+
}
|
|
86
|
+
return n && Object.defineProperty(t, "parent", { configurable: !0, writable: !0, enumerable: !1, value: e || null }), t;
|
|
87
|
+
}
|
|
88
|
+
class le {
|
|
89
|
+
level = 0;
|
|
90
|
+
indentation = " ";
|
|
91
|
+
compress = !1;
|
|
92
|
+
constructor(e) {
|
|
93
|
+
typeof e?.indent == "string" && (this.indentation = e?.indent), e?.compress && (this.compress = !0);
|
|
94
|
+
}
|
|
95
|
+
emit(e, n) {
|
|
96
|
+
return e;
|
|
97
|
+
}
|
|
98
|
+
indent(e) {
|
|
99
|
+
return this.level = this.level || 1, e ? (this.level += e, "") : Array(this.level).join(this.indentation);
|
|
100
|
+
}
|
|
101
|
+
visit(e) {
|
|
102
|
+
switch (e.type) {
|
|
103
|
+
case f.stylesheet:
|
|
104
|
+
return this.stylesheet(e);
|
|
105
|
+
case f.rule:
|
|
106
|
+
return this.rule(e);
|
|
107
|
+
case f.declaration:
|
|
108
|
+
return this.declaration(e);
|
|
109
|
+
case f.comment:
|
|
110
|
+
return this.comment(e);
|
|
111
|
+
case f.container:
|
|
112
|
+
return this.container(e);
|
|
113
|
+
case f.charset:
|
|
114
|
+
return this.charset(e);
|
|
115
|
+
case f.document:
|
|
116
|
+
return this.document(e);
|
|
117
|
+
case f.customMedia:
|
|
118
|
+
return this.customMedia(e);
|
|
119
|
+
case f.fontFace:
|
|
120
|
+
return this.fontFace(e);
|
|
121
|
+
case f.host:
|
|
122
|
+
return this.host(e);
|
|
123
|
+
case f.import:
|
|
124
|
+
return this.import(e);
|
|
125
|
+
case f.keyframes:
|
|
126
|
+
return this.keyframes(e);
|
|
127
|
+
case f.keyframe:
|
|
128
|
+
return this.keyframe(e);
|
|
129
|
+
case f.layer:
|
|
130
|
+
return this.layer(e);
|
|
131
|
+
case f.media:
|
|
132
|
+
return this.media(e);
|
|
133
|
+
case f.namespace:
|
|
134
|
+
return this.namespace(e);
|
|
135
|
+
case f.page:
|
|
136
|
+
return this.page(e);
|
|
137
|
+
case f.startingStyle:
|
|
138
|
+
return this.startingStyle(e);
|
|
139
|
+
case f.supports:
|
|
140
|
+
return this.supports(e);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
mapVisit(e, n) {
|
|
144
|
+
let i = "";
|
|
145
|
+
n = n || "";
|
|
146
|
+
for (let r = 0, s = e.length; r < s; r++) i += this.visit(e[r]), n && r < s - 1 && (i += this.emit(n));
|
|
147
|
+
return i;
|
|
148
|
+
}
|
|
149
|
+
compile(e) {
|
|
150
|
+
return this.compress ? e.stylesheet.rules.map(this.visit, this).join("") : this.stylesheet(e);
|
|
151
|
+
}
|
|
152
|
+
stylesheet(e) {
|
|
153
|
+
return this.mapVisit(e.stylesheet.rules, `
|
|
154
|
+
|
|
155
|
+
`);
|
|
156
|
+
}
|
|
157
|
+
comment(e) {
|
|
158
|
+
return this.compress ? this.emit("", e.position) : this.emit(`${this.indent()}/*${e.comment}*/`, e.position);
|
|
159
|
+
}
|
|
160
|
+
container(e) {
|
|
161
|
+
return this.compress ? this.emit(`@container ${e.container}`, e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(`${this.indent()}@container ${e.container}`, e.position) + this.emit(` {
|
|
162
|
+
${this.indent(1)}`) + this.mapVisit(e.rules, `
|
|
163
|
+
|
|
164
|
+
`) + this.emit(`
|
|
165
|
+
${this.indent(-1)}${this.indent()}}`);
|
|
166
|
+
}
|
|
167
|
+
layer(e) {
|
|
168
|
+
return this.compress ? this.emit(`@layer ${e.layer}`, e.position) + (e.rules ? this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : ";") : this.emit(`${this.indent()}@layer ${e.layer}`, e.position) + (e.rules ? this.emit(` {
|
|
169
|
+
${this.indent(1)}`) + this.mapVisit(e.rules, `
|
|
170
|
+
|
|
171
|
+
`) + this.emit(`
|
|
172
|
+
${this.indent(-1)}${this.indent()}}`) : ";");
|
|
173
|
+
}
|
|
174
|
+
import(e) {
|
|
175
|
+
return this.emit(`@import ${e.import};`, e.position);
|
|
176
|
+
}
|
|
177
|
+
media(e) {
|
|
178
|
+
return this.compress ? this.emit(`@media ${e.media}`, e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(`${this.indent()}@media ${e.media}`, e.position) + this.emit(` {
|
|
179
|
+
${this.indent(1)}`) + this.mapVisit(e.rules, `
|
|
180
|
+
|
|
181
|
+
`) + this.emit(`
|
|
182
|
+
${this.indent(-1)}${this.indent()}}`);
|
|
183
|
+
}
|
|
184
|
+
document(e) {
|
|
185
|
+
const n = `@${e.vendor || ""}document ${e.document}`;
|
|
186
|
+
return this.compress ? this.emit(n, e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(n, e.position) + this.emit(` {
|
|
187
|
+
${this.indent(1)}`) + this.mapVisit(e.rules, `
|
|
188
|
+
|
|
189
|
+
`) + this.emit(`${this.indent(-1)}
|
|
190
|
+
}`);
|
|
191
|
+
}
|
|
192
|
+
charset(e) {
|
|
193
|
+
return this.emit(`@charset ${e.charset};`, e.position);
|
|
194
|
+
}
|
|
195
|
+
namespace(e) {
|
|
196
|
+
return this.emit(`@namespace ${e.namespace};`, e.position);
|
|
197
|
+
}
|
|
198
|
+
startingStyle(e) {
|
|
199
|
+
return this.compress ? this.emit("@starting-style", e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(`${this.indent()}@starting-style`, e.position) + this.emit(` {
|
|
200
|
+
${this.indent(1)}`) + this.mapVisit(e.rules, `
|
|
201
|
+
|
|
202
|
+
`) + this.emit(`
|
|
203
|
+
${this.indent(-1)}${this.indent()}}`);
|
|
204
|
+
}
|
|
205
|
+
supports(e) {
|
|
206
|
+
return this.compress ? this.emit(`@supports ${e.supports}`, e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(`${this.indent()}@supports ${e.supports}`, e.position) + this.emit(` {
|
|
207
|
+
${this.indent(1)}`) + this.mapVisit(e.rules, `
|
|
208
|
+
|
|
209
|
+
`) + this.emit(`
|
|
210
|
+
${this.indent(-1)}${this.indent()}}`);
|
|
211
|
+
}
|
|
212
|
+
keyframes(e) {
|
|
213
|
+
return this.compress ? this.emit(`@${e.vendor || ""}keyframes ${e.name}`, e.position) + this.emit("{") + this.mapVisit(e.keyframes) + this.emit("}") : this.emit(`@${e.vendor || ""}keyframes ${e.name}`, e.position) + this.emit(` {
|
|
214
|
+
${this.indent(1)}`) + this.mapVisit(e.keyframes, `
|
|
215
|
+
`) + this.emit(`${this.indent(-1)}}`);
|
|
216
|
+
}
|
|
217
|
+
keyframe(e) {
|
|
218
|
+
const n = e.declarations;
|
|
219
|
+
return this.compress ? this.emit(e.values.join(","), e.position) + this.emit("{") + this.mapVisit(n) + this.emit("}") : this.emit(this.indent()) + this.emit(e.values.join(", "), e.position) + this.emit(` {
|
|
220
|
+
${this.indent(1)}`) + this.mapVisit(n, `
|
|
221
|
+
`) + this.emit(`${this.indent(-1)}
|
|
222
|
+
${this.indent()}}
|
|
223
|
+
`);
|
|
224
|
+
}
|
|
225
|
+
page(e) {
|
|
226
|
+
if (this.compress) {
|
|
227
|
+
const i = e.selectors.length ? e.selectors.join(", ") : "";
|
|
228
|
+
return this.emit(`@page ${i}`, e.position) + this.emit("{") + this.mapVisit(e.declarations) + this.emit("}");
|
|
229
|
+
}
|
|
230
|
+
const n = e.selectors.length ? `${e.selectors.join(", ")} ` : "";
|
|
231
|
+
return this.emit(`@page ${n}`, e.position) + this.emit(`{
|
|
232
|
+
`) + this.emit(this.indent(1)) + this.mapVisit(e.declarations, `
|
|
233
|
+
`) + this.emit(this.indent(-1)) + this.emit(`
|
|
234
|
+
}`);
|
|
235
|
+
}
|
|
236
|
+
fontFace(e) {
|
|
237
|
+
return this.compress ? this.emit("@font-face", e.position) + this.emit("{") + this.mapVisit(e.declarations) + this.emit("}") : this.emit("@font-face ", e.position) + this.emit(`{
|
|
238
|
+
`) + this.emit(this.indent(1)) + this.mapVisit(e.declarations, `
|
|
239
|
+
`) + this.emit(this.indent(-1)) + this.emit(`
|
|
240
|
+
}`);
|
|
241
|
+
}
|
|
242
|
+
host(e) {
|
|
243
|
+
return this.compress ? this.emit("@host", e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit("@host", e.position) + this.emit(` {
|
|
244
|
+
${this.indent(1)}`) + this.mapVisit(e.rules, `
|
|
245
|
+
|
|
246
|
+
`) + this.emit(`${this.indent(-1)}
|
|
247
|
+
}`);
|
|
248
|
+
}
|
|
249
|
+
customMedia(e) {
|
|
250
|
+
return this.emit(`@custom-media ${e.name} ${e.media};`, e.position);
|
|
251
|
+
}
|
|
252
|
+
rule(e) {
|
|
253
|
+
const n = e.declarations;
|
|
254
|
+
if (!n.length) return "";
|
|
255
|
+
if (this.compress) return this.emit(e.selectors.join(","), e.position) + this.emit("{") + this.mapVisit(n) + this.emit("}");
|
|
256
|
+
const i = this.indent();
|
|
257
|
+
return this.emit(e.selectors.map((r) => i + r).join(`,
|
|
258
|
+
`), e.position) + this.emit(` {
|
|
259
|
+
`) + this.emit(this.indent(1)) + this.mapVisit(n, `
|
|
260
|
+
`) + this.emit(this.indent(-1)) + this.emit(`
|
|
261
|
+
${this.indent()}}`);
|
|
262
|
+
}
|
|
263
|
+
declaration(e) {
|
|
264
|
+
return this.compress ? this.emit(`${e.property}:${e.value}`, e.position) + this.emit(";") : e.property === "grid-template-areas" ? this.emit(this.indent()) + this.emit(e.property + ": " + e.value.split(`
|
|
265
|
+
`).join(`
|
|
266
|
+
`.padEnd(22) + this.indent()), e.position) + this.emit(";") : this.emit(this.indent()) + this.emit(`${e.property}: ${e.value}`, e.position) + this.emit(";");
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const ue = (t, e) => {
|
|
270
|
+
e = e || {};
|
|
271
|
+
let n = 1, i = 1;
|
|
272
|
+
function r() {
|
|
273
|
+
const a = { line: n, column: i };
|
|
274
|
+
return (o) => (o.position = new ce(a, { line: n, column: i }, e?.source || ""), E(), o);
|
|
275
|
+
}
|
|
276
|
+
const s = [];
|
|
277
|
+
function l(a) {
|
|
278
|
+
const o = new ae(e?.source || "", a, n, i, t);
|
|
279
|
+
if (!e?.silent) throw o;
|
|
280
|
+
s.push(o);
|
|
281
|
+
}
|
|
282
|
+
function u() {
|
|
283
|
+
const a = /^{\s*/.exec(t);
|
|
284
|
+
return !!a && (m(a), !0);
|
|
285
|
+
}
|
|
286
|
+
function c() {
|
|
287
|
+
const a = /^}/.exec(t);
|
|
288
|
+
return !!a && (m(a), !0);
|
|
289
|
+
}
|
|
290
|
+
function g() {
|
|
291
|
+
let a;
|
|
292
|
+
const o = [];
|
|
293
|
+
for (E(), d(o); t.length && t.charAt(0) !== "}" && (a = se() || oe(), a); ) o.push(a), d(o);
|
|
294
|
+
return o;
|
|
295
|
+
}
|
|
296
|
+
function m(a) {
|
|
297
|
+
const o = a[0];
|
|
298
|
+
return (function(h) {
|
|
299
|
+
const p = h.match(/\n/g);
|
|
300
|
+
p && (n += p.length);
|
|
301
|
+
const y = h.lastIndexOf(`
|
|
302
|
+
`);
|
|
303
|
+
i = ~y ? h.length - y : i + h.length;
|
|
304
|
+
})(o), t = t.slice(o.length), a;
|
|
305
|
+
}
|
|
306
|
+
function E() {
|
|
307
|
+
const a = /^\s*/.exec(t);
|
|
308
|
+
a && m(a);
|
|
309
|
+
}
|
|
310
|
+
function d(a) {
|
|
311
|
+
a = a || [];
|
|
312
|
+
let o = $();
|
|
313
|
+
for (; o; ) a.push(o), o = $();
|
|
314
|
+
return a;
|
|
315
|
+
}
|
|
316
|
+
function $() {
|
|
317
|
+
const a = r();
|
|
318
|
+
if (t.charAt(0) !== "/" || t.charAt(1) !== "*") return;
|
|
319
|
+
const o = /^\/\*[^]*?\*\//.exec(t);
|
|
320
|
+
return o ? (m(o), a({ type: f.comment, comment: o[0].slice(2, -2) })) : l("End of comment missing");
|
|
321
|
+
}
|
|
322
|
+
function V() {
|
|
323
|
+
const a = /^([^{]+)/.exec(t);
|
|
324
|
+
if (a)
|
|
325
|
+
return m(a), ((o, h) => {
|
|
326
|
+
const p = [];
|
|
327
|
+
let y = 0;
|
|
328
|
+
for (; y < o.length; ) {
|
|
329
|
+
const k = M(o, h, y);
|
|
330
|
+
if (k === -1) return p.push(o.substring(y)), p;
|
|
331
|
+
p.push(o.substring(y, k)), y = k + 1;
|
|
332
|
+
}
|
|
333
|
+
return p;
|
|
334
|
+
})(T(a[0]).replace(w, ""), [","]).map((o) => T(o));
|
|
335
|
+
}
|
|
336
|
+
function A() {
|
|
337
|
+
const a = r(), o = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(t);
|
|
338
|
+
if (!o) return;
|
|
339
|
+
m(o);
|
|
340
|
+
const h = T(o[0]), p = /^:\s*/.exec(t);
|
|
341
|
+
if (!p) return l("property missing ':'");
|
|
342
|
+
m(p);
|
|
343
|
+
let y = "";
|
|
344
|
+
const k = M(t, [";", "}"]);
|
|
345
|
+
k !== -1 && (y = t.substring(0, k), m([y]), y = T(y).replace(w, ""));
|
|
346
|
+
const R = a({ type: f.declaration, property: h.replace(w, ""), value: y }), _ = /^[;\s]*/.exec(t);
|
|
347
|
+
return _ && m(_), R;
|
|
348
|
+
}
|
|
349
|
+
function H() {
|
|
350
|
+
const a = [];
|
|
351
|
+
if (!u()) return l("missing '{'");
|
|
352
|
+
d(a);
|
|
353
|
+
let o = A();
|
|
354
|
+
for (; o; ) a.push(o), d(a), o = A();
|
|
355
|
+
return c() ? a : l("missing '}'");
|
|
356
|
+
}
|
|
357
|
+
function F() {
|
|
358
|
+
const a = [], o = r();
|
|
359
|
+
let h = /^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(t);
|
|
360
|
+
for (; h; ) {
|
|
361
|
+
const p = m(h);
|
|
362
|
+
a.push(p[1]);
|
|
363
|
+
const y = /^,\s*/.exec(t);
|
|
364
|
+
y && m(y), h = /^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(t);
|
|
365
|
+
}
|
|
366
|
+
if (a.length) return o({ type: f.keyframe, values: a, declarations: H() || [] });
|
|
367
|
+
}
|
|
368
|
+
const ne = C("import"), ie = C("charset"), re = C("namespace");
|
|
369
|
+
function C(a) {
|
|
370
|
+
const o = new RegExp("^@" + a + `\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);
|
|
371
|
+
return () => {
|
|
372
|
+
const h = r(), p = o.exec(t);
|
|
373
|
+
if (!p) return;
|
|
374
|
+
const y = m(p), k = { type: a };
|
|
375
|
+
return k[a] = y[1].trim(), h(k);
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function se() {
|
|
379
|
+
if (t[0] === "@") return (function() {
|
|
380
|
+
const a = r(), o = /^@([-\w]+)?keyframes\s*/.exec(t);
|
|
381
|
+
if (!o) return;
|
|
382
|
+
const h = m(o)[1], p = /^([-\w]+)\s*/.exec(t);
|
|
383
|
+
if (!p) return l("@keyframes missing name");
|
|
384
|
+
const y = m(p)[1];
|
|
385
|
+
if (!u()) return l("@keyframes missing '{'");
|
|
386
|
+
let k = d(), R = F();
|
|
387
|
+
for (; R; ) k.push(R), k = k.concat(d()), R = F();
|
|
388
|
+
return c() ? a({ type: f.keyframes, name: y, vendor: h, keyframes: k }) : l("@keyframes missing '}'");
|
|
389
|
+
})() || (function() {
|
|
390
|
+
const a = r(), o = /^@media *([^{]+)/.exec(t);
|
|
391
|
+
if (!o) return;
|
|
392
|
+
const h = T(m(o)[1]);
|
|
393
|
+
if (!u()) return l("@media missing '{'");
|
|
394
|
+
const p = d().concat(g());
|
|
395
|
+
return c() ? a({ type: f.media, media: h, rules: p }) : l("@media missing '}'");
|
|
396
|
+
})() || (function() {
|
|
397
|
+
const a = r(), o = /^@custom-media\s+(--\S+)\s+([^{;\s][^{;]*);/.exec(t);
|
|
398
|
+
if (!o) return;
|
|
399
|
+
const h = m(o);
|
|
400
|
+
return a({ type: f.customMedia, name: T(h[1]), media: T(h[2]) });
|
|
401
|
+
})() || (function() {
|
|
402
|
+
const a = r(), o = /^@supports *([^{]+)/.exec(t);
|
|
403
|
+
if (!o) return;
|
|
404
|
+
const h = T(m(o)[1]);
|
|
405
|
+
if (!u()) return l("@supports missing '{'");
|
|
406
|
+
const p = d().concat(g());
|
|
407
|
+
return c() ? a({ type: f.supports, supports: h, rules: p }) : l("@supports missing '}'");
|
|
408
|
+
})() || ne() || ie() || re() || (function() {
|
|
409
|
+
const a = r(), o = /^@([-\w]+)?document *([^{]+)/.exec(t);
|
|
410
|
+
if (!o) return;
|
|
411
|
+
const h = m(o), p = T(h[1]), y = T(h[2]);
|
|
412
|
+
if (!u()) return l("@document missing '{'");
|
|
413
|
+
const k = d().concat(g());
|
|
414
|
+
return c() ? a({ type: f.document, document: y, vendor: p, rules: k }) : l("@document missing '}'");
|
|
415
|
+
})() || (function() {
|
|
416
|
+
const a = r(), o = /^@page */.exec(t);
|
|
417
|
+
if (!o) return;
|
|
418
|
+
m(o);
|
|
419
|
+
const h = V() || [];
|
|
420
|
+
if (!u()) return l("@page missing '{'");
|
|
421
|
+
let p = d(), y = A();
|
|
422
|
+
for (; y; ) p.push(y), p = p.concat(d()), y = A();
|
|
423
|
+
return c() ? a({ type: f.page, selectors: h, declarations: p }) : l("@page missing '}'");
|
|
424
|
+
})() || (function() {
|
|
425
|
+
const a = r(), o = /^@host\s*/.exec(t);
|
|
426
|
+
if (!o) return;
|
|
427
|
+
if (m(o), !u()) return l("@host missing '{'");
|
|
428
|
+
const h = d().concat(g());
|
|
429
|
+
return c() ? a({ type: f.host, rules: h }) : l("@host missing '}'");
|
|
430
|
+
})() || (function() {
|
|
431
|
+
const a = r(), o = /^@font-face\s*/.exec(t);
|
|
432
|
+
if (!o) return;
|
|
433
|
+
if (m(o), !u()) return l("@font-face missing '{'");
|
|
434
|
+
let h = d(), p = A();
|
|
435
|
+
for (; p; ) h.push(p), h = h.concat(d()), p = A();
|
|
436
|
+
return c() ? a({ type: f.fontFace, declarations: h }) : l("@font-face missing '}'");
|
|
437
|
+
})() || (function() {
|
|
438
|
+
const a = r(), o = /^@container *([^{]+)/.exec(t);
|
|
439
|
+
if (!o) return;
|
|
440
|
+
const h = T(m(o)[1]);
|
|
441
|
+
if (!u()) return l("@container missing '{'");
|
|
442
|
+
const p = d().concat(g());
|
|
443
|
+
return c() ? a({ type: f.container, container: h, rules: p }) : l("@container missing '}'");
|
|
444
|
+
})() || (function() {
|
|
445
|
+
const a = r(), o = /^@starting-style\s*/.exec(t);
|
|
446
|
+
if (!o) return;
|
|
447
|
+
if (m(o), !u()) return l("@starting-style missing '{'");
|
|
448
|
+
const h = d().concat(g());
|
|
449
|
+
return c() ? a({ type: f.startingStyle, rules: h }) : l("@starting-style missing '}'");
|
|
450
|
+
})() || (function() {
|
|
451
|
+
const a = r(), o = /^@layer *([^{;@]+)/.exec(t);
|
|
452
|
+
if (!o) return;
|
|
453
|
+
const h = T(m(o)[1]);
|
|
454
|
+
if (!u()) {
|
|
455
|
+
const y = /^[;\s]*/.exec(t);
|
|
456
|
+
return y && m(y), a({ type: f.layer, layer: h });
|
|
457
|
+
}
|
|
458
|
+
const p = d().concat(g());
|
|
459
|
+
return c() ? a({ type: f.layer, layer: h, rules: p }) : l("@layer missing '}'");
|
|
460
|
+
})();
|
|
461
|
+
}
|
|
462
|
+
function oe() {
|
|
463
|
+
const a = r(), o = V();
|
|
464
|
+
return o ? (d(), a({ type: f.rule, selectors: o, declarations: H() || [] })) : l("selector missing");
|
|
465
|
+
}
|
|
466
|
+
return L((function() {
|
|
467
|
+
const a = g();
|
|
468
|
+
return { type: f.stylesheet, stylesheet: { source: e?.source, rules: a, parsingErrors: s } };
|
|
469
|
+
})());
|
|
470
|
+
}, me = (t, e) => new le(e || {}).compile(t);
|
|
471
|
+
var he = { parse: ue, stringify: me };
|
|
472
|
+
function fe(t, e) {
|
|
2
473
|
const n = t;
|
|
3
|
-
return n.isBlock =
|
|
474
|
+
return n.isBlock = B(n), n.isCode = n.nodeName === "CODE" || n.parentNode?.isCode, n.isBlank = pe(n), n.flankingWhitespace = de(n, e), n;
|
|
4
475
|
}
|
|
5
|
-
function
|
|
6
|
-
return !
|
|
476
|
+
function pe(t) {
|
|
477
|
+
return !X(t) && !Ee(t) && /^\s*$/i.test(t.textContent || "") && !ke(t) && !Te(t);
|
|
7
478
|
}
|
|
8
|
-
function
|
|
479
|
+
function de(t, e) {
|
|
9
480
|
const n = t;
|
|
10
481
|
if (n.isBlock || e.preformattedCode && n.isCode)
|
|
11
482
|
return { leading: "", trailing: "" };
|
|
12
|
-
const
|
|
13
|
-
return
|
|
483
|
+
const i = ge(t.textContent || "");
|
|
484
|
+
return i.leadingAscii && j("left", t, e) && (i.leading = i.leadingNonAscii), i.trailingAscii && j("right", t, e) && (i.trailing = i.trailingNonAscii), { leading: i.leading, trailing: i.trailing };
|
|
14
485
|
}
|
|
15
|
-
function
|
|
486
|
+
function ge(t) {
|
|
16
487
|
const e = t.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
|
|
17
488
|
return e ? {
|
|
18
489
|
leading: e[1],
|
|
@@ -32,31 +503,32 @@ function $(t) {
|
|
|
32
503
|
trailingAscii: ""
|
|
33
504
|
};
|
|
34
505
|
}
|
|
35
|
-
function
|
|
36
|
-
let
|
|
37
|
-
return t === "left" ? (
|
|
506
|
+
function j(t, e, n) {
|
|
507
|
+
let i, r, s;
|
|
508
|
+
return t === "left" ? (i = e.previousSibling, r = / $/) : (i = e.nextSibling, r = /^ /), i && (i.nodeType === 3 ? s = r.test(i.nodeValue || "") : n.preformattedCode && i.nodeName === "CODE" ? s = !1 : i.nodeType === 1 && !B(i) && (s = r.test(i.textContent || ""))), s || !1;
|
|
38
509
|
}
|
|
39
|
-
const
|
|
510
|
+
const x = {
|
|
40
511
|
Element: 1,
|
|
41
512
|
Text: 3,
|
|
42
|
-
CDATASection: 4
|
|
513
|
+
CDATASection: 4,
|
|
514
|
+
Comment: 8
|
|
43
515
|
};
|
|
44
|
-
function
|
|
516
|
+
function v(t, e) {
|
|
45
517
|
return Array(e + 1).join(t);
|
|
46
518
|
}
|
|
47
|
-
function
|
|
519
|
+
function K(t) {
|
|
48
520
|
return t.replace(/^\n*/, "");
|
|
49
521
|
}
|
|
50
|
-
function
|
|
522
|
+
function Y(t) {
|
|
51
523
|
let e = t.length;
|
|
52
524
|
for (; e > 0 && t[e - 1] === `
|
|
53
525
|
`; ) e--;
|
|
54
526
|
return t.substring(0, e);
|
|
55
527
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
528
|
+
function q(t) {
|
|
529
|
+
return Y(K(t));
|
|
58
530
|
}
|
|
59
|
-
const
|
|
531
|
+
const ye = [
|
|
60
532
|
"ADDRESS",
|
|
61
533
|
"ARTICLE",
|
|
62
534
|
"ASIDE",
|
|
@@ -107,10 +579,10 @@ const F = [
|
|
|
107
579
|
"TR",
|
|
108
580
|
"UL"
|
|
109
581
|
];
|
|
110
|
-
function
|
|
111
|
-
return
|
|
582
|
+
function B(t) {
|
|
583
|
+
return P(t, ye);
|
|
112
584
|
}
|
|
113
|
-
const
|
|
585
|
+
const Q = [
|
|
114
586
|
"AREA",
|
|
115
587
|
"BASE",
|
|
116
588
|
"BR",
|
|
@@ -128,13 +600,13 @@ const D = [
|
|
|
128
600
|
"TRACK",
|
|
129
601
|
"WBR"
|
|
130
602
|
];
|
|
131
|
-
function
|
|
132
|
-
return
|
|
603
|
+
function X(t) {
|
|
604
|
+
return P(t, Q);
|
|
133
605
|
}
|
|
134
|
-
function
|
|
135
|
-
return
|
|
606
|
+
function ke(t) {
|
|
607
|
+
return Z(t, Q);
|
|
136
608
|
}
|
|
137
|
-
const
|
|
609
|
+
const J = [
|
|
138
610
|
"A",
|
|
139
611
|
"TABLE",
|
|
140
612
|
"THEAD",
|
|
@@ -146,7 +618,7 @@ const M = [
|
|
|
146
618
|
"SCRIPT",
|
|
147
619
|
"AUDIO",
|
|
148
620
|
"VIDEO"
|
|
149
|
-
],
|
|
621
|
+
], Ne = [
|
|
150
622
|
"P",
|
|
151
623
|
"BR",
|
|
152
624
|
"H1",
|
|
@@ -177,32 +649,54 @@ const M = [
|
|
|
177
649
|
"TH",
|
|
178
650
|
"TD"
|
|
179
651
|
];
|
|
180
|
-
function
|
|
181
|
-
return
|
|
652
|
+
function Ee(t) {
|
|
653
|
+
return P(t, J);
|
|
182
654
|
}
|
|
183
|
-
function
|
|
184
|
-
return
|
|
655
|
+
function Te(t) {
|
|
656
|
+
return Z(t, J);
|
|
185
657
|
}
|
|
186
|
-
function
|
|
658
|
+
function P(t, e) {
|
|
187
659
|
return e.indexOf(t.nodeName) >= 0;
|
|
188
660
|
}
|
|
189
|
-
function
|
|
661
|
+
function Z(t, e) {
|
|
190
662
|
return e.some(function(n) {
|
|
191
|
-
return t.nodeType !==
|
|
663
|
+
return t.nodeType !== x.Element ? !1 : t.getElementsByTagName(n).length;
|
|
192
664
|
});
|
|
193
665
|
}
|
|
194
|
-
function
|
|
666
|
+
function ee(t) {
|
|
195
667
|
return t ? t.replace(/(\n+\s*)+/g, `
|
|
196
668
|
`) : "";
|
|
197
669
|
}
|
|
198
|
-
function
|
|
199
|
-
return
|
|
670
|
+
function xe(t) {
|
|
671
|
+
return ee(t).replace(/[\t\r\n]+/g, " ").replace(/ {2,}/g, " ").trim();
|
|
672
|
+
}
|
|
673
|
+
function b(t) {
|
|
674
|
+
return ee(t).replace(/[\t\r\n]+/g, " ");
|
|
675
|
+
}
|
|
676
|
+
function $e(t) {
|
|
677
|
+
const e = t.parentNode;
|
|
678
|
+
return e ? e.nodeType === x.Element && e.classList && e.classList.contains("code") && e.nodeName === "TD" && t.nodeName === "PRE" : !1;
|
|
200
679
|
}
|
|
201
|
-
function
|
|
202
|
-
|
|
680
|
+
function Ae(t) {
|
|
681
|
+
if (t.nodeName !== "PRE" || t.nodeType !== x.Element)
|
|
682
|
+
return !1;
|
|
683
|
+
const e = t.getAttribute("style");
|
|
684
|
+
if (!e)
|
|
685
|
+
return !1;
|
|
686
|
+
const n = he.parse("pre {" + e + "}");
|
|
687
|
+
if (!n.stylesheet.rules.length)
|
|
688
|
+
return !1;
|
|
689
|
+
const i = n.stylesheet.rules[0];
|
|
690
|
+
if (!("declarations" in i) || !i.declarations)
|
|
691
|
+
return !1;
|
|
692
|
+
const r = i.declarations.find((l) => "property" in l ? l.property.toLowerCase() === "font-family" : !1);
|
|
693
|
+
return !r || "value" in r && !r.value ? !1 : "value" in r && r.value.split(",").map((l) => l.trim().toLowerCase()).indexOf("monospace") >= 0;
|
|
694
|
+
}
|
|
695
|
+
function te(t) {
|
|
696
|
+
return $e(t) || Ae(t) ? !0 : t.nodeName === "PRE" && t.firstChild && t.firstChild.nodeName === "CODE" || !1;
|
|
203
697
|
}
|
|
204
|
-
const
|
|
205
|
-
|
|
698
|
+
const N = {};
|
|
699
|
+
N.paragraph = {
|
|
206
700
|
filter: "p",
|
|
207
701
|
replacement: function(t) {
|
|
208
702
|
return `
|
|
@@ -212,44 +706,44 @@ f.paragraph = {
|
|
|
212
706
|
`;
|
|
213
707
|
}
|
|
214
708
|
};
|
|
215
|
-
|
|
709
|
+
N.lineBreak = {
|
|
216
710
|
filter: "br",
|
|
217
711
|
replacement: function(t, e, n) {
|
|
218
712
|
return n.br + `
|
|
219
713
|
`;
|
|
220
714
|
}
|
|
221
715
|
};
|
|
222
|
-
|
|
716
|
+
N.heading = {
|
|
223
717
|
filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
|
|
224
718
|
replacement: function(t, e, n) {
|
|
225
|
-
const
|
|
226
|
-
if (n.headingStyle === "setext" &&
|
|
227
|
-
const
|
|
719
|
+
const i = Number(e.nodeName.charAt(1));
|
|
720
|
+
if (n.headingStyle === "setext" && i < 3) {
|
|
721
|
+
const r = v(i === 1 ? "=" : "-", t.length);
|
|
228
722
|
return `
|
|
229
723
|
|
|
230
724
|
` + t + `
|
|
231
|
-
` +
|
|
725
|
+
` + r + `
|
|
232
726
|
|
|
233
727
|
`;
|
|
234
728
|
} else
|
|
235
729
|
return `
|
|
236
730
|
|
|
237
|
-
` +
|
|
731
|
+
` + v("#", i) + " " + t + `
|
|
238
732
|
|
|
239
733
|
`;
|
|
240
734
|
}
|
|
241
735
|
};
|
|
242
|
-
|
|
736
|
+
N.blockquote = {
|
|
243
737
|
filter: "blockquote",
|
|
244
738
|
replacement: function(t) {
|
|
245
|
-
return t =
|
|
739
|
+
return t = q(t).replace(/^/gm, "> "), `
|
|
246
740
|
|
|
247
741
|
` + t + `
|
|
248
742
|
|
|
249
743
|
`;
|
|
250
744
|
}
|
|
251
745
|
};
|
|
252
|
-
|
|
746
|
+
N.list = {
|
|
253
747
|
filter: ["ul", "ol"],
|
|
254
748
|
replacement: function(t, e) {
|
|
255
749
|
const n = e.parentNode;
|
|
@@ -261,36 +755,36 @@ f.list = {
|
|
|
261
755
|
`;
|
|
262
756
|
}
|
|
263
757
|
};
|
|
264
|
-
|
|
758
|
+
N.listItem = {
|
|
265
759
|
filter: "li",
|
|
266
760
|
replacement: function(t, e, n) {
|
|
267
|
-
let
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
const d =
|
|
271
|
-
|
|
761
|
+
let i = n.bulletListMarker + " ".repeat(n.listMarkerSpaceCount);
|
|
762
|
+
const r = e.parentNode;
|
|
763
|
+
if (r.nodeName === "OL") {
|
|
764
|
+
const d = r.getAttribute("start"), $ = Array.prototype.indexOf.call(r.children, e);
|
|
765
|
+
i = (d ? Number(d) + $ : $ + 1) + "." + " ".repeat(n.listMarkerSpaceCount);
|
|
272
766
|
}
|
|
273
|
-
const
|
|
274
|
-
if (t =
|
|
275
|
-
` : ""), e.childNodes.length > 0 && Array.from(e.childNodes).every((d) => d.nodeType ===
|
|
767
|
+
const s = /\n$/.test(t);
|
|
768
|
+
if (t = q(t) + (s ? `
|
|
769
|
+
` : ""), e.childNodes.length > 0 && Array.from(e.childNodes).every((d) => d.nodeType === x.Text && /^\s*$/.test(d.nodeValue || "") || d.nodeType === x.Element && ["UL", "OL"].includes(d.nodeName)) && t.trim() !== "")
|
|
276
770
|
return t + (e.nextSibling ? `
|
|
277
771
|
` : "");
|
|
278
|
-
let
|
|
279
|
-
for (;
|
|
280
|
-
if (
|
|
281
|
-
const d =
|
|
282
|
-
d && d.nodeName === "LI" &&
|
|
772
|
+
let u = 0, c = r;
|
|
773
|
+
for (; c; ) {
|
|
774
|
+
if (c.nodeName === "UL" || c.nodeName === "OL") {
|
|
775
|
+
const d = c.parentNode;
|
|
776
|
+
d && d.nodeName === "LI" && u++;
|
|
283
777
|
}
|
|
284
|
-
|
|
778
|
+
c = c.parentNode;
|
|
285
779
|
}
|
|
286
|
-
let
|
|
287
|
-
const
|
|
288
|
-
return t = t.replace(
|
|
289
|
-
` +
|
|
780
|
+
let g = n.listItemIndent === "tab" ? " " : " ".repeat(n.listItemIndentSpaceCount), m = g.repeat(u);
|
|
781
|
+
const E = /\n(?!\s*(?:\d+\.\s|[-+*]\s))/gm;
|
|
782
|
+
return t = t.replace(E, `
|
|
783
|
+
` + g), m + i + t + (e.nextSibling ? `
|
|
290
784
|
` : "");
|
|
291
785
|
}
|
|
292
786
|
};
|
|
293
|
-
|
|
787
|
+
N.indentedCodeBlock = {
|
|
294
788
|
filter: function(t, e) {
|
|
295
789
|
return !!(e && e.codeBlockStyle === "indented" && t.nodeName === "PRE" && t.firstChild && t.firstChild.nodeName === "CODE");
|
|
296
790
|
},
|
|
@@ -303,28 +797,28 @@ f.indentedCodeBlock = {
|
|
|
303
797
|
`;
|
|
304
798
|
}
|
|
305
799
|
};
|
|
306
|
-
|
|
800
|
+
N.fencedCodeBlock = {
|
|
307
801
|
filter: function(t, e) {
|
|
308
802
|
return !!(e && e.codeBlockStyle === "fenced" && t.nodeName === "PRE");
|
|
309
803
|
},
|
|
310
804
|
replacement: function(t, e, n) {
|
|
311
|
-
const
|
|
312
|
-
let
|
|
313
|
-
const
|
|
805
|
+
const i = e, r = i.firstChild, s = r && r.nodeName === "CODE" ? r : i, u = ((s.getAttribute("class") || "").match(/(?:lang|language)-(\S+)/) || [null, ""])[1], c = s.textContent || "", g = n.fence?.charAt(0) || "`";
|
|
806
|
+
let m = 3;
|
|
807
|
+
const E = new RegExp("^" + g + "{3,}", "gm");
|
|
314
808
|
let d;
|
|
315
|
-
for (; d =
|
|
316
|
-
d[0].length >=
|
|
317
|
-
const
|
|
809
|
+
for (; d = E.exec(c); )
|
|
810
|
+
d[0].length >= m && (m = d[0].length + 1);
|
|
811
|
+
const $ = v(g, m);
|
|
318
812
|
return `
|
|
319
813
|
|
|
320
|
-
` +
|
|
321
|
-
` +
|
|
322
|
-
` +
|
|
814
|
+
` + $ + u + `
|
|
815
|
+
` + c.replace(/\n$/, "") + `
|
|
816
|
+
` + $ + `
|
|
323
817
|
|
|
324
818
|
`;
|
|
325
819
|
}
|
|
326
820
|
};
|
|
327
|
-
|
|
821
|
+
N.horizontalRule = {
|
|
328
822
|
filter: "hr",
|
|
329
823
|
replacement: function(t, e, n) {
|
|
330
824
|
return `
|
|
@@ -334,48 +828,48 @@ f.horizontalRule = {
|
|
|
334
828
|
`;
|
|
335
829
|
}
|
|
336
830
|
};
|
|
337
|
-
|
|
831
|
+
N.inlineLink = {
|
|
338
832
|
filter: function(t, e) {
|
|
339
833
|
return !!(e?.linkStyle === "inlined" && t.nodeName === "A" && t.getAttribute("href"));
|
|
340
834
|
},
|
|
341
835
|
replacement: function(t, e) {
|
|
342
|
-
const n =
|
|
343
|
-
let
|
|
344
|
-
const
|
|
345
|
-
return
|
|
836
|
+
const n = xe(t);
|
|
837
|
+
let i = e.getAttribute("href")?.replace(/([()])/g, "\\$1"), r;
|
|
838
|
+
const s = e.getAttribute("title");
|
|
839
|
+
return s ? r = ' "' + b(s).replace(/"/g, '\\"') + '"' : r = "", "[" + n + "](" + i + r + ")";
|
|
346
840
|
}
|
|
347
841
|
};
|
|
348
|
-
const
|
|
842
|
+
const D = {
|
|
349
843
|
filter: function(t, e) {
|
|
350
844
|
return !!(e && e.linkStyle === "referenced" && t.nodeName === "A" && t.getAttribute("href"));
|
|
351
845
|
},
|
|
352
846
|
replacement: function(t, e, n) {
|
|
353
|
-
const
|
|
354
|
-
let
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
const
|
|
358
|
-
let
|
|
847
|
+
const i = D, r = e.getAttribute("href");
|
|
848
|
+
let s;
|
|
849
|
+
const l = e.getAttribute("title");
|
|
850
|
+
l ? s = ' "' + b(l) + '"' : s = "";
|
|
851
|
+
const u = r + s;
|
|
852
|
+
let c, g;
|
|
359
853
|
switch (n.linkReferenceStyle) {
|
|
360
854
|
case "collapsed":
|
|
361
|
-
|
|
855
|
+
c = "[" + t + "][]", g = "[" + t + "]: " + u;
|
|
362
856
|
break;
|
|
363
857
|
case "shortcut":
|
|
364
|
-
|
|
858
|
+
c = "[" + t + "]", g = "[" + t + "]: " + u;
|
|
365
859
|
break;
|
|
366
860
|
default: {
|
|
367
|
-
let
|
|
368
|
-
const
|
|
369
|
-
n.linkReferenceDeduplication === "full" &&
|
|
861
|
+
let m;
|
|
862
|
+
const E = i.urlReferenceIdMap.get(u);
|
|
863
|
+
n.linkReferenceDeduplication === "full" && E ? (m = E, g = "[" + m + "]: " + r + s) : (m = i.references.length + 1, i.urlReferenceIdMap.set(u, m), g = "[" + m + "]: " + r + s, i.references.push(g)), c = "[" + t + "][" + m + "]";
|
|
370
864
|
break;
|
|
371
865
|
}
|
|
372
866
|
}
|
|
373
|
-
return n.linkReferenceStyle !== "full" && (n.linkReferenceDeduplication === "full" ?
|
|
867
|
+
return n.linkReferenceStyle !== "full" && (n.linkReferenceDeduplication === "full" ? i.urlReferenceIdMap.has(u) || (i.urlReferenceIdMap.set(u, 1), i.references.push(g)) : i.references.push(g)), c;
|
|
374
868
|
},
|
|
375
869
|
references: [],
|
|
376
870
|
urlReferenceIdMap: /* @__PURE__ */ new Map(),
|
|
377
871
|
append: () => {
|
|
378
|
-
const t =
|
|
872
|
+
const t = D;
|
|
379
873
|
let e = "";
|
|
380
874
|
return t.references && t.references.length && (e = `
|
|
381
875
|
|
|
@@ -385,36 +879,36 @@ const R = {
|
|
|
385
879
|
`, t.references = [], t.urlReferenceIdMap = /* @__PURE__ */ new Map()), e;
|
|
386
880
|
}
|
|
387
881
|
};
|
|
388
|
-
|
|
389
|
-
|
|
882
|
+
N.referenceLink = D;
|
|
883
|
+
N.emphasis = {
|
|
390
884
|
filter: ["em", "i"],
|
|
391
885
|
replacement: (t, e, n) => (t = t.trim(), t ? n.emDelimiter + t + n.emDelimiter : "")
|
|
392
886
|
};
|
|
393
|
-
|
|
887
|
+
N.strong = {
|
|
394
888
|
filter: ["strong", "b"],
|
|
395
889
|
replacement: (t, e, n) => (t = t.trim(), t ? n.strongDelimiter + t + n.strongDelimiter : "")
|
|
396
890
|
};
|
|
397
|
-
|
|
891
|
+
N.code = {
|
|
398
892
|
filter: (t) => {
|
|
399
|
-
const e = t.
|
|
400
|
-
return t.nodeName === "CODE" && !
|
|
893
|
+
const e = t.parentNode, n = te(e);
|
|
894
|
+
return t.nodeName === "CODE" && !n;
|
|
401
895
|
},
|
|
402
896
|
replacement: (t) => {
|
|
403
897
|
const e = t.replace(/\r?\n|\r/g, " "), n = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "";
|
|
404
|
-
let
|
|
405
|
-
const
|
|
406
|
-
for (;
|
|
407
|
-
return
|
|
898
|
+
let i = "`";
|
|
899
|
+
const r = e.match(/`+/gm) || [];
|
|
900
|
+
for (; r.includes(i); ) i = i + "`";
|
|
901
|
+
return i + n + e + n + i;
|
|
408
902
|
}
|
|
409
903
|
};
|
|
410
|
-
|
|
904
|
+
N.image = {
|
|
411
905
|
filter: "img",
|
|
412
906
|
replacement: function(t, e) {
|
|
413
|
-
const n = e.getAttribute("alt"),
|
|
414
|
-
return
|
|
907
|
+
const n = e.getAttribute("alt"), i = n ? b(n) : "", r = e.getAttribute("src") || "", s = e.getAttribute("title"), l = s ? b(s) : "", u = l ? ' "' + l + '"' : "";
|
|
908
|
+
return r ? "" : "";
|
|
415
909
|
}
|
|
416
910
|
};
|
|
417
|
-
class
|
|
911
|
+
class Re {
|
|
418
912
|
options;
|
|
419
913
|
_keep;
|
|
420
914
|
_remove;
|
|
@@ -461,110 +955,110 @@ class K {
|
|
|
461
955
|
replacement: this.markdownIncludingHtmlReplacement
|
|
462
956
|
};
|
|
463
957
|
let n;
|
|
464
|
-
return (n =
|
|
958
|
+
return (n = O(this.array, e, this.options)) || (n = O(this._keep, e, this.options)) || (n = O(this._remove, e, this.options)) ? n : this.defaultRule;
|
|
465
959
|
}
|
|
466
960
|
/// Check if an element is unsupported for Markdown conversion.
|
|
467
961
|
isUnsupportedElement(e) {
|
|
468
962
|
const n = e.nodeName;
|
|
469
963
|
if (n === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE") {
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
for (let
|
|
473
|
-
if (
|
|
964
|
+
const i = e.firstChild;
|
|
965
|
+
if (i.attributes && i.attributes.length > 0) {
|
|
966
|
+
for (let r = 0; r < i.attributes.length; r++)
|
|
967
|
+
if (i.attributes[r].name.toLowerCase() !== "class")
|
|
474
968
|
return !0;
|
|
475
969
|
}
|
|
476
970
|
}
|
|
477
971
|
if (e.attributes && e.attributes.length > 0)
|
|
478
972
|
switch (n) {
|
|
479
973
|
case "IMG":
|
|
480
|
-
for (let
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
974
|
+
for (let r = 0; r < e.attributes.length; r++) {
|
|
975
|
+
const s = e.attributes[r].name.toLowerCase();
|
|
976
|
+
if (s !== "src" && s !== "alt" && s !== "title")
|
|
483
977
|
return !0;
|
|
484
978
|
}
|
|
485
979
|
return !1;
|
|
486
980
|
case "A":
|
|
487
|
-
for (let
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
981
|
+
for (let r = 0; r < e.attributes.length; r++) {
|
|
982
|
+
const s = e.attributes[r].name.toLowerCase();
|
|
983
|
+
if (s !== "href" && s !== "title")
|
|
490
984
|
return !0;
|
|
491
985
|
}
|
|
492
986
|
return !1;
|
|
493
987
|
case "CODE":
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
for (let
|
|
497
|
-
if (e.attributes[
|
|
988
|
+
const i = e.parentNode;
|
|
989
|
+
if (i && i.nodeName === "PRE") {
|
|
990
|
+
for (let r = 0; r < e.attributes.length; r++)
|
|
991
|
+
if (e.attributes[r].name.toLowerCase() !== "class")
|
|
498
992
|
return !0;
|
|
499
993
|
return !1;
|
|
500
994
|
}
|
|
501
995
|
default:
|
|
502
996
|
return !0;
|
|
503
997
|
}
|
|
504
|
-
return
|
|
998
|
+
return Ne.indexOf(n) === -1;
|
|
505
999
|
}
|
|
506
1000
|
forEach(e) {
|
|
507
1001
|
for (let n = 0; n < this.array.length; n++)
|
|
508
1002
|
e(this.array[n], n);
|
|
509
1003
|
}
|
|
510
1004
|
}
|
|
511
|
-
function
|
|
512
|
-
for (let
|
|
513
|
-
const
|
|
514
|
-
if (
|
|
1005
|
+
function O(t, e, n) {
|
|
1006
|
+
for (let i = 0; i < t.length; i++) {
|
|
1007
|
+
const r = t[i];
|
|
1008
|
+
if (be(r, e, n)) return r;
|
|
515
1009
|
}
|
|
516
1010
|
}
|
|
517
|
-
function
|
|
518
|
-
const
|
|
519
|
-
if (typeof
|
|
520
|
-
if (
|
|
1011
|
+
function be(t, e, n) {
|
|
1012
|
+
const i = t.filter;
|
|
1013
|
+
if (typeof i == "string") {
|
|
1014
|
+
if (i === e.nodeName.toLowerCase())
|
|
521
1015
|
return !0;
|
|
522
|
-
} else if (Array.isArray(
|
|
523
|
-
if (
|
|
1016
|
+
} else if (Array.isArray(i)) {
|
|
1017
|
+
if (i.indexOf(e.nodeName.toLowerCase()) > -1)
|
|
524
1018
|
return !0;
|
|
525
|
-
} else if (typeof
|
|
526
|
-
if (
|
|
1019
|
+
} else if (typeof i == "function") {
|
|
1020
|
+
if (i(e, n))
|
|
527
1021
|
return !0;
|
|
528
1022
|
} else
|
|
529
1023
|
throw new TypeError("`filter` needs to be a string, array, or function");
|
|
530
1024
|
return !1;
|
|
531
1025
|
}
|
|
532
|
-
function
|
|
533
|
-
const e = t.element, n = t.isBlock,
|
|
534
|
-
return
|
|
1026
|
+
function Ce(t) {
|
|
1027
|
+
const e = t.element, n = t.isBlock, i = t.isVoid, r = t.isPre || function(g) {
|
|
1028
|
+
return g.nodeName === "PRE";
|
|
535
1029
|
};
|
|
536
|
-
if (!e.firstChild ||
|
|
537
|
-
let
|
|
538
|
-
for (;
|
|
539
|
-
if (
|
|
540
|
-
const
|
|
541
|
-
let
|
|
542
|
-
if ((!
|
|
543
|
-
|
|
1030
|
+
if (!e.firstChild || r(e)) return;
|
|
1031
|
+
let s = null, l = !1, u = null, c = z(u, e, r);
|
|
1032
|
+
for (; c !== e; ) {
|
|
1033
|
+
if (c.nodeType === x.Text || c.nodeType === x.CDATASection) {
|
|
1034
|
+
const m = c;
|
|
1035
|
+
let E = m.data.replace(/[ \r\n\t]+/g, " ");
|
|
1036
|
+
if ((!s || / $/.test(s.data)) && !l && E[0] === " " && (E = E.substr(1)), !E) {
|
|
1037
|
+
c = S(c);
|
|
544
1038
|
continue;
|
|
545
1039
|
}
|
|
546
|
-
|
|
547
|
-
} else if (
|
|
548
|
-
n(
|
|
1040
|
+
m.data = E, s = m;
|
|
1041
|
+
} else if (c.nodeType === x.Element)
|
|
1042
|
+
n(c) || c.nodeName === "BR" ? (s && (s.data = s.data.replace(/ $/, "")), s = null, l = !1) : i(c) || r(c) ? (s = null, l = !0) : s && (l = !1);
|
|
549
1043
|
else {
|
|
550
|
-
|
|
1044
|
+
c = S(c);
|
|
551
1045
|
continue;
|
|
552
1046
|
}
|
|
553
|
-
const
|
|
554
|
-
|
|
1047
|
+
const g = z(u, c, r);
|
|
1048
|
+
u = c, c = g;
|
|
555
1049
|
}
|
|
556
|
-
|
|
1050
|
+
s && (s.data = s.data.replace(/ $/, ""), s.data || S(s));
|
|
557
1051
|
}
|
|
558
|
-
function
|
|
1052
|
+
function S(t) {
|
|
559
1053
|
const e = t.nextSibling ?? t.parentNode;
|
|
560
1054
|
return t.parentNode && t.parentNode.removeChild(t), e;
|
|
561
1055
|
}
|
|
562
|
-
function
|
|
1056
|
+
function z(t, e, n) {
|
|
563
1057
|
return t && t.parentNode === e || n(e) ? e.nextSibling ?? e.parentNode : e.firstChild ?? e.nextSibling ?? e.parentNode;
|
|
564
1058
|
}
|
|
565
|
-
const
|
|
566
|
-
function
|
|
567
|
-
const t = typeof
|
|
1059
|
+
const I = typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
|
|
1060
|
+
function we() {
|
|
1061
|
+
const t = typeof I.DOMParser < "u" ? I.DOMParser : void 0;
|
|
568
1062
|
let e = !1;
|
|
569
1063
|
if (!t) return !1;
|
|
570
1064
|
try {
|
|
@@ -573,55 +1067,55 @@ function q() {
|
|
|
573
1067
|
}
|
|
574
1068
|
return e;
|
|
575
1069
|
}
|
|
576
|
-
class
|
|
1070
|
+
class W {
|
|
577
1071
|
// This will be assigned per environment below
|
|
578
1072
|
parseFromString(e, n) {
|
|
579
1073
|
throw new Error("Not implemented");
|
|
580
1074
|
}
|
|
581
1075
|
}
|
|
582
|
-
function
|
|
1076
|
+
function Oe() {
|
|
583
1077
|
if (typeof window < "u" && typeof document < "u" && (typeof process > "u" || process.browser), typeof window < "u") {
|
|
584
|
-
class t extends
|
|
585
|
-
parseFromString(n,
|
|
586
|
-
const
|
|
587
|
-
return
|
|
1078
|
+
class t extends W {
|
|
1079
|
+
parseFromString(n, i) {
|
|
1080
|
+
const r = document.implementation.createHTMLDocument("");
|
|
1081
|
+
return r.open(), r.write(n), r.close(), r;
|
|
588
1082
|
}
|
|
589
1083
|
}
|
|
590
1084
|
return new t();
|
|
591
1085
|
} else {
|
|
592
1086
|
const t = require("@mixmark-io/domino");
|
|
593
|
-
class e extends
|
|
594
|
-
parseFromString(
|
|
595
|
-
return t.createDocument(
|
|
1087
|
+
class e extends W {
|
|
1088
|
+
parseFromString(i, r) {
|
|
1089
|
+
return t.createDocument(i);
|
|
596
1090
|
}
|
|
597
1091
|
}
|
|
598
1092
|
return new e();
|
|
599
1093
|
}
|
|
600
1094
|
}
|
|
601
|
-
const
|
|
602
|
-
function
|
|
1095
|
+
const Se = () => we() ? new I.DOMParser() : Oe();
|
|
1096
|
+
function Me(t, { preformattedCode: e }) {
|
|
603
1097
|
let n;
|
|
604
|
-
return typeof t == "string" ? n =
|
|
1098
|
+
return typeof t == "string" ? n = ve().parseFromString(
|
|
605
1099
|
// DOM parsers arrange elements in the <head> and <body>.
|
|
606
1100
|
// Wrapping in a custom element ensures elements are reliably arranged in
|
|
607
1101
|
// a single element.
|
|
608
1102
|
'<x-turnish id="turnish-root">' + t + "</x-turnish>",
|
|
609
1103
|
"text/html"
|
|
610
|
-
).getElementById("turnish-root") : n = t.cloneNode(!0),
|
|
1104
|
+
).getElementById("turnish-root") : n = t.cloneNode(!0), Ce({
|
|
611
1105
|
element: n,
|
|
612
|
-
isBlock:
|
|
613
|
-
isVoid:
|
|
614
|
-
isPre: e ?
|
|
1106
|
+
isBlock: B,
|
|
1107
|
+
isVoid: X,
|
|
1108
|
+
isPre: e ? De : void 0
|
|
615
1109
|
}), n;
|
|
616
1110
|
}
|
|
617
|
-
let
|
|
618
|
-
function
|
|
619
|
-
return
|
|
1111
|
+
let Le;
|
|
1112
|
+
function ve() {
|
|
1113
|
+
return Le ??= Se();
|
|
620
1114
|
}
|
|
621
|
-
function
|
|
1115
|
+
function De(t) {
|
|
622
1116
|
return t.nodeName === "PRE" || t.nodeName === "CODE";
|
|
623
1117
|
}
|
|
624
|
-
const
|
|
1118
|
+
const Ie = [
|
|
625
1119
|
[/\\/g, "\\\\"],
|
|
626
1120
|
[/\*/g, "\\*"],
|
|
627
1121
|
[/_/g, "\\_"],
|
|
@@ -636,8 +1130,8 @@ const ne = [
|
|
|
636
1130
|
[/<([^>]*)>/g, "\\<$1\\>"],
|
|
637
1131
|
[/^>/g, "\\>"],
|
|
638
1132
|
[/^(\d+)\. /g, "$1\\. "]
|
|
639
|
-
],
|
|
640
|
-
rules:
|
|
1133
|
+
], Be = {
|
|
1134
|
+
rules: N,
|
|
641
1135
|
headingStyle: "atx",
|
|
642
1136
|
hr: "---",
|
|
643
1137
|
bulletListMarker: "-",
|
|
@@ -664,24 +1158,24 @@ const ne = [
|
|
|
664
1158
|
` : e.outerHTML,
|
|
665
1159
|
markdownIncludingHtmlReplacement: (t, e) => {
|
|
666
1160
|
const n = e.nodeName.toLowerCase();
|
|
667
|
-
let
|
|
1161
|
+
let i = "";
|
|
668
1162
|
if (e.attributes && e.attributes.length > 0) {
|
|
669
|
-
const
|
|
670
|
-
for (let
|
|
671
|
-
const
|
|
672
|
-
|
|
1163
|
+
const c = [];
|
|
1164
|
+
for (let g = 0; g < e.attributes.length; g++) {
|
|
1165
|
+
const m = e.attributes[g];
|
|
1166
|
+
c.push(`${m.name}="${m.value}"`);
|
|
673
1167
|
}
|
|
674
|
-
|
|
1168
|
+
i = " " + c.join(" ");
|
|
675
1169
|
}
|
|
676
|
-
|
|
677
|
-
const
|
|
678
|
-
` +
|
|
679
|
-
` +
|
|
1170
|
+
i += ' markdown="1"';
|
|
1171
|
+
const r = `<${n}${i}>`, s = `</${n}>`, l = t.trim(), u = r + `
|
|
1172
|
+
` + l + `
|
|
1173
|
+
` + s;
|
|
680
1174
|
return e.isBlock ? `
|
|
681
1175
|
|
|
682
|
-
` +
|
|
1176
|
+
` + u + `
|
|
683
1177
|
|
|
684
|
-
` :
|
|
1178
|
+
` : u;
|
|
685
1179
|
},
|
|
686
1180
|
defaultReplacement: function(t, e) {
|
|
687
1181
|
return e.isBlock ? `
|
|
@@ -691,11 +1185,11 @@ const ne = [
|
|
|
691
1185
|
` : t;
|
|
692
1186
|
}
|
|
693
1187
|
};
|
|
694
|
-
class
|
|
1188
|
+
class Ve {
|
|
695
1189
|
options;
|
|
696
1190
|
rules;
|
|
697
1191
|
constructor(e) {
|
|
698
|
-
this.options = Object.assign({},
|
|
1192
|
+
this.options = Object.assign({}, Be, e), this.rules = new Re(this.options);
|
|
699
1193
|
}
|
|
700
1194
|
/**
|
|
701
1195
|
* The entry point for converting a string or DOM node to Markdown
|
|
@@ -705,13 +1199,13 @@ class le {
|
|
|
705
1199
|
* @type string
|
|
706
1200
|
*/
|
|
707
1201
|
render(e) {
|
|
708
|
-
if (!
|
|
1202
|
+
if (!Pe(e))
|
|
709
1203
|
throw new TypeError(
|
|
710
1204
|
e + " is not a string, or an element/document/fragment node."
|
|
711
1205
|
);
|
|
712
1206
|
if (e === "")
|
|
713
1207
|
return "";
|
|
714
|
-
const n = this.process(
|
|
1208
|
+
const n = this.process(Me(e, this.options));
|
|
715
1209
|
return this.postProcess(n);
|
|
716
1210
|
}
|
|
717
1211
|
/**
|
|
@@ -769,8 +1263,8 @@ class le {
|
|
|
769
1263
|
* @type string
|
|
770
1264
|
*/
|
|
771
1265
|
escape(e) {
|
|
772
|
-
return
|
|
773
|
-
return n.replace(
|
|
1266
|
+
return Ie.reduce(function(n, i) {
|
|
1267
|
+
return n.replace(i[0], i[1]);
|
|
774
1268
|
}, e);
|
|
775
1269
|
}
|
|
776
1270
|
/**
|
|
@@ -781,18 +1275,18 @@ class le {
|
|
|
781
1275
|
* @type string
|
|
782
1276
|
*/
|
|
783
1277
|
process(e) {
|
|
784
|
-
return Array.from(e.childNodes).reduce((n,
|
|
785
|
-
const
|
|
786
|
-
let
|
|
787
|
-
if (
|
|
788
|
-
let
|
|
789
|
-
if (
|
|
790
|
-
const
|
|
791
|
-
|
|
1278
|
+
return Array.from(e.childNodes).reduce((n, i) => {
|
|
1279
|
+
const r = fe(i, this.options);
|
|
1280
|
+
let s = "";
|
|
1281
|
+
if (r.nodeType === x.Text) {
|
|
1282
|
+
let l = r.nodeValue ?? "";
|
|
1283
|
+
if (i.previousSibling && i.previousSibling.nodeType === x.Element) {
|
|
1284
|
+
const u = i.previousSibling;
|
|
1285
|
+
u.nodeName === "INPUT" && u.getAttribute("type") === "checkbox" && (l = l.replace(/^\s+/, ""));
|
|
792
1286
|
}
|
|
793
|
-
|
|
794
|
-
} else
|
|
795
|
-
return
|
|
1287
|
+
s = r.isCode ? l : this.escape(l);
|
|
1288
|
+
} else r.nodeType === x.Element && (s = this.replacementForNode(r));
|
|
1289
|
+
return G(n, s);
|
|
796
1290
|
}, "");
|
|
797
1291
|
}
|
|
798
1292
|
/**
|
|
@@ -804,7 +1298,7 @@ class le {
|
|
|
804
1298
|
*/
|
|
805
1299
|
postProcess(e) {
|
|
806
1300
|
for (const n of this.rules.array)
|
|
807
|
-
n.append && (e =
|
|
1301
|
+
n.append && (e = G(e, n.append(this.options)));
|
|
808
1302
|
return e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
|
|
809
1303
|
}
|
|
810
1304
|
/**
|
|
@@ -816,21 +1310,33 @@ class le {
|
|
|
816
1310
|
*/
|
|
817
1311
|
replacementForNode(e) {
|
|
818
1312
|
const n = this.rules.forNode(e);
|
|
819
|
-
let
|
|
820
|
-
const
|
|
821
|
-
return (
|
|
1313
|
+
let i = this.process(e);
|
|
1314
|
+
const r = e.flankingWhitespace;
|
|
1315
|
+
return (r.leading || r.trailing) && (i = i.trim()), r.leading + n.replacement(i, e, this.options) + r.trailing;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Determines whether a node is a code block
|
|
1319
|
+
* @public
|
|
1320
|
+
* @param {Node} node The node to check
|
|
1321
|
+
* @returns True if the node is a code block, false otherwise
|
|
1322
|
+
* @type boolean
|
|
1323
|
+
*/
|
|
1324
|
+
isCodeBlock(e) {
|
|
1325
|
+
return te(e);
|
|
822
1326
|
}
|
|
823
1327
|
}
|
|
824
|
-
function
|
|
825
|
-
const n =
|
|
1328
|
+
function G(t, e) {
|
|
1329
|
+
const n = Y(t), i = K(e), r = Math.max(t.length - n.length, e.length - i.length), s = `
|
|
826
1330
|
|
|
827
|
-
`.substring(0,
|
|
828
|
-
return n +
|
|
1331
|
+
`.substring(0, r);
|
|
1332
|
+
return n + s + i;
|
|
829
1333
|
}
|
|
830
|
-
function
|
|
1334
|
+
function Pe(t) {
|
|
831
1335
|
return t != null && (typeof t == "string" || t.nodeType && (t.nodeType === 1 || t.nodeType === 9 || t.nodeType === 11));
|
|
832
1336
|
}
|
|
833
1337
|
export {
|
|
834
|
-
|
|
1338
|
+
x as NodeTypes,
|
|
1339
|
+
Re as Rules,
|
|
1340
|
+
Ve as default
|
|
835
1341
|
};
|
|
836
1342
|
//# sourceMappingURL=index.mjs.map
|