@wodira/browser 1.2.3 → 1.3.0
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/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/boxes/cdn.js +1 -1
- package/dist/ui/boxes/index.js +7 -0
- package/dist/ui/components.d.ts +10 -1
- package/dist/ui/components.d.ts.map +1 -1
- package/dist/ui/i18n.d.ts +1 -1
- package/dist/ui/i18n.d.ts.map +1 -1
- package/dist/ui/{index-3eb6xc34.js → index-4eecjr6y.js} +70 -1
- package/dist/ui/index.js +137 -44
- package/dist/ui/shirt-sponsors/cdn.js +90 -22
- package/dist/ui/shirt-sponsors/index.js +2 -2
- package/dist/ui/styles.d.ts +1 -0
- package/dist/ui/styles.d.ts.map +1 -1
- package/dist/ui/theme.d.ts.map +1 -1
- package/dist/ui/waiver-document-kemkgn03.js +4120 -0
- package/dist/ui/waiver-document.d.ts +2 -0
- package/dist/ui/waiver-document.d.ts.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,4120 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/dompurify@3.5.0/node_modules/dompurify/dist/purify.es.mjs
|
|
2
|
+
/*! @license DOMPurify 3.5.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.5.0/LICENSE */
|
|
3
|
+
function _OverloadYield(e, d) {
|
|
4
|
+
this.v = e, this.k = d;
|
|
5
|
+
}
|
|
6
|
+
function _arrayLikeToArray(r, a) {
|
|
7
|
+
(a == null || a > r.length) && (a = r.length);
|
|
8
|
+
for (var e = 0, n = Array(a);e < a; e++)
|
|
9
|
+
n[e] = r[e];
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
function _arrayWithHoles(r) {
|
|
13
|
+
if (Array.isArray(r))
|
|
14
|
+
return r;
|
|
15
|
+
}
|
|
16
|
+
function _iterableToArrayLimit(r, l) {
|
|
17
|
+
var t = r == null ? null : typeof Symbol != "undefined" && r[Symbol.iterator] || r["@@iterator"];
|
|
18
|
+
if (t != null) {
|
|
19
|
+
var e, n, i, u, a = [], f = true, o = false;
|
|
20
|
+
try {
|
|
21
|
+
if (i = (t = t.call(r)).next, l === 0) {
|
|
22
|
+
if (Object(t) !== t)
|
|
23
|
+
return;
|
|
24
|
+
f = false;
|
|
25
|
+
} else
|
|
26
|
+
for (;!(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true)
|
|
27
|
+
;
|
|
28
|
+
} catch (r) {
|
|
29
|
+
o = true, n = r;
|
|
30
|
+
} finally {
|
|
31
|
+
try {
|
|
32
|
+
if (!f && t.return != null && (u = t.return(), Object(u) !== u))
|
|
33
|
+
return;
|
|
34
|
+
} finally {
|
|
35
|
+
if (o)
|
|
36
|
+
throw n;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return a;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function _nonIterableRest() {
|
|
43
|
+
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
44
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
45
|
+
}
|
|
46
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
47
|
+
function _slicedToArray(r, e) {
|
|
48
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
49
|
+
}
|
|
50
|
+
function _unsupportedIterableToArray(r, a) {
|
|
51
|
+
if (r) {
|
|
52
|
+
if (typeof r == "string")
|
|
53
|
+
return _arrayLikeToArray(r, a);
|
|
54
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
55
|
+
return t === "Object" && r.constructor && (t = r.constructor.name), t === "Map" || t === "Set" ? Array.from(r) : t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function AsyncGenerator(e) {
|
|
59
|
+
var t, n;
|
|
60
|
+
function resume(t, n) {
|
|
61
|
+
try {
|
|
62
|
+
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
63
|
+
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
64
|
+
if (u) {
|
|
65
|
+
var i = t === "return" && o.k ? t : "next";
|
|
66
|
+
if (!o.k || n.done)
|
|
67
|
+
return resume(i, n);
|
|
68
|
+
n = e[i](n).value;
|
|
69
|
+
}
|
|
70
|
+
settle(!!r.done, n);
|
|
71
|
+
}, function(e) {
|
|
72
|
+
resume("throw", e);
|
|
73
|
+
});
|
|
74
|
+
} catch (e) {
|
|
75
|
+
settle(2, e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function settle(e, r) {
|
|
79
|
+
e === 2 ? t.reject(r) : t.resolve({
|
|
80
|
+
value: r,
|
|
81
|
+
done: e
|
|
82
|
+
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
83
|
+
}
|
|
84
|
+
this._invoke = function(e, r) {
|
|
85
|
+
return new Promise(function(o, u) {
|
|
86
|
+
var i = {
|
|
87
|
+
key: e,
|
|
88
|
+
arg: r,
|
|
89
|
+
resolve: o,
|
|
90
|
+
reject: u,
|
|
91
|
+
next: null
|
|
92
|
+
};
|
|
93
|
+
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
94
|
+
});
|
|
95
|
+
}, typeof e.return != "function" && (this.return = undefined);
|
|
96
|
+
}
|
|
97
|
+
AsyncGenerator.prototype[typeof Symbol == "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
98
|
+
return this;
|
|
99
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
100
|
+
return this._invoke("next", e);
|
|
101
|
+
}, AsyncGenerator.prototype.throw = function(e) {
|
|
102
|
+
return this._invoke("throw", e);
|
|
103
|
+
}, AsyncGenerator.prototype.return = function(e) {
|
|
104
|
+
return this._invoke("return", e);
|
|
105
|
+
};
|
|
106
|
+
var entries = Object.entries;
|
|
107
|
+
var objectKeys = Object.keys;
|
|
108
|
+
var setPrototypeOf = Object.setPrototypeOf;
|
|
109
|
+
var isFrozen = Object.isFrozen;
|
|
110
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
111
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
112
|
+
var freeze = Object.freeze;
|
|
113
|
+
var seal = Object.seal;
|
|
114
|
+
var create = Object.create;
|
|
115
|
+
var _ref = typeof Reflect !== "undefined" && Reflect;
|
|
116
|
+
var apply = _ref.apply;
|
|
117
|
+
var construct = _ref.construct;
|
|
118
|
+
if (!freeze)
|
|
119
|
+
freeze = function freeze(x) {
|
|
120
|
+
return x;
|
|
121
|
+
};
|
|
122
|
+
if (!seal)
|
|
123
|
+
seal = function seal(x) {
|
|
124
|
+
return x;
|
|
125
|
+
};
|
|
126
|
+
if (!apply)
|
|
127
|
+
apply = function apply(func, thisArg) {
|
|
128
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2;_key < _len; _key++)
|
|
129
|
+
args[_key - 2] = arguments[_key];
|
|
130
|
+
return func.apply(thisArg, args);
|
|
131
|
+
};
|
|
132
|
+
if (!construct)
|
|
133
|
+
construct = function construct(Func) {
|
|
134
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1;_key2 < _len2; _key2++)
|
|
135
|
+
args[_key2 - 1] = arguments[_key2];
|
|
136
|
+
return new Func(...args);
|
|
137
|
+
};
|
|
138
|
+
var arrayForEach = unapply(Array.prototype.forEach);
|
|
139
|
+
var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
140
|
+
var arrayPop = unapply(Array.prototype.pop);
|
|
141
|
+
var arrayPush = unapply(Array.prototype.push);
|
|
142
|
+
var arraySlice = unapply(Array.prototype.slice);
|
|
143
|
+
var arraySplice = unapply(Array.prototype.splice);
|
|
144
|
+
var arrayIsArray = Array.isArray;
|
|
145
|
+
var setCreate = unconstruct(Set);
|
|
146
|
+
var setAdd = unapply(Set.prototype.add);
|
|
147
|
+
var setHas = unapply(Set.prototype.has);
|
|
148
|
+
var setDelete = unapply(Set.prototype.delete);
|
|
149
|
+
var mapCreate = unconstruct(Map);
|
|
150
|
+
var mapGet = unapply(Map.prototype.get);
|
|
151
|
+
var mapSet = unapply(Map.prototype.set);
|
|
152
|
+
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
153
|
+
var stringToString = unapply(String.prototype.toString);
|
|
154
|
+
var stringMatch = unapply(String.prototype.match);
|
|
155
|
+
var stringReplace = unapply(String.prototype.replace);
|
|
156
|
+
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
157
|
+
var stringTrim = unapply(String.prototype.trim);
|
|
158
|
+
var numberToString = unapply(Number.prototype.toString);
|
|
159
|
+
var booleanToString = unapply(Boolean.prototype.toString);
|
|
160
|
+
var bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
|
|
161
|
+
var symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
|
|
162
|
+
var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
163
|
+
var objectToString = unapply(Object.prototype.toString);
|
|
164
|
+
var regExpTestRaw = RegExp.prototype.test;
|
|
165
|
+
var regExpTest = function regExpTest(regExp, value) {
|
|
166
|
+
if (regExp instanceof RegExp)
|
|
167
|
+
regExp.lastIndex = 0;
|
|
168
|
+
return apply(regExpTestRaw, regExp, [value]);
|
|
169
|
+
};
|
|
170
|
+
var typeErrorCreate = unconstruct(TypeError);
|
|
171
|
+
function unapply(func) {
|
|
172
|
+
return function(thisArg) {
|
|
173
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1;_key3 < _len3; _key3++)
|
|
174
|
+
args[_key3 - 1] = arguments[_key3];
|
|
175
|
+
return apply(func, thisArg, args);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function unconstruct(Func) {
|
|
179
|
+
return function() {
|
|
180
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0;_key4 < _len4; _key4++)
|
|
181
|
+
args[_key4] = arguments[_key4];
|
|
182
|
+
return construct(Func, args);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function addToSet(set, array) {
|
|
186
|
+
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
|
|
187
|
+
if (setPrototypeOf)
|
|
188
|
+
setPrototypeOf(set, null);
|
|
189
|
+
if (!arrayIsArray(array))
|
|
190
|
+
return set;
|
|
191
|
+
let l = array.length;
|
|
192
|
+
while (l--) {
|
|
193
|
+
let element = array[l];
|
|
194
|
+
if (typeof element === "string") {
|
|
195
|
+
const lcElement = transformCaseFunc(element);
|
|
196
|
+
if (lcElement !== element) {
|
|
197
|
+
if (!isFrozen(array))
|
|
198
|
+
array[l] = lcElement;
|
|
199
|
+
element = lcElement;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
set[element] = true;
|
|
203
|
+
}
|
|
204
|
+
return set;
|
|
205
|
+
}
|
|
206
|
+
function cleanArray(array) {
|
|
207
|
+
for (let index = 0;index < array.length; index++)
|
|
208
|
+
if (!objectHasOwnProperty(array, index))
|
|
209
|
+
array[index] = null;
|
|
210
|
+
return array;
|
|
211
|
+
}
|
|
212
|
+
function clone(object) {
|
|
213
|
+
const newObject = create(null);
|
|
214
|
+
for (const _ref2 of entries(object)) {
|
|
215
|
+
var _ref3 = _slicedToArray(_ref2, 2);
|
|
216
|
+
const property = _ref3[0];
|
|
217
|
+
const value = _ref3[1];
|
|
218
|
+
if (objectHasOwnProperty(object, property)) {
|
|
219
|
+
if (arrayIsArray(value))
|
|
220
|
+
newObject[property] = cleanArray(value);
|
|
221
|
+
else if (value && typeof value === "object" && value.constructor === Object)
|
|
222
|
+
newObject[property] = clone(value);
|
|
223
|
+
else
|
|
224
|
+
newObject[property] = value;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return newObject;
|
|
228
|
+
}
|
|
229
|
+
function cloneSet(set) {
|
|
230
|
+
const newSet = create(null);
|
|
231
|
+
const keys = objectKeys(set);
|
|
232
|
+
let l = keys.length;
|
|
233
|
+
while (l--)
|
|
234
|
+
newSet[keys[l]] = set[keys[l]];
|
|
235
|
+
return newSet;
|
|
236
|
+
}
|
|
237
|
+
function stringifyValue(value) {
|
|
238
|
+
switch (typeof value) {
|
|
239
|
+
case "string":
|
|
240
|
+
return value;
|
|
241
|
+
case "number":
|
|
242
|
+
return numberToString(value);
|
|
243
|
+
case "boolean":
|
|
244
|
+
return booleanToString(value);
|
|
245
|
+
case "bigint":
|
|
246
|
+
return bigintToString ? bigintToString(value) : "0";
|
|
247
|
+
case "symbol":
|
|
248
|
+
return symbolToString ? symbolToString(value) : "Symbol()";
|
|
249
|
+
case "undefined":
|
|
250
|
+
return objectToString(value);
|
|
251
|
+
case "function":
|
|
252
|
+
case "object": {
|
|
253
|
+
if (value === null)
|
|
254
|
+
return objectToString(value);
|
|
255
|
+
const valueAsRecord = value;
|
|
256
|
+
const valueToString = lookupGetter(valueAsRecord, "toString");
|
|
257
|
+
if (typeof valueToString === "function") {
|
|
258
|
+
const stringified = valueToString(valueAsRecord);
|
|
259
|
+
return typeof stringified === "string" ? stringified : objectToString(stringified);
|
|
260
|
+
}
|
|
261
|
+
return objectToString(value);
|
|
262
|
+
}
|
|
263
|
+
default:
|
|
264
|
+
return objectToString(value);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function lookupGetter(object, prop) {
|
|
268
|
+
while (object !== null) {
|
|
269
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
270
|
+
if (desc) {
|
|
271
|
+
if (desc.get)
|
|
272
|
+
return unapply(desc.get);
|
|
273
|
+
if (typeof desc.value === "function")
|
|
274
|
+
return unapply(desc.value);
|
|
275
|
+
}
|
|
276
|
+
object = getPrototypeOf(object);
|
|
277
|
+
}
|
|
278
|
+
function fallbackValue() {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
return fallbackValue;
|
|
282
|
+
}
|
|
283
|
+
function lookupAccessor(object, prop) {
|
|
284
|
+
while (object !== null) {
|
|
285
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
286
|
+
if (desc)
|
|
287
|
+
return desc.get ? unapply(desc.get) : null;
|
|
288
|
+
object = getPrototypeOf(object);
|
|
289
|
+
}
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
function isRegex(value) {
|
|
293
|
+
if (!value)
|
|
294
|
+
return false;
|
|
295
|
+
try {
|
|
296
|
+
regExpTest(value, "");
|
|
297
|
+
return true;
|
|
298
|
+
} catch (_unused) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
var html$1 = freeze([
|
|
303
|
+
"a",
|
|
304
|
+
"abbr",
|
|
305
|
+
"acronym",
|
|
306
|
+
"address",
|
|
307
|
+
"area",
|
|
308
|
+
"article",
|
|
309
|
+
"aside",
|
|
310
|
+
"audio",
|
|
311
|
+
"b",
|
|
312
|
+
"bdi",
|
|
313
|
+
"bdo",
|
|
314
|
+
"big",
|
|
315
|
+
"blink",
|
|
316
|
+
"blockquote",
|
|
317
|
+
"body",
|
|
318
|
+
"br",
|
|
319
|
+
"button",
|
|
320
|
+
"canvas",
|
|
321
|
+
"caption",
|
|
322
|
+
"center",
|
|
323
|
+
"cite",
|
|
324
|
+
"code",
|
|
325
|
+
"col",
|
|
326
|
+
"colgroup",
|
|
327
|
+
"content",
|
|
328
|
+
"data",
|
|
329
|
+
"datalist",
|
|
330
|
+
"dd",
|
|
331
|
+
"decorator",
|
|
332
|
+
"del",
|
|
333
|
+
"details",
|
|
334
|
+
"dfn",
|
|
335
|
+
"dialog",
|
|
336
|
+
"dir",
|
|
337
|
+
"div",
|
|
338
|
+
"dl",
|
|
339
|
+
"dt",
|
|
340
|
+
"element",
|
|
341
|
+
"em",
|
|
342
|
+
"fieldset",
|
|
343
|
+
"figcaption",
|
|
344
|
+
"figure",
|
|
345
|
+
"font",
|
|
346
|
+
"footer",
|
|
347
|
+
"form",
|
|
348
|
+
"h1",
|
|
349
|
+
"h2",
|
|
350
|
+
"h3",
|
|
351
|
+
"h4",
|
|
352
|
+
"h5",
|
|
353
|
+
"h6",
|
|
354
|
+
"head",
|
|
355
|
+
"header",
|
|
356
|
+
"hgroup",
|
|
357
|
+
"hr",
|
|
358
|
+
"html",
|
|
359
|
+
"i",
|
|
360
|
+
"img",
|
|
361
|
+
"input",
|
|
362
|
+
"ins",
|
|
363
|
+
"kbd",
|
|
364
|
+
"label",
|
|
365
|
+
"legend",
|
|
366
|
+
"li",
|
|
367
|
+
"main",
|
|
368
|
+
"map",
|
|
369
|
+
"mark",
|
|
370
|
+
"marquee",
|
|
371
|
+
"menu",
|
|
372
|
+
"menuitem",
|
|
373
|
+
"meter",
|
|
374
|
+
"nav",
|
|
375
|
+
"nobr",
|
|
376
|
+
"ol",
|
|
377
|
+
"optgroup",
|
|
378
|
+
"option",
|
|
379
|
+
"output",
|
|
380
|
+
"p",
|
|
381
|
+
"picture",
|
|
382
|
+
"pre",
|
|
383
|
+
"progress",
|
|
384
|
+
"q",
|
|
385
|
+
"rp",
|
|
386
|
+
"rt",
|
|
387
|
+
"ruby",
|
|
388
|
+
"s",
|
|
389
|
+
"samp",
|
|
390
|
+
"search",
|
|
391
|
+
"section",
|
|
392
|
+
"select",
|
|
393
|
+
"shadow",
|
|
394
|
+
"slot",
|
|
395
|
+
"small",
|
|
396
|
+
"source",
|
|
397
|
+
"spacer",
|
|
398
|
+
"span",
|
|
399
|
+
"strike",
|
|
400
|
+
"strong",
|
|
401
|
+
"style",
|
|
402
|
+
"sub",
|
|
403
|
+
"summary",
|
|
404
|
+
"sup",
|
|
405
|
+
"table",
|
|
406
|
+
"tbody",
|
|
407
|
+
"td",
|
|
408
|
+
"template",
|
|
409
|
+
"textarea",
|
|
410
|
+
"tfoot",
|
|
411
|
+
"th",
|
|
412
|
+
"thead",
|
|
413
|
+
"time",
|
|
414
|
+
"tr",
|
|
415
|
+
"track",
|
|
416
|
+
"tt",
|
|
417
|
+
"u",
|
|
418
|
+
"ul",
|
|
419
|
+
"var",
|
|
420
|
+
"video",
|
|
421
|
+
"wbr"
|
|
422
|
+
]);
|
|
423
|
+
var svg$1 = freeze([
|
|
424
|
+
"svg",
|
|
425
|
+
"a",
|
|
426
|
+
"altglyph",
|
|
427
|
+
"altglyphdef",
|
|
428
|
+
"altglyphitem",
|
|
429
|
+
"animatecolor",
|
|
430
|
+
"animatemotion",
|
|
431
|
+
"animatetransform",
|
|
432
|
+
"circle",
|
|
433
|
+
"clippath",
|
|
434
|
+
"defs",
|
|
435
|
+
"desc",
|
|
436
|
+
"ellipse",
|
|
437
|
+
"filter",
|
|
438
|
+
"font",
|
|
439
|
+
"g",
|
|
440
|
+
"glyph",
|
|
441
|
+
"glyphref",
|
|
442
|
+
"hkern",
|
|
443
|
+
"image",
|
|
444
|
+
"line",
|
|
445
|
+
"lineargradient",
|
|
446
|
+
"marker",
|
|
447
|
+
"mask",
|
|
448
|
+
"metadata",
|
|
449
|
+
"mpath",
|
|
450
|
+
"path",
|
|
451
|
+
"pattern",
|
|
452
|
+
"polygon",
|
|
453
|
+
"polyline",
|
|
454
|
+
"radialgradient",
|
|
455
|
+
"rect",
|
|
456
|
+
"stop",
|
|
457
|
+
"style",
|
|
458
|
+
"switch",
|
|
459
|
+
"symbol",
|
|
460
|
+
"text",
|
|
461
|
+
"textpath",
|
|
462
|
+
"title",
|
|
463
|
+
"tref",
|
|
464
|
+
"tspan",
|
|
465
|
+
"view",
|
|
466
|
+
"vkern"
|
|
467
|
+
]);
|
|
468
|
+
var svgFilters = freeze([
|
|
469
|
+
"feBlend",
|
|
470
|
+
"feColorMatrix",
|
|
471
|
+
"feComponentTransfer",
|
|
472
|
+
"feComposite",
|
|
473
|
+
"feConvolveMatrix",
|
|
474
|
+
"feDiffuseLighting",
|
|
475
|
+
"feDisplacementMap",
|
|
476
|
+
"feDistantLight",
|
|
477
|
+
"feDropShadow",
|
|
478
|
+
"feFlood",
|
|
479
|
+
"feFuncA",
|
|
480
|
+
"feFuncB",
|
|
481
|
+
"feFuncG",
|
|
482
|
+
"feFuncR",
|
|
483
|
+
"feGaussianBlur",
|
|
484
|
+
"feImage",
|
|
485
|
+
"feMerge",
|
|
486
|
+
"feMergeNode",
|
|
487
|
+
"feMorphology",
|
|
488
|
+
"feOffset",
|
|
489
|
+
"fePointLight",
|
|
490
|
+
"feSpecularLighting",
|
|
491
|
+
"feSpotLight",
|
|
492
|
+
"feTile",
|
|
493
|
+
"feTurbulence"
|
|
494
|
+
]);
|
|
495
|
+
var svgDisallowed = freeze([
|
|
496
|
+
"animate",
|
|
497
|
+
"color-profile",
|
|
498
|
+
"cursor",
|
|
499
|
+
"discard",
|
|
500
|
+
"font-face",
|
|
501
|
+
"font-face-format",
|
|
502
|
+
"font-face-name",
|
|
503
|
+
"font-face-src",
|
|
504
|
+
"font-face-uri",
|
|
505
|
+
"foreignobject",
|
|
506
|
+
"hatch",
|
|
507
|
+
"hatchpath",
|
|
508
|
+
"mesh",
|
|
509
|
+
"meshgradient",
|
|
510
|
+
"meshpatch",
|
|
511
|
+
"meshrow",
|
|
512
|
+
"missing-glyph",
|
|
513
|
+
"script",
|
|
514
|
+
"set",
|
|
515
|
+
"solidcolor",
|
|
516
|
+
"unknown",
|
|
517
|
+
"use"
|
|
518
|
+
]);
|
|
519
|
+
var mathMl$1 = freeze([
|
|
520
|
+
"math",
|
|
521
|
+
"menclose",
|
|
522
|
+
"merror",
|
|
523
|
+
"mfenced",
|
|
524
|
+
"mfrac",
|
|
525
|
+
"mglyph",
|
|
526
|
+
"mi",
|
|
527
|
+
"mlabeledtr",
|
|
528
|
+
"mmultiscripts",
|
|
529
|
+
"mn",
|
|
530
|
+
"mo",
|
|
531
|
+
"mover",
|
|
532
|
+
"mpadded",
|
|
533
|
+
"mphantom",
|
|
534
|
+
"mroot",
|
|
535
|
+
"mrow",
|
|
536
|
+
"ms",
|
|
537
|
+
"mspace",
|
|
538
|
+
"msqrt",
|
|
539
|
+
"mstyle",
|
|
540
|
+
"msub",
|
|
541
|
+
"msup",
|
|
542
|
+
"msubsup",
|
|
543
|
+
"mtable",
|
|
544
|
+
"mtd",
|
|
545
|
+
"mtext",
|
|
546
|
+
"mtr",
|
|
547
|
+
"munder",
|
|
548
|
+
"munderover",
|
|
549
|
+
"mprescripts"
|
|
550
|
+
]);
|
|
551
|
+
var mathMlDisallowed = freeze([
|
|
552
|
+
"maction",
|
|
553
|
+
"maligngroup",
|
|
554
|
+
"malignmark",
|
|
555
|
+
"mlongdiv",
|
|
556
|
+
"mscarries",
|
|
557
|
+
"mscarry",
|
|
558
|
+
"msgroup",
|
|
559
|
+
"mstack",
|
|
560
|
+
"msline",
|
|
561
|
+
"msrow",
|
|
562
|
+
"semantics",
|
|
563
|
+
"annotation",
|
|
564
|
+
"annotation-xml",
|
|
565
|
+
"mprescripts",
|
|
566
|
+
"none"
|
|
567
|
+
]);
|
|
568
|
+
var text = freeze(["#text"]);
|
|
569
|
+
var html = freeze([
|
|
570
|
+
"accept",
|
|
571
|
+
"action",
|
|
572
|
+
"align",
|
|
573
|
+
"alt",
|
|
574
|
+
"autocapitalize",
|
|
575
|
+
"autocomplete",
|
|
576
|
+
"autopictureinpicture",
|
|
577
|
+
"autoplay",
|
|
578
|
+
"background",
|
|
579
|
+
"bgcolor",
|
|
580
|
+
"border",
|
|
581
|
+
"capture",
|
|
582
|
+
"cellpadding",
|
|
583
|
+
"cellspacing",
|
|
584
|
+
"checked",
|
|
585
|
+
"cite",
|
|
586
|
+
"class",
|
|
587
|
+
"clear",
|
|
588
|
+
"color",
|
|
589
|
+
"cols",
|
|
590
|
+
"colspan",
|
|
591
|
+
"command",
|
|
592
|
+
"commandfor",
|
|
593
|
+
"controls",
|
|
594
|
+
"controlslist",
|
|
595
|
+
"coords",
|
|
596
|
+
"crossorigin",
|
|
597
|
+
"datetime",
|
|
598
|
+
"decoding",
|
|
599
|
+
"default",
|
|
600
|
+
"dir",
|
|
601
|
+
"disabled",
|
|
602
|
+
"disablepictureinpicture",
|
|
603
|
+
"disableremoteplayback",
|
|
604
|
+
"download",
|
|
605
|
+
"draggable",
|
|
606
|
+
"enctype",
|
|
607
|
+
"enterkeyhint",
|
|
608
|
+
"exportparts",
|
|
609
|
+
"face",
|
|
610
|
+
"for",
|
|
611
|
+
"headers",
|
|
612
|
+
"height",
|
|
613
|
+
"hidden",
|
|
614
|
+
"high",
|
|
615
|
+
"href",
|
|
616
|
+
"hreflang",
|
|
617
|
+
"id",
|
|
618
|
+
"inert",
|
|
619
|
+
"inputmode",
|
|
620
|
+
"integrity",
|
|
621
|
+
"ismap",
|
|
622
|
+
"kind",
|
|
623
|
+
"label",
|
|
624
|
+
"lang",
|
|
625
|
+
"list",
|
|
626
|
+
"loading",
|
|
627
|
+
"loop",
|
|
628
|
+
"low",
|
|
629
|
+
"max",
|
|
630
|
+
"maxlength",
|
|
631
|
+
"media",
|
|
632
|
+
"method",
|
|
633
|
+
"min",
|
|
634
|
+
"minlength",
|
|
635
|
+
"multiple",
|
|
636
|
+
"muted",
|
|
637
|
+
"name",
|
|
638
|
+
"nonce",
|
|
639
|
+
"noshade",
|
|
640
|
+
"novalidate",
|
|
641
|
+
"nowrap",
|
|
642
|
+
"open",
|
|
643
|
+
"optimum",
|
|
644
|
+
"part",
|
|
645
|
+
"pattern",
|
|
646
|
+
"placeholder",
|
|
647
|
+
"playsinline",
|
|
648
|
+
"popover",
|
|
649
|
+
"popovertarget",
|
|
650
|
+
"popovertargetaction",
|
|
651
|
+
"poster",
|
|
652
|
+
"preload",
|
|
653
|
+
"pubdate",
|
|
654
|
+
"radiogroup",
|
|
655
|
+
"readonly",
|
|
656
|
+
"rel",
|
|
657
|
+
"required",
|
|
658
|
+
"rev",
|
|
659
|
+
"reversed",
|
|
660
|
+
"role",
|
|
661
|
+
"rows",
|
|
662
|
+
"rowspan",
|
|
663
|
+
"spellcheck",
|
|
664
|
+
"scope",
|
|
665
|
+
"selected",
|
|
666
|
+
"shape",
|
|
667
|
+
"size",
|
|
668
|
+
"sizes",
|
|
669
|
+
"slot",
|
|
670
|
+
"span",
|
|
671
|
+
"srclang",
|
|
672
|
+
"start",
|
|
673
|
+
"src",
|
|
674
|
+
"srcset",
|
|
675
|
+
"step",
|
|
676
|
+
"style",
|
|
677
|
+
"summary",
|
|
678
|
+
"tabindex",
|
|
679
|
+
"title",
|
|
680
|
+
"translate",
|
|
681
|
+
"type",
|
|
682
|
+
"usemap",
|
|
683
|
+
"valign",
|
|
684
|
+
"value",
|
|
685
|
+
"width",
|
|
686
|
+
"wrap",
|
|
687
|
+
"xmlns"
|
|
688
|
+
]);
|
|
689
|
+
var svg = freeze([
|
|
690
|
+
"accent-height",
|
|
691
|
+
"accumulate",
|
|
692
|
+
"additive",
|
|
693
|
+
"alignment-baseline",
|
|
694
|
+
"amplitude",
|
|
695
|
+
"ascent",
|
|
696
|
+
"attributename",
|
|
697
|
+
"attributetype",
|
|
698
|
+
"azimuth",
|
|
699
|
+
"basefrequency",
|
|
700
|
+
"baseline-shift",
|
|
701
|
+
"begin",
|
|
702
|
+
"bias",
|
|
703
|
+
"by",
|
|
704
|
+
"class",
|
|
705
|
+
"clip",
|
|
706
|
+
"clippathunits",
|
|
707
|
+
"clip-path",
|
|
708
|
+
"clip-rule",
|
|
709
|
+
"color",
|
|
710
|
+
"color-interpolation",
|
|
711
|
+
"color-interpolation-filters",
|
|
712
|
+
"color-profile",
|
|
713
|
+
"color-rendering",
|
|
714
|
+
"cx",
|
|
715
|
+
"cy",
|
|
716
|
+
"d",
|
|
717
|
+
"dx",
|
|
718
|
+
"dy",
|
|
719
|
+
"diffuseconstant",
|
|
720
|
+
"direction",
|
|
721
|
+
"display",
|
|
722
|
+
"divisor",
|
|
723
|
+
"dominant-baseline",
|
|
724
|
+
"dur",
|
|
725
|
+
"edgemode",
|
|
726
|
+
"elevation",
|
|
727
|
+
"end",
|
|
728
|
+
"exponent",
|
|
729
|
+
"fill",
|
|
730
|
+
"fill-opacity",
|
|
731
|
+
"fill-rule",
|
|
732
|
+
"filter",
|
|
733
|
+
"filterunits",
|
|
734
|
+
"flood-color",
|
|
735
|
+
"flood-opacity",
|
|
736
|
+
"font-family",
|
|
737
|
+
"font-size",
|
|
738
|
+
"font-size-adjust",
|
|
739
|
+
"font-stretch",
|
|
740
|
+
"font-style",
|
|
741
|
+
"font-variant",
|
|
742
|
+
"font-weight",
|
|
743
|
+
"fx",
|
|
744
|
+
"fy",
|
|
745
|
+
"g1",
|
|
746
|
+
"g2",
|
|
747
|
+
"glyph-name",
|
|
748
|
+
"glyphref",
|
|
749
|
+
"gradientunits",
|
|
750
|
+
"gradienttransform",
|
|
751
|
+
"height",
|
|
752
|
+
"href",
|
|
753
|
+
"id",
|
|
754
|
+
"image-rendering",
|
|
755
|
+
"in",
|
|
756
|
+
"in2",
|
|
757
|
+
"intercept",
|
|
758
|
+
"k",
|
|
759
|
+
"k1",
|
|
760
|
+
"k2",
|
|
761
|
+
"k3",
|
|
762
|
+
"k4",
|
|
763
|
+
"kerning",
|
|
764
|
+
"keypoints",
|
|
765
|
+
"keysplines",
|
|
766
|
+
"keytimes",
|
|
767
|
+
"lang",
|
|
768
|
+
"lengthadjust",
|
|
769
|
+
"letter-spacing",
|
|
770
|
+
"kernelmatrix",
|
|
771
|
+
"kernelunitlength",
|
|
772
|
+
"lighting-color",
|
|
773
|
+
"local",
|
|
774
|
+
"marker-end",
|
|
775
|
+
"marker-mid",
|
|
776
|
+
"marker-start",
|
|
777
|
+
"markerheight",
|
|
778
|
+
"markerunits",
|
|
779
|
+
"markerwidth",
|
|
780
|
+
"maskcontentunits",
|
|
781
|
+
"maskunits",
|
|
782
|
+
"max",
|
|
783
|
+
"mask",
|
|
784
|
+
"mask-type",
|
|
785
|
+
"media",
|
|
786
|
+
"method",
|
|
787
|
+
"mode",
|
|
788
|
+
"min",
|
|
789
|
+
"name",
|
|
790
|
+
"numoctaves",
|
|
791
|
+
"offset",
|
|
792
|
+
"operator",
|
|
793
|
+
"opacity",
|
|
794
|
+
"order",
|
|
795
|
+
"orient",
|
|
796
|
+
"orientation",
|
|
797
|
+
"origin",
|
|
798
|
+
"overflow",
|
|
799
|
+
"paint-order",
|
|
800
|
+
"path",
|
|
801
|
+
"pathlength",
|
|
802
|
+
"patterncontentunits",
|
|
803
|
+
"patterntransform",
|
|
804
|
+
"patternunits",
|
|
805
|
+
"pointer-events",
|
|
806
|
+
"points",
|
|
807
|
+
"preservealpha",
|
|
808
|
+
"preserveaspectratio",
|
|
809
|
+
"primitiveunits",
|
|
810
|
+
"r",
|
|
811
|
+
"rx",
|
|
812
|
+
"ry",
|
|
813
|
+
"radius",
|
|
814
|
+
"refx",
|
|
815
|
+
"refy",
|
|
816
|
+
"repeatcount",
|
|
817
|
+
"repeatdur",
|
|
818
|
+
"restart",
|
|
819
|
+
"result",
|
|
820
|
+
"rotate",
|
|
821
|
+
"scale",
|
|
822
|
+
"seed",
|
|
823
|
+
"shape-rendering",
|
|
824
|
+
"slope",
|
|
825
|
+
"specularconstant",
|
|
826
|
+
"specularexponent",
|
|
827
|
+
"spreadmethod",
|
|
828
|
+
"startoffset",
|
|
829
|
+
"stddeviation",
|
|
830
|
+
"stitchtiles",
|
|
831
|
+
"stop-color",
|
|
832
|
+
"stop-opacity",
|
|
833
|
+
"stroke-dasharray",
|
|
834
|
+
"stroke-dashoffset",
|
|
835
|
+
"stroke-linecap",
|
|
836
|
+
"stroke-linejoin",
|
|
837
|
+
"stroke-miterlimit",
|
|
838
|
+
"stroke-opacity",
|
|
839
|
+
"stroke",
|
|
840
|
+
"stroke-width",
|
|
841
|
+
"style",
|
|
842
|
+
"surfacescale",
|
|
843
|
+
"systemlanguage",
|
|
844
|
+
"tabindex",
|
|
845
|
+
"tablevalues",
|
|
846
|
+
"targetx",
|
|
847
|
+
"targety",
|
|
848
|
+
"transform",
|
|
849
|
+
"transform-origin",
|
|
850
|
+
"text-anchor",
|
|
851
|
+
"text-decoration",
|
|
852
|
+
"text-orientation",
|
|
853
|
+
"text-rendering",
|
|
854
|
+
"textlength",
|
|
855
|
+
"type",
|
|
856
|
+
"u1",
|
|
857
|
+
"u2",
|
|
858
|
+
"unicode",
|
|
859
|
+
"values",
|
|
860
|
+
"vector-effect",
|
|
861
|
+
"viewbox",
|
|
862
|
+
"visibility",
|
|
863
|
+
"version",
|
|
864
|
+
"vert-adv-y",
|
|
865
|
+
"vert-origin-x",
|
|
866
|
+
"vert-origin-y",
|
|
867
|
+
"width",
|
|
868
|
+
"word-spacing",
|
|
869
|
+
"wrap",
|
|
870
|
+
"writing-mode",
|
|
871
|
+
"xchannelselector",
|
|
872
|
+
"ychannelselector",
|
|
873
|
+
"x",
|
|
874
|
+
"x1",
|
|
875
|
+
"x2",
|
|
876
|
+
"xmlns",
|
|
877
|
+
"y",
|
|
878
|
+
"y1",
|
|
879
|
+
"y2",
|
|
880
|
+
"z",
|
|
881
|
+
"zoomandpan"
|
|
882
|
+
]);
|
|
883
|
+
var mathMl = freeze([
|
|
884
|
+
"accent",
|
|
885
|
+
"accentunder",
|
|
886
|
+
"align",
|
|
887
|
+
"bevelled",
|
|
888
|
+
"close",
|
|
889
|
+
"columnalign",
|
|
890
|
+
"columnlines",
|
|
891
|
+
"columnspacing",
|
|
892
|
+
"columnspan",
|
|
893
|
+
"denomalign",
|
|
894
|
+
"depth",
|
|
895
|
+
"dir",
|
|
896
|
+
"display",
|
|
897
|
+
"displaystyle",
|
|
898
|
+
"encoding",
|
|
899
|
+
"fence",
|
|
900
|
+
"frame",
|
|
901
|
+
"height",
|
|
902
|
+
"href",
|
|
903
|
+
"id",
|
|
904
|
+
"largeop",
|
|
905
|
+
"length",
|
|
906
|
+
"linethickness",
|
|
907
|
+
"lquote",
|
|
908
|
+
"lspace",
|
|
909
|
+
"mathbackground",
|
|
910
|
+
"mathcolor",
|
|
911
|
+
"mathsize",
|
|
912
|
+
"mathvariant",
|
|
913
|
+
"maxsize",
|
|
914
|
+
"minsize",
|
|
915
|
+
"movablelimits",
|
|
916
|
+
"notation",
|
|
917
|
+
"numalign",
|
|
918
|
+
"open",
|
|
919
|
+
"rowalign",
|
|
920
|
+
"rowlines",
|
|
921
|
+
"rowspacing",
|
|
922
|
+
"rowspan",
|
|
923
|
+
"rspace",
|
|
924
|
+
"rquote",
|
|
925
|
+
"scriptlevel",
|
|
926
|
+
"scriptminsize",
|
|
927
|
+
"scriptsizemultiplier",
|
|
928
|
+
"selection",
|
|
929
|
+
"separator",
|
|
930
|
+
"separators",
|
|
931
|
+
"stretchy",
|
|
932
|
+
"subscriptshift",
|
|
933
|
+
"supscriptshift",
|
|
934
|
+
"symmetric",
|
|
935
|
+
"voffset",
|
|
936
|
+
"width",
|
|
937
|
+
"xmlns"
|
|
938
|
+
]);
|
|
939
|
+
var xml = freeze([
|
|
940
|
+
"xlink:href",
|
|
941
|
+
"xml:id",
|
|
942
|
+
"xlink:title",
|
|
943
|
+
"xml:space",
|
|
944
|
+
"xmlns:xlink"
|
|
945
|
+
]);
|
|
946
|
+
var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
947
|
+
var ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
|
|
948
|
+
var TMPLIT_EXPR = seal(/\${[\w\W]*/g);
|
|
949
|
+
var TMPL_MARKER = seal(/{{|}}|\${|<%|%>/);
|
|
950
|
+
var NON_WHITESPACE = seal(/[^\t\n\f\r ]/);
|
|
951
|
+
var NUL = seal(/\u0000/g);
|
|
952
|
+
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
|
953
|
+
var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
|
954
|
+
var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
|
|
955
|
+
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
956
|
+
var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
|
|
957
|
+
var DOCTYPE_NAME = seal(/^html$/i);
|
|
958
|
+
var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
959
|
+
var ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
960
|
+
var COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
961
|
+
var COMMENT_UNSAFE = seal(/<[/\w]|^-?>|--!?>|<!-$/g);
|
|
962
|
+
var FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
963
|
+
var SELF_CLOSING_TAG = seal(/\/>/i);
|
|
964
|
+
var ATTR_VALUE_BREAKOUT = seal(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i);
|
|
965
|
+
var LEADING_WHITESPACE = seal(/^[\r\n\t ]+/);
|
|
966
|
+
var NODE_TYPE = {
|
|
967
|
+
element: 1,
|
|
968
|
+
text: 3,
|
|
969
|
+
processingInstruction: 7,
|
|
970
|
+
comment: 8,
|
|
971
|
+
document: 9,
|
|
972
|
+
documentFragment: 11
|
|
973
|
+
};
|
|
974
|
+
var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, [
|
|
975
|
+
"style",
|
|
976
|
+
"script",
|
|
977
|
+
"xmp",
|
|
978
|
+
"iframe",
|
|
979
|
+
"noembed",
|
|
980
|
+
"noframes",
|
|
981
|
+
"plaintext",
|
|
982
|
+
"noscript"
|
|
983
|
+
]));
|
|
984
|
+
var ESCAPABLE_TEXT_ELEMENTS = freeze(addToSet({}, ["textarea", "title"]));
|
|
985
|
+
var VOID_ELEMENTS = freeze(addToSet({}, [
|
|
986
|
+
"area",
|
|
987
|
+
"base",
|
|
988
|
+
"basefont",
|
|
989
|
+
"bgsound",
|
|
990
|
+
"br",
|
|
991
|
+
"col",
|
|
992
|
+
"embed",
|
|
993
|
+
"frame",
|
|
994
|
+
"hr",
|
|
995
|
+
"img",
|
|
996
|
+
"input",
|
|
997
|
+
"keygen",
|
|
998
|
+
"link",
|
|
999
|
+
"meta",
|
|
1000
|
+
"param",
|
|
1001
|
+
"source",
|
|
1002
|
+
"track",
|
|
1003
|
+
"wbr"
|
|
1004
|
+
]));
|
|
1005
|
+
var getGlobal = function getGlobal() {
|
|
1006
|
+
return typeof window === "undefined" ? null : window;
|
|
1007
|
+
};
|
|
1008
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
1009
|
+
if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function")
|
|
1010
|
+
return null;
|
|
1011
|
+
let suffix = null;
|
|
1012
|
+
const ATTR_NAME = "data-tt-policy-suffix";
|
|
1013
|
+
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME))
|
|
1014
|
+
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
1015
|
+
const policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
|
1016
|
+
try {
|
|
1017
|
+
return trustedTypes.createPolicy(policyName, {
|
|
1018
|
+
createHTML(html) {
|
|
1019
|
+
return html;
|
|
1020
|
+
},
|
|
1021
|
+
createScriptURL(scriptUrl) {
|
|
1022
|
+
return scriptUrl;
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
} catch (_) {
|
|
1026
|
+
console.warn("TrustedTypes policy " + policyName + " could not be created.");
|
|
1027
|
+
return null;
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
var _createHooksMap = function _createHooksMap() {
|
|
1031
|
+
return {
|
|
1032
|
+
afterSanitizeAttributes: [],
|
|
1033
|
+
afterSanitizeElements: [],
|
|
1034
|
+
afterSanitizeShadowDOM: [],
|
|
1035
|
+
beforeSanitizeAttributes: [],
|
|
1036
|
+
beforeSanitizeElements: [],
|
|
1037
|
+
beforeSanitizeShadowDOM: [],
|
|
1038
|
+
uponSanitizeAttribute: [],
|
|
1039
|
+
uponSanitizeElement: [],
|
|
1040
|
+
uponSanitizeShadowNode: []
|
|
1041
|
+
};
|
|
1042
|
+
};
|
|
1043
|
+
var _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
|
|
1044
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? cloneSet(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
1045
|
+
};
|
|
1046
|
+
var _resolveObjectOption = function _resolveObjectOption(cfg, key, fallback) {
|
|
1047
|
+
const value = objectHasOwnProperty(cfg, key) ? cfg[key] : undefined;
|
|
1048
|
+
return value && typeof value === "object" ? clone(value) : fallback;
|
|
1049
|
+
};
|
|
1050
|
+
function createDOMPurify() {
|
|
1051
|
+
let window2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
1052
|
+
const DOMPurify = (root) => createDOMPurify(root);
|
|
1053
|
+
DOMPurify.version = "3.5.0";
|
|
1054
|
+
DOMPurify.removed = [];
|
|
1055
|
+
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
1056
|
+
DOMPurify.isSupported = false;
|
|
1057
|
+
return DOMPurify;
|
|
1058
|
+
}
|
|
1059
|
+
let document = window2.document;
|
|
1060
|
+
const originalDocument = document;
|
|
1061
|
+
const currentScript = originalDocument.currentScript;
|
|
1062
|
+
const { HTMLTemplateElement, Node, Element, NodeFilter, DOMParser, trustedTypes } = window2;
|
|
1063
|
+
const ElementPrototype = Element.prototype;
|
|
1064
|
+
const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
|
|
1065
|
+
const remove = lookupGetter(ElementPrototype, "remove");
|
|
1066
|
+
const removeChild = lookupGetter(ElementPrototype, "removeChild");
|
|
1067
|
+
const removeAttributeNode = lookupGetter(ElementPrototype, "removeAttributeNode");
|
|
1068
|
+
const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
|
|
1069
|
+
const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
|
|
1070
|
+
const getParentNode = lookupGetter(ElementPrototype, "parentNode");
|
|
1071
|
+
const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
|
|
1072
|
+
const getAttributes = lookupGetter(ElementPrototype, "attributes");
|
|
1073
|
+
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
|
|
1074
|
+
const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
|
|
1075
|
+
const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, "ownerDocument") : null;
|
|
1076
|
+
const _readNodeType = function _readNodeType(node) {
|
|
1077
|
+
return getNodeType ? getNodeType(node) : node.nodeType;
|
|
1078
|
+
};
|
|
1079
|
+
const _readNodeName = function _readNodeName(node) {
|
|
1080
|
+
return getNodeName ? getNodeName(node) : node.nodeName;
|
|
1081
|
+
};
|
|
1082
|
+
const getNamespaceURI = lookupAccessor(ElementPrototype, "namespaceURI");
|
|
1083
|
+
const _readNamespaceURI = function _readNamespaceURI(element) {
|
|
1084
|
+
return getNamespaceURI ? getNamespaceURI(element) : element.namespaceURI;
|
|
1085
|
+
};
|
|
1086
|
+
const _readAttributes = function _readAttributes(node) {
|
|
1087
|
+
return _readNodeType(node) === NODE_TYPE.element ? getAttributes(node) : null;
|
|
1088
|
+
};
|
|
1089
|
+
if (typeof HTMLTemplateElement === "function") {
|
|
1090
|
+
const template = document.createElement("template");
|
|
1091
|
+
if (template.content && template.content.ownerDocument)
|
|
1092
|
+
document = template.content.ownerDocument;
|
|
1093
|
+
}
|
|
1094
|
+
let trustedTypesPolicy;
|
|
1095
|
+
let emptyHTML = "";
|
|
1096
|
+
let defaultTrustedTypesPolicy;
|
|
1097
|
+
let defaultTrustedTypesPolicyResolved = false;
|
|
1098
|
+
let IN_TRUSTED_TYPES_POLICY = 0;
|
|
1099
|
+
const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
|
|
1100
|
+
if (IN_TRUSTED_TYPES_POLICY > 0)
|
|
1101
|
+
throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
|
|
1102
|
+
};
|
|
1103
|
+
const _createTrustedHTML = function _createTrustedHTML(html) {
|
|
1104
|
+
_assertNotInTrustedTypesPolicy();
|
|
1105
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
1106
|
+
try {
|
|
1107
|
+
return trustedTypesPolicy.createHTML(html);
|
|
1108
|
+
} finally {
|
|
1109
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
const _signOutput = function _signOutput(html) {
|
|
1113
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(html) : html;
|
|
1114
|
+
};
|
|
1115
|
+
const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
|
|
1116
|
+
_assertNotInTrustedTypesPolicy();
|
|
1117
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
1118
|
+
try {
|
|
1119
|
+
return trustedTypesPolicy.createScriptURL(scriptUrl);
|
|
1120
|
+
} finally {
|
|
1121
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
|
|
1125
|
+
if (!defaultTrustedTypesPolicyResolved) {
|
|
1126
|
+
defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
1127
|
+
defaultTrustedTypesPolicyResolved = true;
|
|
1128
|
+
}
|
|
1129
|
+
return defaultTrustedTypesPolicy;
|
|
1130
|
+
};
|
|
1131
|
+
const _document = document, { implementation, createNodeIterator, createDocumentFragment, getElementsByTagName } = _document;
|
|
1132
|
+
const importNode = originalDocument.importNode;
|
|
1133
|
+
let hooks = _createHooksMap();
|
|
1134
|
+
DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== undefined;
|
|
1135
|
+
const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
|
|
1136
|
+
let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
|
|
1137
|
+
let ALLOWED_TAGS = null;
|
|
1138
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [
|
|
1139
|
+
...html$1,
|
|
1140
|
+
...svg$1,
|
|
1141
|
+
...svgFilters,
|
|
1142
|
+
...mathMl$1,
|
|
1143
|
+
...text
|
|
1144
|
+
]);
|
|
1145
|
+
let ALLOWED_ATTR = null;
|
|
1146
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [
|
|
1147
|
+
...html,
|
|
1148
|
+
...svg,
|
|
1149
|
+
...mathMl,
|
|
1150
|
+
...xml
|
|
1151
|
+
]);
|
|
1152
|
+
let CUSTOM_ELEMENT_HANDLING = null;
|
|
1153
|
+
let FORBID_TAGS = null;
|
|
1154
|
+
let FORBID_ATTR = null;
|
|
1155
|
+
const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
1156
|
+
tagCheck: {
|
|
1157
|
+
writable: true,
|
|
1158
|
+
configurable: false,
|
|
1159
|
+
enumerable: true,
|
|
1160
|
+
value: null
|
|
1161
|
+
},
|
|
1162
|
+
attributeCheck: {
|
|
1163
|
+
writable: true,
|
|
1164
|
+
configurable: false,
|
|
1165
|
+
enumerable: true,
|
|
1166
|
+
value: null
|
|
1167
|
+
}
|
|
1168
|
+
}));
|
|
1169
|
+
let ALLOW_ARIA_ATTR = true;
|
|
1170
|
+
let ALLOW_DATA_ATTR = true;
|
|
1171
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
1172
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
1173
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
1174
|
+
let SAFE_FOR_XML = true;
|
|
1175
|
+
let WHOLE_DOCUMENT = false;
|
|
1176
|
+
let SET_CONFIG = false;
|
|
1177
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
1178
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
1179
|
+
let FORCE_BODY = false;
|
|
1180
|
+
let RETURN_DOM = false;
|
|
1181
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
1182
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
1183
|
+
let SANITIZE_DOM = true;
|
|
1184
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
1185
|
+
const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
|
|
1186
|
+
let KEEP_CONTENT = true;
|
|
1187
|
+
let IN_PLACE = false;
|
|
1188
|
+
let IN_PLACE_VISITED = null;
|
|
1189
|
+
let IN_PLACE_RETURNS = null;
|
|
1190
|
+
let USE_PROFILES = false;
|
|
1191
|
+
let FORBID_CONTENTS = null;
|
|
1192
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
|
|
1193
|
+
"annotation-xml",
|
|
1194
|
+
"audio",
|
|
1195
|
+
"colgroup",
|
|
1196
|
+
"desc",
|
|
1197
|
+
"foreignobject",
|
|
1198
|
+
"head",
|
|
1199
|
+
"iframe",
|
|
1200
|
+
"math",
|
|
1201
|
+
"mi",
|
|
1202
|
+
"mn",
|
|
1203
|
+
"mo",
|
|
1204
|
+
"ms",
|
|
1205
|
+
"mtext",
|
|
1206
|
+
"noembed",
|
|
1207
|
+
"noframes",
|
|
1208
|
+
"noscript",
|
|
1209
|
+
"plaintext",
|
|
1210
|
+
"script",
|
|
1211
|
+
"selectedcontent",
|
|
1212
|
+
"style",
|
|
1213
|
+
"svg",
|
|
1214
|
+
"template",
|
|
1215
|
+
"thead",
|
|
1216
|
+
"title",
|
|
1217
|
+
"video",
|
|
1218
|
+
"xmp"
|
|
1219
|
+
]);
|
|
1220
|
+
let DATA_URI_TAGS = null;
|
|
1221
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, [
|
|
1222
|
+
"audio",
|
|
1223
|
+
"video",
|
|
1224
|
+
"img",
|
|
1225
|
+
"source",
|
|
1226
|
+
"image",
|
|
1227
|
+
"track"
|
|
1228
|
+
]);
|
|
1229
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
1230
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
|
|
1231
|
+
"alt",
|
|
1232
|
+
"class",
|
|
1233
|
+
"for",
|
|
1234
|
+
"id",
|
|
1235
|
+
"label",
|
|
1236
|
+
"name",
|
|
1237
|
+
"pattern",
|
|
1238
|
+
"placeholder",
|
|
1239
|
+
"role",
|
|
1240
|
+
"summary",
|
|
1241
|
+
"title",
|
|
1242
|
+
"value",
|
|
1243
|
+
"style",
|
|
1244
|
+
"xmlns"
|
|
1245
|
+
]);
|
|
1246
|
+
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
1247
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
1248
|
+
const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
1249
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
1250
|
+
let IS_EMPTY_INPUT = false;
|
|
1251
|
+
let ALLOWED_NAMESPACES = null;
|
|
1252
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
|
|
1253
|
+
MATHML_NAMESPACE,
|
|
1254
|
+
SVG_NAMESPACE,
|
|
1255
|
+
HTML_NAMESPACE
|
|
1256
|
+
], stringToString);
|
|
1257
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(addToSet({}, [
|
|
1258
|
+
"mi",
|
|
1259
|
+
"mo",
|
|
1260
|
+
"mn",
|
|
1261
|
+
"ms",
|
|
1262
|
+
"mtext"
|
|
1263
|
+
]));
|
|
1264
|
+
let MATHML_TEXT_INTEGRATION_POINTS = null;
|
|
1265
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(addToSet({}, ["annotation-xml"]));
|
|
1266
|
+
let HTML_INTEGRATION_POINTS = null;
|
|
1267
|
+
const DEFAULT_CUSTOM_ELEMENT_HANDLING = freeze(create(null));
|
|
1268
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
|
|
1269
|
+
"title",
|
|
1270
|
+
"style",
|
|
1271
|
+
"font",
|
|
1272
|
+
"a",
|
|
1273
|
+
"script"
|
|
1274
|
+
]);
|
|
1275
|
+
let PARSER_MEDIA_TYPE = null;
|
|
1276
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
1277
|
+
const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
|
|
1278
|
+
let transformCaseFunc = null;
|
|
1279
|
+
let CONFIG = null;
|
|
1280
|
+
let ACTIVE_CONFIG = null;
|
|
1281
|
+
const formElement = document.createElement("form");
|
|
1282
|
+
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
1283
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
1284
|
+
};
|
|
1285
|
+
const _parseConfig = function _parseConfig() {
|
|
1286
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1287
|
+
if (!cfg || typeof cfg !== "object")
|
|
1288
|
+
cfg = {};
|
|
1289
|
+
cfg = clone(cfg);
|
|
1290
|
+
PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
1291
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
1292
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, { transform: transformCaseFunc });
|
|
1293
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, { transform: transformCaseFunc });
|
|
1294
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, { transform: stringToString });
|
|
1295
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
1296
|
+
transform: transformCaseFunc,
|
|
1297
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
1298
|
+
});
|
|
1299
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
|
|
1300
|
+
transform: transformCaseFunc,
|
|
1301
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
1302
|
+
});
|
|
1303
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, { transform: transformCaseFunc });
|
|
1304
|
+
FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", create(null), { transform: transformCaseFunc });
|
|
1305
|
+
FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", create(null), { transform: transformCaseFunc });
|
|
1306
|
+
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
1307
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
1308
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
1309
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
|
1310
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
|
|
1311
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
|
|
1312
|
+
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
|
|
1313
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
|
|
1314
|
+
RETURN_DOM = cfg.RETURN_DOM || false;
|
|
1315
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
|
|
1316
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
|
|
1317
|
+
FORCE_BODY = cfg.FORCE_BODY || false;
|
|
1318
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
|
|
1319
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
|
1320
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
|
1321
|
+
IN_PLACE = cfg.IN_PLACE || false;
|
|
1322
|
+
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
1323
|
+
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
1324
|
+
MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, "MATHML_TEXT_INTEGRATION_POINTS", DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
1325
|
+
HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, "HTML_INTEGRATION_POINTS", DEFAULT_HTML_INTEGRATION_POINTS);
|
|
1326
|
+
const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", DEFAULT_CUSTOM_ELEMENT_HANDLING);
|
|
1327
|
+
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
1328
|
+
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck))
|
|
1329
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
|
|
1330
|
+
if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck))
|
|
1331
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
|
|
1332
|
+
if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean")
|
|
1333
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
|
|
1334
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
1335
|
+
if (SAFE_FOR_TEMPLATES)
|
|
1336
|
+
ALLOW_DATA_ATTR = false;
|
|
1337
|
+
if (RETURN_DOM_FRAGMENT)
|
|
1338
|
+
RETURN_DOM = true;
|
|
1339
|
+
if (USE_PROFILES) {
|
|
1340
|
+
if ((objectHasOwnProperty(cfg, "ALLOWED_TAGS") || objectHasOwnProperty(cfg, "ALLOWED_ATTR")) && typeof console !== "undefined" && typeof console.warn === "function")
|
|
1341
|
+
console.warn("DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together.");
|
|
1342
|
+
ALLOWED_TAGS = addToSet({}, text);
|
|
1343
|
+
ALLOWED_ATTR = create(null);
|
|
1344
|
+
if (USE_PROFILES.html === true) {
|
|
1345
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
1346
|
+
addToSet(ALLOWED_ATTR, html);
|
|
1347
|
+
}
|
|
1348
|
+
if (USE_PROFILES.svg === true) {
|
|
1349
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
1350
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
1351
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
1352
|
+
}
|
|
1353
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
1354
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
1355
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
1356
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
1357
|
+
}
|
|
1358
|
+
if (USE_PROFILES.mathMl === true) {
|
|
1359
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
1360
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
1361
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
1365
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
1366
|
+
if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
|
|
1367
|
+
if (typeof cfg.ADD_TAGS === "function")
|
|
1368
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
1369
|
+
else if (arrayIsArray(cfg.ADD_TAGS)) {
|
|
1370
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS)
|
|
1371
|
+
ALLOWED_TAGS = cloneSet(ALLOWED_TAGS);
|
|
1372
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
|
|
1376
|
+
if (typeof cfg.ADD_ATTR === "function")
|
|
1377
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
1378
|
+
else if (arrayIsArray(cfg.ADD_ATTR)) {
|
|
1379
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR)
|
|
1380
|
+
ALLOWED_ATTR = cloneSet(ALLOWED_ATTR);
|
|
1381
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
|
|
1385
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS)
|
|
1386
|
+
FORBID_CONTENTS = cloneSet(FORBID_CONTENTS);
|
|
1387
|
+
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
|
|
1388
|
+
}
|
|
1389
|
+
if (KEEP_CONTENT)
|
|
1390
|
+
ALLOWED_TAGS["#text"] = true;
|
|
1391
|
+
if (WHOLE_DOCUMENT)
|
|
1392
|
+
addToSet(ALLOWED_TAGS, [
|
|
1393
|
+
"html",
|
|
1394
|
+
"head",
|
|
1395
|
+
"body"
|
|
1396
|
+
]);
|
|
1397
|
+
if (ALLOWED_TAGS.table) {
|
|
1398
|
+
ALLOWED_TAGS.tbody = true;
|
|
1399
|
+
delete FORBID_TAGS.tbody;
|
|
1400
|
+
}
|
|
1401
|
+
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
1402
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function")
|
|
1403
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
1404
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function")
|
|
1405
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
1406
|
+
const previousTrustedTypesPolicy = trustedTypesPolicy;
|
|
1407
|
+
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
1408
|
+
try {
|
|
1409
|
+
emptyHTML = _createTrustedHTML("");
|
|
1410
|
+
} catch (error) {
|
|
1411
|
+
trustedTypesPolicy = previousTrustedTypesPolicy;
|
|
1412
|
+
throw error;
|
|
1413
|
+
}
|
|
1414
|
+
} else if (cfg.TRUSTED_TYPES_POLICY === null) {
|
|
1415
|
+
trustedTypesPolicy = undefined;
|
|
1416
|
+
emptyHTML = "";
|
|
1417
|
+
} else {
|
|
1418
|
+
if (trustedTypesPolicy === undefined)
|
|
1419
|
+
trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
|
|
1420
|
+
if (trustedTypesPolicy && typeof emptyHTML === "string")
|
|
1421
|
+
emptyHTML = _createTrustedHTML("");
|
|
1422
|
+
}
|
|
1423
|
+
CONFIG = freeze(cfg);
|
|
1424
|
+
};
|
|
1425
|
+
const ALL_SVG_TAGS = addToSet({}, [
|
|
1426
|
+
...svg$1,
|
|
1427
|
+
...svgFilters,
|
|
1428
|
+
...svgDisallowed
|
|
1429
|
+
]);
|
|
1430
|
+
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
1431
|
+
const _checkSvgNamespace = function _checkSvgNamespace(tagName, parentNamespace, parentTagName) {
|
|
1432
|
+
if (parentNamespace === HTML_NAMESPACE)
|
|
1433
|
+
return tagName === "svg";
|
|
1434
|
+
if (parentNamespace === MATHML_NAMESPACE)
|
|
1435
|
+
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
1436
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
1437
|
+
};
|
|
1438
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parentNamespace, parentTagName) {
|
|
1439
|
+
if (parentNamespace === HTML_NAMESPACE)
|
|
1440
|
+
return tagName === "math";
|
|
1441
|
+
if (parentNamespace === SVG_NAMESPACE)
|
|
1442
|
+
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
1443
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
1444
|
+
};
|
|
1445
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parentNamespace, parentTagName) {
|
|
1446
|
+
if (parentNamespace === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName])
|
|
1447
|
+
return false;
|
|
1448
|
+
if (parentNamespace === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName])
|
|
1449
|
+
return false;
|
|
1450
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
1451
|
+
};
|
|
1452
|
+
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
1453
|
+
const elementNamespace = _readNamespaceURI(element);
|
|
1454
|
+
const tagName = stringToLowerCase(_readNodeName(element));
|
|
1455
|
+
const parentNode = getParentNode(element);
|
|
1456
|
+
let parentNamespace = NAMESPACE;
|
|
1457
|
+
let parentTagName = "template";
|
|
1458
|
+
if (parentNode && _readNodeType(parentNode) === NODE_TYPE.element) {
|
|
1459
|
+
parentNamespace = _readNamespaceURI(parentNode);
|
|
1460
|
+
parentTagName = stringToLowerCase(_readNodeName(parentNode));
|
|
1461
|
+
}
|
|
1462
|
+
if (!ALLOWED_NAMESPACES[elementNamespace])
|
|
1463
|
+
return false;
|
|
1464
|
+
if (elementNamespace === SVG_NAMESPACE)
|
|
1465
|
+
return _checkSvgNamespace(tagName, parentNamespace, parentTagName);
|
|
1466
|
+
if (elementNamespace === MATHML_NAMESPACE)
|
|
1467
|
+
return _checkMathMlNamespace(tagName, parentNamespace, parentTagName);
|
|
1468
|
+
if (elementNamespace === HTML_NAMESPACE)
|
|
1469
|
+
return _checkHtmlNamespace(tagName, parentNamespace, parentTagName);
|
|
1470
|
+
return PARSER_MEDIA_TYPE === "application/xhtml+xml";
|
|
1471
|
+
};
|
|
1472
|
+
const _forceRemove = function _forceRemove(node) {
|
|
1473
|
+
arrayPush(DOMPurify.removed, { element: node });
|
|
1474
|
+
_unmarkVisited(node);
|
|
1475
|
+
try {
|
|
1476
|
+
getParentNode(node).removeChild(node);
|
|
1477
|
+
} catch (_) {
|
|
1478
|
+
remove(node);
|
|
1479
|
+
if (!getParentNode(node))
|
|
1480
|
+
throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {
|
|
1484
|
+
try {
|
|
1485
|
+
removeAttributeNode(element, attribute);
|
|
1486
|
+
} catch (_) {
|
|
1487
|
+
try {
|
|
1488
|
+
element.removeAttribute(name);
|
|
1489
|
+
} catch (_) {}
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
const _neutralizeRoot = function _neutralizeRoot(root) {
|
|
1493
|
+
_neutralizeSubtree(root);
|
|
1494
|
+
const childNodes = getChildNodes(root);
|
|
1495
|
+
if (childNodes)
|
|
1496
|
+
arrayForEach(arraySlice(childNodes), (child) => {
|
|
1497
|
+
try {
|
|
1498
|
+
removeChild(root, child);
|
|
1499
|
+
} catch (_) {}
|
|
1500
|
+
});
|
|
1501
|
+
if (_readNodeType(root) === NODE_TYPE.element)
|
|
1502
|
+
_stripAttributes(root, false);
|
|
1503
|
+
};
|
|
1504
|
+
const _removeAttribute = function _removeAttribute(name, element, attr) {
|
|
1505
|
+
if (!attr)
|
|
1506
|
+
try {
|
|
1507
|
+
attr = element.getAttributeNode(name);
|
|
1508
|
+
} catch (_) {
|
|
1509
|
+
attr = null;
|
|
1510
|
+
}
|
|
1511
|
+
arrayPush(DOMPurify.removed, {
|
|
1512
|
+
attribute: attr || null,
|
|
1513
|
+
from: element
|
|
1514
|
+
});
|
|
1515
|
+
if (attr)
|
|
1516
|
+
_stripAttributeNode(element, attr, name);
|
|
1517
|
+
else
|
|
1518
|
+
try {
|
|
1519
|
+
element.removeAttribute(name);
|
|
1520
|
+
} catch (_) {}
|
|
1521
|
+
if (name === "is") {
|
|
1522
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT)
|
|
1523
|
+
try {
|
|
1524
|
+
_forceRemove(element);
|
|
1525
|
+
} catch (_) {}
|
|
1526
|
+
else
|
|
1527
|
+
try {
|
|
1528
|
+
element.setAttribute(name, "");
|
|
1529
|
+
} catch (_) {}
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
const _stripAttributes = function _stripAttributes(element, keepAllowed) {
|
|
1533
|
+
const attributes = getAttributes(element);
|
|
1534
|
+
if (!attributes)
|
|
1535
|
+
return;
|
|
1536
|
+
for (let i = attributes.length - 1;i >= 0; --i) {
|
|
1537
|
+
const attribute = attributes[i];
|
|
1538
|
+
const name = attribute && attribute.name;
|
|
1539
|
+
if (typeof name === "string" && !(keepAllowed && ALLOWED_ATTR[transformCaseFunc(name)]))
|
|
1540
|
+
_stripAttributeNode(element, attribute, name);
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
const _walkTree = function _walkTree(root, visit) {
|
|
1544
|
+
let intoShadow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1545
|
+
const stack = [root];
|
|
1546
|
+
while (stack.length > 0) {
|
|
1547
|
+
const node = stack.pop();
|
|
1548
|
+
if (visit(node) === false)
|
|
1549
|
+
continue;
|
|
1550
|
+
if (intoShadow && _readNodeType(node) === NODE_TYPE.element) {
|
|
1551
|
+
const shadowRoot = getShadowRoot(node);
|
|
1552
|
+
if (_isDocumentFragment(shadowRoot))
|
|
1553
|
+
stack.push(shadowRoot);
|
|
1554
|
+
}
|
|
1555
|
+
const childNodes = getChildNodes(node);
|
|
1556
|
+
if (childNodes)
|
|
1557
|
+
for (let i = childNodes.length - 1;i >= 0; --i)
|
|
1558
|
+
stack.push(childNodes[i]);
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
const _neutralizeSubtree = function _neutralizeSubtree(root) {
|
|
1562
|
+
_walkTree(root, (node) => {
|
|
1563
|
+
if (_readNodeType(node) === NODE_TYPE.element)
|
|
1564
|
+
_stripAttributes(node, true);
|
|
1565
|
+
});
|
|
1566
|
+
};
|
|
1567
|
+
const _collectLiveNodes = function _collectLiveNodes(root) {
|
|
1568
|
+
const nodes = [];
|
|
1569
|
+
_walkTree(root, (node) => {
|
|
1570
|
+
nodes.push(node);
|
|
1571
|
+
}, true);
|
|
1572
|
+
return nodes;
|
|
1573
|
+
};
|
|
1574
|
+
const _neutralizeEscapedElements = function _neutralizeEscapedElements(root, before) {
|
|
1575
|
+
const reachable = setCreate();
|
|
1576
|
+
arrayForEach(_collectLiveNodes(root), (node) => {
|
|
1577
|
+
if (_readNodeType(node) === NODE_TYPE.element)
|
|
1578
|
+
setAdd(reachable, node);
|
|
1579
|
+
});
|
|
1580
|
+
arrayForEach(before, (node) => {
|
|
1581
|
+
if (_readNodeType(node) === NODE_TYPE.element && !setHas(reachable, node))
|
|
1582
|
+
_stripAttributes(node, true);
|
|
1583
|
+
});
|
|
1584
|
+
};
|
|
1585
|
+
const _neutralizeDiscarded = function _neutralizeDiscarded(root, before) {
|
|
1586
|
+
let rootRemoved = false;
|
|
1587
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
1588
|
+
if (entry.element) {
|
|
1589
|
+
rootRemoved = rootRemoved || entry.element === root;
|
|
1590
|
+
_neutralizeSubtree(entry.element);
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
_neutralizeEscapedElements(root, before);
|
|
1594
|
+
return rootRemoved;
|
|
1595
|
+
};
|
|
1596
|
+
const _failClosed = function _failClosed(root, before) {
|
|
1597
|
+
_neutralizeRoot(root);
|
|
1598
|
+
_neutralizeDiscarded(root, before);
|
|
1599
|
+
};
|
|
1600
|
+
const MAX_UNVISITED_ROUNDS = 8;
|
|
1601
|
+
const _sanitizeUnvisitedNodes = function _sanitizeUnvisitedNodes(root, before) {
|
|
1602
|
+
const visited = IN_PLACE_VISITED;
|
|
1603
|
+
let original = null;
|
|
1604
|
+
const getOriginal = () => {
|
|
1605
|
+
if (!original) {
|
|
1606
|
+
original = setCreate();
|
|
1607
|
+
arrayForEach(before, (beforeNode) => {
|
|
1608
|
+
setAdd(original, beforeNode);
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
return original;
|
|
1612
|
+
};
|
|
1613
|
+
for (let round = 0;; round++) {
|
|
1614
|
+
const live = _collectLiveNodes(root);
|
|
1615
|
+
const containers = [root];
|
|
1616
|
+
let pending = false;
|
|
1617
|
+
arrayForEach(live, (node) => {
|
|
1618
|
+
if (_readNodeType(node) === NODE_TYPE.documentFragment)
|
|
1619
|
+
arrayPush(containers, node);
|
|
1620
|
+
else if (!pending && !setHas(visited, node))
|
|
1621
|
+
pending = setHas(getOriginal(), node);
|
|
1622
|
+
});
|
|
1623
|
+
if (!pending)
|
|
1624
|
+
return;
|
|
1625
|
+
if (round >= MAX_UNVISITED_ROUNDS)
|
|
1626
|
+
throw typeErrorCreate("the tree kept changing during in-place sanitization; refusing to return it");
|
|
1627
|
+
arrayForEach(containers, (container, index) => {
|
|
1628
|
+
_sanitizeUnvisitedIn(container, index > 0, root, getOriginal());
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
const _sanitizeUnvisitedIn = function _sanitizeUnvisitedIn(container, inShadow, root, original) {
|
|
1633
|
+
const iterator = _createNodeIterator(container);
|
|
1634
|
+
let node;
|
|
1635
|
+
while (node = iterator.nextNode()) {
|
|
1636
|
+
if (!setHas(original, node) || setHas(IN_PLACE_VISITED, node))
|
|
1637
|
+
continue;
|
|
1638
|
+
if (inShadow)
|
|
1639
|
+
_executeHooks(hooks.uponSanitizeShadowNode, node, null);
|
|
1640
|
+
_sanitizeNode(node, root);
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
const _markVisited = function _markVisited(node) {
|
|
1644
|
+
if (!IN_PLACE_VISITED)
|
|
1645
|
+
return;
|
|
1646
|
+
setAdd(IN_PLACE_VISITED, node);
|
|
1647
|
+
const returns = mapGet(IN_PLACE_RETURNS, node);
|
|
1648
|
+
if (returns === undefined)
|
|
1649
|
+
return;
|
|
1650
|
+
if (returns >= MAX_UNVISITED_ROUNDS)
|
|
1651
|
+
throw typeErrorCreate("the tree kept changing during in-place sanitization; refusing to return it");
|
|
1652
|
+
mapSet(IN_PLACE_RETURNS, node, returns + 1);
|
|
1653
|
+
};
|
|
1654
|
+
const _unmarkVisited = function _unmarkVisited(node) {
|
|
1655
|
+
if (!IN_PLACE_VISITED)
|
|
1656
|
+
return;
|
|
1657
|
+
setDelete(IN_PLACE_VISITED, node);
|
|
1658
|
+
if (mapGet(IN_PLACE_RETURNS, node) === undefined)
|
|
1659
|
+
mapSet(IN_PLACE_RETURNS, node, 0);
|
|
1660
|
+
};
|
|
1661
|
+
const _isPatchLinkageAttribute = function _isPatchLinkageAttribute(lcName, lcTag) {
|
|
1662
|
+
if (!SAFE_FOR_XML)
|
|
1663
|
+
return false;
|
|
1664
|
+
if (lcName === "patchsrc")
|
|
1665
|
+
return true;
|
|
1666
|
+
return lcName === "for" && lcTag !== "label" && lcTag !== "output";
|
|
1667
|
+
};
|
|
1668
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
|
|
1669
|
+
if (!SAFE_FOR_XML)
|
|
1670
|
+
return;
|
|
1671
|
+
_walkTree(root, (node) => {
|
|
1672
|
+
const nodeType = _readNodeType(node);
|
|
1673
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
1674
|
+
try {
|
|
1675
|
+
remove(node);
|
|
1676
|
+
} catch (_) {}
|
|
1677
|
+
return false;
|
|
1678
|
+
}
|
|
1679
|
+
if (nodeType === NODE_TYPE.element) {
|
|
1680
|
+
const element = node;
|
|
1681
|
+
const lcTag = transformCaseFunc(_readNodeName(node));
|
|
1682
|
+
try {
|
|
1683
|
+
if (element.hasAttribute && element.hasAttribute("patchsrc"))
|
|
1684
|
+
element.removeAttribute("patchsrc");
|
|
1685
|
+
if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag))
|
|
1686
|
+
element.removeAttribute("for");
|
|
1687
|
+
} catch (_) {}
|
|
1688
|
+
}
|
|
1689
|
+
return true;
|
|
1690
|
+
});
|
|
1691
|
+
};
|
|
1692
|
+
const _initDocument = function _initDocument(dirty) {
|
|
1693
|
+
let doc = null;
|
|
1694
|
+
let leadingWhitespace = null;
|
|
1695
|
+
if (FORCE_BODY)
|
|
1696
|
+
dirty = "<remove></remove>" + dirty;
|
|
1697
|
+
else {
|
|
1698
|
+
const matches = stringMatch(dirty, LEADING_WHITESPACE);
|
|
1699
|
+
leadingWhitespace = matches && matches[0];
|
|
1700
|
+
}
|
|
1701
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE)
|
|
1702
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
|
|
1703
|
+
const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
|
|
1704
|
+
if (NAMESPACE === HTML_NAMESPACE)
|
|
1705
|
+
try {
|
|
1706
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
1707
|
+
} catch (_) {}
|
|
1708
|
+
if (!doc || !doc.documentElement) {
|
|
1709
|
+
doc = implementation.createDocument(NAMESPACE, "template", null);
|
|
1710
|
+
try {
|
|
1711
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
1712
|
+
} catch (_) {}
|
|
1713
|
+
}
|
|
1714
|
+
const body = doc.body || doc.documentElement;
|
|
1715
|
+
if (dirty && leadingWhitespace)
|
|
1716
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
1717
|
+
if (NAMESPACE === HTML_NAMESPACE)
|
|
1718
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
|
|
1719
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
1720
|
+
};
|
|
1721
|
+
const _createNodeIterator = function _createNodeIterator(root) {
|
|
1722
|
+
let characterDataOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1723
|
+
const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
|
|
1724
|
+
return createNodeIterator.call(doc || root, root, (characterDataOnly ? 0 : NodeFilter.SHOW_ELEMENT) | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
1725
|
+
};
|
|
1726
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
|
|
1727
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
|
1728
|
+
value = stringReplace(value, ERB_EXPR$1, " ");
|
|
1729
|
+
value = stringReplace(value, TMPLIT_EXPR$1, " ");
|
|
1730
|
+
return value;
|
|
1731
|
+
};
|
|
1732
|
+
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
1733
|
+
var _node$querySelectorAl;
|
|
1734
|
+
_scrubOwnCharacterData(node);
|
|
1735
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === undefined ? undefined : _node$querySelectorAl.call(node, "template");
|
|
1736
|
+
if (templates)
|
|
1737
|
+
arrayForEach(templates, (tmpl) => {
|
|
1738
|
+
if (_isDocumentFragment(tmpl.content))
|
|
1739
|
+
_scrubTemplateExpressions2(tmpl.content);
|
|
1740
|
+
});
|
|
1741
|
+
};
|
|
1742
|
+
const TABLE_STRUCTURE = "table,tbody,thead,tfoot,tr,colgroup";
|
|
1743
|
+
const TABLE_CONTENT = addToSet({}, [
|
|
1744
|
+
"caption",
|
|
1745
|
+
"colgroup",
|
|
1746
|
+
"col",
|
|
1747
|
+
"thead",
|
|
1748
|
+
"tbody",
|
|
1749
|
+
"tfoot",
|
|
1750
|
+
"tr",
|
|
1751
|
+
"td",
|
|
1752
|
+
"th",
|
|
1753
|
+
"style",
|
|
1754
|
+
"script",
|
|
1755
|
+
"template"
|
|
1756
|
+
]);
|
|
1757
|
+
const _fosterTableContent = function _fosterTableContent(root) {
|
|
1758
|
+
var _root$querySelectorAl;
|
|
1759
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml")
|
|
1760
|
+
return;
|
|
1761
|
+
const structures = (_root$querySelectorAl = root.querySelectorAll) === null || _root$querySelectorAl === undefined ? undefined : _root$querySelectorAl.call(root, TABLE_STRUCTURE);
|
|
1762
|
+
if (!structures || structures.length === 0)
|
|
1763
|
+
return;
|
|
1764
|
+
arrayForEach(structures, (structure) => {
|
|
1765
|
+
arrayForEach(arraySlice(getChildNodes(structure)), (child) => {
|
|
1766
|
+
const nodeType = _readNodeType(child);
|
|
1767
|
+
if (!(nodeType === NODE_TYPE.text ? regExpTest(NON_WHITESPACE, child.data) : nodeType === NODE_TYPE.element && !TABLE_CONTENT[stringToLowerCase(_readNodeName(child))]))
|
|
1768
|
+
return;
|
|
1769
|
+
let table = structure;
|
|
1770
|
+
while (table && stringToLowerCase(_readNodeName(table)) !== "table")
|
|
1771
|
+
table = table === root ? null : getParentNode(table);
|
|
1772
|
+
const tableParent = table && table !== root ? getParentNode(table) : null;
|
|
1773
|
+
if (tableParent)
|
|
1774
|
+
try {
|
|
1775
|
+
tableParent.insertBefore(child, table);
|
|
1776
|
+
} catch (_) {}
|
|
1777
|
+
});
|
|
1778
|
+
});
|
|
1779
|
+
};
|
|
1780
|
+
const _scrubOwnCharacterData = function _scrubOwnCharacterData(node) {
|
|
1781
|
+
_fosterTableContent(node);
|
|
1782
|
+
node.normalize();
|
|
1783
|
+
const walker = _createNodeIterator(node, true);
|
|
1784
|
+
let previousText = null;
|
|
1785
|
+
let currentNode = walker.nextNode();
|
|
1786
|
+
while (currentNode) {
|
|
1787
|
+
let data = currentNode.data;
|
|
1788
|
+
if (regExpTest(NUL, data)) {
|
|
1789
|
+
data = stringReplace(data, NUL, "");
|
|
1790
|
+
currentNode.data = data;
|
|
1791
|
+
}
|
|
1792
|
+
if (regExpTest(TMPL_MARKER, data)) {
|
|
1793
|
+
data = _stripTemplateExpressions(data);
|
|
1794
|
+
currentNode.data = data;
|
|
1795
|
+
}
|
|
1796
|
+
if (data && _readNodeType(currentNode) === NODE_TYPE.text) {
|
|
1797
|
+
if (previousText) {
|
|
1798
|
+
const tail = previousText.data;
|
|
1799
|
+
const boundary = tail[tail.length - 1] + data[0];
|
|
1800
|
+
if (regExpTest(TMPL_MARKER, boundary))
|
|
1801
|
+
previousText.data = _stripTemplateExpressions(tail + data[0]);
|
|
1802
|
+
}
|
|
1803
|
+
previousText = currentNode;
|
|
1804
|
+
}
|
|
1805
|
+
currentNode = walker.nextNode();
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
const _isClobbered = function _isClobbered(element) {
|
|
1809
|
+
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
1810
|
+
if (typeof realTagName !== "string")
|
|
1811
|
+
return false;
|
|
1812
|
+
if (transformCaseFunc(realTagName) !== "form")
|
|
1813
|
+
return false;
|
|
1814
|
+
return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
|
|
1815
|
+
};
|
|
1816
|
+
const _nodeTypeOf = function _nodeTypeOf(value) {
|
|
1817
|
+
if (!getNodeType || typeof value !== "object" || value === null)
|
|
1818
|
+
return null;
|
|
1819
|
+
try {
|
|
1820
|
+
const nodeType = getNodeType(value);
|
|
1821
|
+
return typeof nodeType === "number" ? nodeType : null;
|
|
1822
|
+
} catch (_) {
|
|
1823
|
+
return null;
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
const _isDocumentFragment = function _isDocumentFragment(value) {
|
|
1827
|
+
return _nodeTypeOf(value) === NODE_TYPE.documentFragment;
|
|
1828
|
+
};
|
|
1829
|
+
const _isNode = function _isNode(value) {
|
|
1830
|
+
return _nodeTypeOf(value) !== null;
|
|
1831
|
+
};
|
|
1832
|
+
function _executeHooks(hooks, currentNode, data) {
|
|
1833
|
+
if (hooks.length === 0)
|
|
1834
|
+
return;
|
|
1835
|
+
arrayForEach(hooks, (hook) => {
|
|
1836
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
const _isMalformedElement = function _isMalformedElement(currentNode, tagName) {
|
|
1840
|
+
const isVoid = Boolean(VOID_ELEMENTS[tagName]);
|
|
1841
|
+
const literal = Boolean(LITERAL_TEXT_ELEMENTS[tagName]);
|
|
1842
|
+
if (!isVoid && !literal && !ESCAPABLE_TEXT_ELEMENTS[tagName])
|
|
1843
|
+
return false;
|
|
1844
|
+
if (_readNamespaceURI(currentNode) !== HTML_NAMESPACE)
|
|
1845
|
+
return false;
|
|
1846
|
+
if (isVoid)
|
|
1847
|
+
return currentNode.hasChildNodes();
|
|
1848
|
+
if (_isNode(currentNode.firstElementChild))
|
|
1849
|
+
return true;
|
|
1850
|
+
return literal && typeof currentNode.textContent === "string" && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent);
|
|
1851
|
+
};
|
|
1852
|
+
const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName, nodeType) {
|
|
1853
|
+
if (SAFE_FOR_XML && nodeType === NODE_TYPE.element && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML))
|
|
1854
|
+
return true;
|
|
1855
|
+
if (SAFE_FOR_XML && nodeType === NODE_TYPE.element && _isMalformedElement(currentNode, tagName))
|
|
1856
|
+
return true;
|
|
1857
|
+
if (nodeType === NODE_TYPE.processingInstruction)
|
|
1858
|
+
return true;
|
|
1859
|
+
if (SAFE_FOR_XML && nodeType === NODE_TYPE.comment && regExpTest(COMMENT_UNSAFE, currentNode.data))
|
|
1860
|
+
return true;
|
|
1861
|
+
return false;
|
|
1862
|
+
};
|
|
1863
|
+
const _matchesNameCheck = function _matchesNameCheck(check, name) {
|
|
1864
|
+
if (check instanceof RegExp)
|
|
1865
|
+
return regExpTest(check, name);
|
|
1866
|
+
if (check instanceof Function) {
|
|
1867
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2;_key < _len; _key++)
|
|
1868
|
+
args[_key - 2] = arguments[_key];
|
|
1869
|
+
return Boolean(check(name, ...args));
|
|
1870
|
+
}
|
|
1871
|
+
return false;
|
|
1872
|
+
};
|
|
1873
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
|
|
1874
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName))
|
|
1875
|
+
return false;
|
|
1876
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
|
|
1877
|
+
const parentNode = getParentNode(currentNode);
|
|
1878
|
+
const childNodes = getChildNodes(currentNode);
|
|
1879
|
+
if (childNodes && parentNode) {
|
|
1880
|
+
const childCount = childNodes.length;
|
|
1881
|
+
for (let i = childCount - 1;i >= 0; --i) {
|
|
1882
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
1883
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
_forceRemove(currentNode);
|
|
1888
|
+
return true;
|
|
1889
|
+
};
|
|
1890
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
|
|
1891
|
+
if (hookList.length === 0)
|
|
1892
|
+
return set;
|
|
1893
|
+
return set === defaultSet || set === setConfigSet ? cloneSet(set) : set;
|
|
1894
|
+
};
|
|
1895
|
+
const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
|
|
1896
|
+
if (currentNode === root || getParentNode(currentNode) !== null)
|
|
1897
|
+
return false;
|
|
1898
|
+
if (IN_PLACE)
|
|
1899
|
+
_neutralizeSubtree(currentNode);
|
|
1900
|
+
_unmarkVisited(currentNode);
|
|
1901
|
+
return true;
|
|
1902
|
+
};
|
|
1903
|
+
const _sanitizeElements = function _sanitizeElements(currentNode, root) {
|
|
1904
|
+
_markVisited(currentNode);
|
|
1905
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
1906
|
+
if (_handleHookDetachedNode(currentNode, root))
|
|
1907
|
+
return true;
|
|
1908
|
+
if (_isClobbered(currentNode)) {
|
|
1909
|
+
_forceRemove(currentNode);
|
|
1910
|
+
return true;
|
|
1911
|
+
}
|
|
1912
|
+
const tagName = transformCaseFunc(_readNodeName(currentNode));
|
|
1913
|
+
const nodeType = _readNodeType(currentNode);
|
|
1914
|
+
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
1915
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
1916
|
+
tagName,
|
|
1917
|
+
allowedTags: ALLOWED_TAGS
|
|
1918
|
+
});
|
|
1919
|
+
if (_handleHookDetachedNode(currentNode, root))
|
|
1920
|
+
return true;
|
|
1921
|
+
if (_isUnsafeNode(currentNode, tagName, nodeType)) {
|
|
1922
|
+
_forceRemove(currentNode);
|
|
1923
|
+
return true;
|
|
1924
|
+
}
|
|
1925
|
+
if ((FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) && _sanitizeDisallowedNode(currentNode, tagName, root))
|
|
1926
|
+
return true;
|
|
1927
|
+
if (nodeType === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
1928
|
+
_forceRemove(currentNode);
|
|
1929
|
+
return true;
|
|
1930
|
+
}
|
|
1931
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
1932
|
+
_forceRemove(currentNode);
|
|
1933
|
+
return true;
|
|
1934
|
+
}
|
|
1935
|
+
if (SAFE_FOR_TEMPLATES && nodeType === NODE_TYPE.text) {
|
|
1936
|
+
const text = currentNode.textContent;
|
|
1937
|
+
const content = _stripTemplateExpressions(text);
|
|
1938
|
+
if (text !== content) {
|
|
1939
|
+
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
|
1940
|
+
currentNode.textContent = content;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
1944
|
+
return _handleHookDetachedNode(currentNode, root);
|
|
1945
|
+
};
|
|
1946
|
+
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
1947
|
+
if (FORBID_ATTR[lcName])
|
|
1948
|
+
return false;
|
|
1949
|
+
if (_isPatchLinkageAttribute(lcName, lcTag))
|
|
1950
|
+
return false;
|
|
1951
|
+
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && ((value in document) || (value in formElement)))
|
|
1952
|
+
return false;
|
|
1953
|
+
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
1954
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName))
|
|
1955
|
+
return true;
|
|
1956
|
+
if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName))
|
|
1957
|
+
return true;
|
|
1958
|
+
if (!nameIsPermitted)
|
|
1959
|
+
return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
|
|
1960
|
+
if (URI_SAFE_ATTRIBUTES[lcName])
|
|
1961
|
+
return true;
|
|
1962
|
+
const compactValue = stringReplace(value, ATTR_WHITESPACE$1, "");
|
|
1963
|
+
if (regExpTest(IS_ALLOWED_URI$1, compactValue))
|
|
1964
|
+
return true;
|
|
1965
|
+
if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag])
|
|
1966
|
+
return true;
|
|
1967
|
+
if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, compactValue))
|
|
1968
|
+
return true;
|
|
1969
|
+
return !value;
|
|
1970
|
+
};
|
|
1971
|
+
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
|
|
1972
|
+
"annotation-xml",
|
|
1973
|
+
"color-profile",
|
|
1974
|
+
"font-face",
|
|
1975
|
+
"font-face-format",
|
|
1976
|
+
"font-face-name",
|
|
1977
|
+
"font-face-src",
|
|
1978
|
+
"font-face-uri",
|
|
1979
|
+
"missing-glyph"
|
|
1980
|
+
]);
|
|
1981
|
+
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
1982
|
+
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
1983
|
+
};
|
|
1984
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
|
|
1985
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI)
|
|
1986
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
1987
|
+
case "TrustedHTML":
|
|
1988
|
+
return _createTrustedHTML(value);
|
|
1989
|
+
case "TrustedScriptURL":
|
|
1990
|
+
return _createTrustedScriptURL(value);
|
|
1991
|
+
}
|
|
1992
|
+
return value;
|
|
1993
|
+
};
|
|
1994
|
+
const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
|
|
1995
|
+
try {
|
|
1996
|
+
if (namespaceURI)
|
|
1997
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
1998
|
+
else
|
|
1999
|
+
currentNode.setAttribute(name, value);
|
|
2000
|
+
if (_isClobbered(currentNode)) {
|
|
2001
|
+
_forceRemove(currentNode);
|
|
2002
|
+
return false;
|
|
2003
|
+
}
|
|
2004
|
+
return true;
|
|
2005
|
+
} catch (_) {
|
|
2006
|
+
_removeAttribute(name, currentNode);
|
|
2007
|
+
return false;
|
|
2008
|
+
}
|
|
2009
|
+
};
|
|
2010
|
+
const _isUnsafeAttributeValue = function _isUnsafeAttributeValue(name, value) {
|
|
2011
|
+
if (SAFE_FOR_XML && regExpTest(ATTR_VALUE_BREAKOUT, value))
|
|
2012
|
+
return true;
|
|
2013
|
+
return stringToLowerCase(name) === "attributename" && stringIndexOf(value, "href") !== -1;
|
|
2014
|
+
};
|
|
2015
|
+
const _sanitizeAttributes = function _sanitizeAttributes(currentNode, root) {
|
|
2016
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
2017
|
+
if (_handleHookDetachedNode(currentNode, root))
|
|
2018
|
+
return;
|
|
2019
|
+
const attributes = _readAttributes(currentNode);
|
|
2020
|
+
if (!attributes || _isClobbered(currentNode))
|
|
2021
|
+
return;
|
|
2022
|
+
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
2023
|
+
const hookEvent = {
|
|
2024
|
+
attrName: "",
|
|
2025
|
+
attrValue: "",
|
|
2026
|
+
keepAttr: true,
|
|
2027
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
2028
|
+
forceKeepAttr: undefined
|
|
2029
|
+
};
|
|
2030
|
+
let l = attributes.length;
|
|
2031
|
+
const lcTag = transformCaseFunc(_readNodeName(currentNode));
|
|
2032
|
+
while (l--) {
|
|
2033
|
+
const attr = attributes[l];
|
|
2034
|
+
if (!attr)
|
|
2035
|
+
continue;
|
|
2036
|
+
const { name, namespaceURI, value: attrValue } = attr;
|
|
2037
|
+
const lcName = transformCaseFunc(name);
|
|
2038
|
+
const initValue = attrValue;
|
|
2039
|
+
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
2040
|
+
let recreatedNamedProp = false;
|
|
2041
|
+
hookEvent.attrName = lcName;
|
|
2042
|
+
hookEvent.attrValue = value;
|
|
2043
|
+
hookEvent.keepAttr = true;
|
|
2044
|
+
hookEvent.forceKeepAttr = undefined;
|
|
2045
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
2046
|
+
value = hookEvent.attrValue;
|
|
2047
|
+
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
2048
|
+
_removeAttribute(name, currentNode, attr);
|
|
2049
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
2050
|
+
recreatedNamedProp = true;
|
|
2051
|
+
}
|
|
2052
|
+
if (_isUnsafeAttributeValue(name, value)) {
|
|
2053
|
+
_removeAttribute(name, currentNode, attr);
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
if (hookEvent.forceKeepAttr)
|
|
2057
|
+
continue;
|
|
2058
|
+
if (!hookEvent.keepAttr) {
|
|
2059
|
+
_removeAttribute(name, currentNode, attr);
|
|
2060
|
+
continue;
|
|
2061
|
+
}
|
|
2062
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
2063
|
+
_removeAttribute(name, currentNode, attr);
|
|
2064
|
+
continue;
|
|
2065
|
+
}
|
|
2066
|
+
if (SAFE_FOR_TEMPLATES)
|
|
2067
|
+
value = _stripTemplateExpressions(value);
|
|
2068
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
2069
|
+
_removeAttribute(name, currentNode, attr);
|
|
2070
|
+
continue;
|
|
2071
|
+
}
|
|
2072
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
2073
|
+
if (value !== initValue) {
|
|
2074
|
+
if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp)
|
|
2075
|
+
arrayPop(DOMPurify.removed);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
2079
|
+
_handleHookDetachedNode(currentNode, root);
|
|
2080
|
+
};
|
|
2081
|
+
const _sanitizeNode = function _sanitizeNode(node, root) {
|
|
2082
|
+
_sanitizeElements(node, root);
|
|
2083
|
+
_sanitizeAttributes(node, root);
|
|
2084
|
+
if (_isDocumentFragment(node.content))
|
|
2085
|
+
_sanitizeShadowDOM2(node.content);
|
|
2086
|
+
};
|
|
2087
|
+
const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
|
|
2088
|
+
let shadowNode = null;
|
|
2089
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
2090
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
2091
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
2092
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
2093
|
+
_sanitizeNode(shadowNode, fragment);
|
|
2094
|
+
if (_readNodeType(shadowNode) === NODE_TYPE.element) {
|
|
2095
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
2096
|
+
if (_isDocumentFragment(innerSr)) {
|
|
2097
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
2098
|
+
_sanitizeShadowDOM2(innerSr);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
if (SAFE_FOR_TEMPLATES)
|
|
2103
|
+
_scrubOwnCharacterData(fragment);
|
|
2104
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
2105
|
+
};
|
|
2106
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
|
|
2107
|
+
const stack = [{
|
|
2108
|
+
node: root,
|
|
2109
|
+
shadow: null
|
|
2110
|
+
}];
|
|
2111
|
+
while (stack.length > 0) {
|
|
2112
|
+
const item = stack.pop();
|
|
2113
|
+
if (item.shadow) {
|
|
2114
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
2115
|
+
continue;
|
|
2116
|
+
}
|
|
2117
|
+
const node = item.node;
|
|
2118
|
+
const isElement = _readNodeType(node) === NODE_TYPE.element;
|
|
2119
|
+
const childNodes = getChildNodes(node);
|
|
2120
|
+
if (childNodes)
|
|
2121
|
+
for (let i = childNodes.length - 1;i >= 0; --i)
|
|
2122
|
+
stack.push({
|
|
2123
|
+
node: childNodes[i],
|
|
2124
|
+
shadow: null
|
|
2125
|
+
});
|
|
2126
|
+
if (isElement) {
|
|
2127
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
2128
|
+
if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
|
|
2129
|
+
const content = node.content;
|
|
2130
|
+
if (_isDocumentFragment(content))
|
|
2131
|
+
stack.push({
|
|
2132
|
+
node: content,
|
|
2133
|
+
shadow: null
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
if (isElement) {
|
|
2138
|
+
const sr = getShadowRoot(node);
|
|
2139
|
+
if (_isDocumentFragment(sr))
|
|
2140
|
+
stack.push({
|
|
2141
|
+
node: null,
|
|
2142
|
+
shadow: sr
|
|
2143
|
+
}, {
|
|
2144
|
+
node: sr,
|
|
2145
|
+
shadow: null
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2150
|
+
const _sanitize = function _sanitize(dirty) {
|
|
2151
|
+
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2152
|
+
let body = null;
|
|
2153
|
+
let importedNode = null;
|
|
2154
|
+
let currentNode = null;
|
|
2155
|
+
let returnNode = null;
|
|
2156
|
+
IS_EMPTY_INPUT = !dirty;
|
|
2157
|
+
if (IS_EMPTY_INPUT)
|
|
2158
|
+
dirty = "<!-->";
|
|
2159
|
+
if (typeof dirty !== "string" && !_isNode(dirty)) {
|
|
2160
|
+
dirty = stringifyValue(dirty);
|
|
2161
|
+
if (typeof dirty !== "string")
|
|
2162
|
+
throw typeErrorCreate("dirty is not a string, aborting");
|
|
2163
|
+
}
|
|
2164
|
+
if (!DOMPurify.isSupported)
|
|
2165
|
+
return dirty;
|
|
2166
|
+
if (SET_CONFIG) {
|
|
2167
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
2168
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
2169
|
+
} else
|
|
2170
|
+
_parseConfig(cfg);
|
|
2171
|
+
ACTIVE_CONFIG = CONFIG;
|
|
2172
|
+
DOMPurify.removed = [];
|
|
2173
|
+
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
2174
|
+
let inPlaceNodes = [];
|
|
2175
|
+
const outerVisited = IN_PLACE_VISITED;
|
|
2176
|
+
const outerReturns = IN_PLACE_RETURNS;
|
|
2177
|
+
if (inPlace) {
|
|
2178
|
+
_neutralizePatchLinkage(dirty);
|
|
2179
|
+
inPlaceNodes = _collectLiveNodes(dirty);
|
|
2180
|
+
const nn = _readNodeName(dirty);
|
|
2181
|
+
if (typeof nn === "string") {
|
|
2182
|
+
const tagName = transformCaseFunc(nn);
|
|
2183
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
2184
|
+
_failClosed(dirty, inPlaceNodes);
|
|
2185
|
+
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
if (_isClobbered(dirty)) {
|
|
2189
|
+
_failClosed(dirty, inPlaceNodes);
|
|
2190
|
+
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
2191
|
+
}
|
|
2192
|
+
IN_PLACE_VISITED = setCreate();
|
|
2193
|
+
IN_PLACE_RETURNS = mapCreate();
|
|
2194
|
+
} else if (_isNode(dirty)) {
|
|
2195
|
+
body = _initDocument("<!---->");
|
|
2196
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
2197
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY")
|
|
2198
|
+
body = importedNode;
|
|
2199
|
+
else if (importedNode.nodeName === "HTML")
|
|
2200
|
+
body = importedNode;
|
|
2201
|
+
else
|
|
2202
|
+
body.appendChild(importedNode);
|
|
2203
|
+
_sanitizeAttachedShadowRoots(body);
|
|
2204
|
+
} else {
|
|
2205
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1)
|
|
2206
|
+
return _signOutput(dirty);
|
|
2207
|
+
body = _initDocument(dirty);
|
|
2208
|
+
if (!body)
|
|
2209
|
+
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
|
2210
|
+
}
|
|
2211
|
+
if (body && FORCE_BODY)
|
|
2212
|
+
_forceRemove(body.firstChild);
|
|
2213
|
+
const walkRoot = inPlace ? dirty : body;
|
|
2214
|
+
try {
|
|
2215
|
+
if (inPlace)
|
|
2216
|
+
_sanitizeAttachedShadowRoots(dirty);
|
|
2217
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
2218
|
+
while (currentNode = nodeIterator.nextNode())
|
|
2219
|
+
_sanitizeNode(currentNode, walkRoot);
|
|
2220
|
+
if (inPlace)
|
|
2221
|
+
_sanitizeUnvisitedNodes(dirty, inPlaceNodes);
|
|
2222
|
+
} catch (error) {
|
|
2223
|
+
if (inPlace)
|
|
2224
|
+
_failClosed(dirty, inPlaceNodes);
|
|
2225
|
+
throw error;
|
|
2226
|
+
} finally {
|
|
2227
|
+
IN_PLACE_VISITED = outerVisited;
|
|
2228
|
+
IN_PLACE_RETURNS = outerReturns;
|
|
2229
|
+
}
|
|
2230
|
+
if (inPlace) {
|
|
2231
|
+
if (_neutralizeDiscarded(dirty, inPlaceNodes))
|
|
2232
|
+
throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
|
|
2233
|
+
if (SAFE_FOR_TEMPLATES)
|
|
2234
|
+
_scrubTemplateExpressions2(dirty);
|
|
2235
|
+
return dirty;
|
|
2236
|
+
}
|
|
2237
|
+
if (RETURN_DOM) {
|
|
2238
|
+
if (SAFE_FOR_TEMPLATES)
|
|
2239
|
+
_scrubTemplateExpressions2(body);
|
|
2240
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
2241
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
2242
|
+
while (body.firstChild)
|
|
2243
|
+
returnNode.appendChild(body.firstChild);
|
|
2244
|
+
} else
|
|
2245
|
+
returnNode = body;
|
|
2246
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode)
|
|
2247
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
2248
|
+
return returnNode;
|
|
2249
|
+
}
|
|
2250
|
+
if (SAFE_FOR_TEMPLATES)
|
|
2251
|
+
_scrubOwnCharacterData(body);
|
|
2252
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
2253
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name))
|
|
2254
|
+
serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + `>
|
|
2255
|
+
` + serializedHTML;
|
|
2256
|
+
return _signOutput(serializedHTML);
|
|
2257
|
+
};
|
|
2258
|
+
DOMPurify.sanitize = function(dirty) {
|
|
2259
|
+
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2260
|
+
const outerConfig = ACTIVE_CONFIG;
|
|
2261
|
+
const outerTags = ALLOWED_TAGS;
|
|
2262
|
+
const outerAttr = ALLOWED_ATTR;
|
|
2263
|
+
const outerRemoved = DOMPurify.removed;
|
|
2264
|
+
ACTIVE_CONFIG = null;
|
|
2265
|
+
try {
|
|
2266
|
+
return _sanitize(dirty, cfg);
|
|
2267
|
+
} finally {
|
|
2268
|
+
ACTIVE_CONFIG = outerConfig;
|
|
2269
|
+
if (outerConfig) {
|
|
2270
|
+
if (!SET_CONFIG)
|
|
2271
|
+
_parseConfig(outerConfig);
|
|
2272
|
+
ALLOWED_TAGS = outerTags;
|
|
2273
|
+
ALLOWED_ATTR = outerAttr;
|
|
2274
|
+
DOMPurify.removed = outerRemoved;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
DOMPurify.setConfig = function() {
|
|
2279
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2280
|
+
_parseConfig(cfg);
|
|
2281
|
+
SET_CONFIG = true;
|
|
2282
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
2283
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
2284
|
+
};
|
|
2285
|
+
DOMPurify.clearConfig = function() {
|
|
2286
|
+
CONFIG = null;
|
|
2287
|
+
SET_CONFIG = false;
|
|
2288
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
2289
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
2290
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
2291
|
+
emptyHTML = "";
|
|
2292
|
+
};
|
|
2293
|
+
DOMPurify.isValidAttribute = function(tag, attr, value) {
|
|
2294
|
+
if (!CONFIG)
|
|
2295
|
+
_parseConfig({});
|
|
2296
|
+
const lcTag = transformCaseFunc(tag);
|
|
2297
|
+
const lcName = transformCaseFunc(attr);
|
|
2298
|
+
if (typeof value === "string" && (_isUnsafeAttributeValue(attr, value) || !ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)))
|
|
2299
|
+
return false;
|
|
2300
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
2301
|
+
};
|
|
2302
|
+
DOMPurify.addHook = function(entryPoint, hookFunction) {
|
|
2303
|
+
if (typeof hookFunction !== "function")
|
|
2304
|
+
return;
|
|
2305
|
+
if (!objectHasOwnProperty(hooks, entryPoint))
|
|
2306
|
+
return;
|
|
2307
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
2308
|
+
};
|
|
2309
|
+
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
2310
|
+
if (!objectHasOwnProperty(hooks, entryPoint))
|
|
2311
|
+
return;
|
|
2312
|
+
if (hookFunction !== undefined) {
|
|
2313
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
2314
|
+
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
2315
|
+
}
|
|
2316
|
+
return arrayPop(hooks[entryPoint]);
|
|
2317
|
+
};
|
|
2318
|
+
DOMPurify.removeHooks = function(entryPoint) {
|
|
2319
|
+
if (!objectHasOwnProperty(hooks, entryPoint))
|
|
2320
|
+
return;
|
|
2321
|
+
hooks[entryPoint] = [];
|
|
2322
|
+
};
|
|
2323
|
+
DOMPurify.removeAllHooks = function() {
|
|
2324
|
+
hooks = _createHooksMap();
|
|
2325
|
+
};
|
|
2326
|
+
return DOMPurify;
|
|
2327
|
+
}
|
|
2328
|
+
var purify_default = createDOMPurify();
|
|
2329
|
+
|
|
2330
|
+
// ../../node_modules/.pnpm/marked@18.4.0/node_modules/marked/lib/marked.esm.js
|
|
2331
|
+
function G() {
|
|
2332
|
+
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
2333
|
+
}
|
|
2334
|
+
var $ = G();
|
|
2335
|
+
function ge(l) {
|
|
2336
|
+
$ = l;
|
|
2337
|
+
}
|
|
2338
|
+
var N = { exec: () => null };
|
|
2339
|
+
function j(l) {
|
|
2340
|
+
let e = [];
|
|
2341
|
+
return (t) => {
|
|
2342
|
+
let n = Math.max(0, Math.min(3, t - 1)), r = e[n];
|
|
2343
|
+
return r || (r = l(n), e[n] = r), r;
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2346
|
+
function h(l, e = "") {
|
|
2347
|
+
let t = typeof l == "string" ? l : l.source, n = { replace: (r, s) => {
|
|
2348
|
+
let o = typeof s == "string" ? s : s.source;
|
|
2349
|
+
return o = o.replace(b.caret, "$1"), t = t.replace(r, o), n;
|
|
2350
|
+
}, getRegex: () => new RegExp(t, e) };
|
|
2351
|
+
return n;
|
|
2352
|
+
}
|
|
2353
|
+
var ze = ((l = "") => {
|
|
2354
|
+
try {
|
|
2355
|
+
return !!new RegExp("(?<=1)(?<!1)" + l);
|
|
2356
|
+
} catch {
|
|
2357
|
+
return false;
|
|
2358
|
+
}
|
|
2359
|
+
})();
|
|
2360
|
+
var Me = "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)";
|
|
2361
|
+
var b = { codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm, listInterruptsParagraph: /^ {0,3}(?:[*+-]|0{0,8}1[.)])[ \t]+[^ \t\n]/, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^( {1,3})(?:`{3}|~{3})/, beginningSpace: /^[ \t]{1,3}/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, leadingSpaceTab: /^[ \t]+/, multipleSpaceGlobal: /\s+/g, multipleSpaceTabGlobal: /[ \t\r\n]+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, textIndentedContinuation: /^(?:\n(?: {4}| {0,3}\t)[ \t]*[^ \t\n][^\n]*)+/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, blockquoteMarkerWhitespace: /^( {0,3}>)(\t[ \t]*)/gm, blockquoteFenceOpen: /^ {0,3}(`{3,}(?=[^`]*$)|~{3,})/, blockquoteFenceClose: /^ {0,3}(`{3,}|~{3,})[ \t]*$/, blockquoteListItemStart: /^ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|$)/, nestedBlockMarker: /^ {0,3}(?:(?:[*+-]|\d{1,9}[.)])(?: |$)|> ?)/, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\][ \t]+\S/, listReplaceTask: /^\[[ xX]\][ \t]+/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableHeader: new RegExp(Me + "(?:\\n|$)"), tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/, numericCharacterReferenceOrAmpersand: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l) => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: j((l) => new RegExp(`^ {0,${l}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: j((l) => new RegExp(`^ {0,${l}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)), fencesBeginRegex: j((l) => new RegExp(`^ {0,${l}}(?:\`{3,}(?=[^\`\\n]*(?:\\n|$))|~~~)`)), headingBeginRegex: j((l) => new RegExp(`^ {0,${l}}#{1,6}(?:\\s|$)`)), pedanticHeadingBeginRegex: j((l) => new RegExp(`^ {0,${l}}#`)), htmlBeginRegex: j((l) => new RegExp(`^ {0,${l}}(?:</?(?:${me})(?:[ \\t]+|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, "i")), blockquoteBeginRegex: j((l) => new RegExp(`^ {0,${l}}>`)), nestedContainerMarkers: /^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/ };
|
|
2362
|
+
var Ye = /^(?:[ \t]*(?:\n|$))+/;
|
|
2363
|
+
var et = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
2364
|
+
var tt = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*)[ \t]*(?=\n|$)|$)/;
|
|
2365
|
+
var ee = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
2366
|
+
var nt = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
2367
|
+
var fe = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
2368
|
+
var me = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
2369
|
+
var te = h(" {0,3}(?:</?(?:tag)(?:[ \\t]+|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", me).getRegex();
|
|
2370
|
+
var Be = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?![ \t]*\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/;
|
|
2371
|
+
var De = h(Be).replace(/bull/g, fe).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}(?=[^`\n]*(?:\n|$))|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/\|table/g, "").replace(/html/g, te).getRegex();
|
|
2372
|
+
var rt = h(Be).replace(/bull/g, fe).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}(?=[^`\n]*(?:\n|$))|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).replace(/html/g, te).getRegex();
|
|
2373
|
+
var xe = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
2374
|
+
var st = /^[^\n]+/;
|
|
2375
|
+
var be = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/;
|
|
2376
|
+
var it = h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<(?:\\.|[^\n<>\\])*>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", be).replace("title", /(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex();
|
|
2377
|
+
var ot = h(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, fe).getRegex();
|
|
2378
|
+
var Re = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
2379
|
+
var at = h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*?[ \\t]*/?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))", "i").replace("comment", Re).replace("tag", me).replace("attribute", /[ \t]+[a-zA-Z:_][\w.:-]*(?:[ \t]*=[ \t]*"[^"\n]*"|[ \t]*=[ \t]*'[^'\n]*'|[ \t]*=[ \t]*[^\s"'=<>`]+)?/).getRegex();
|
|
2380
|
+
var qe = (l) => h(xe).replace("hr", ee).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", l).replace("html", te).getRegex();
|
|
2381
|
+
var lt = qe(b.listInterruptsParagraph);
|
|
2382
|
+
var ut = qe(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
2383
|
+
var Le = / {0,3}> ?(?:(?!blank)(paragraph)|[^\n]*)(?:\n|$)/;
|
|
2384
|
+
var pt = h(/^(first)(?:next)*/).replace("first", h(Le).replace("blank", /[ \t]*(?:\n|$)| {4}/).getRegex()).replace("next", h(Le).replace("blank", /[ \t]*(?:\n|$)/).getRegex()).replace(/paragraph/g, ut).getRegex();
|
|
2385
|
+
var Oe = { blockquote: pt, code: et, def: it, fences: tt, heading: nt, hr: ee, html: at, lheading: De, list: ot, newline: Ye, paragraph: lt, table: N, text: st };
|
|
2386
|
+
var ct = h(Me + "(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", ee).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}\t)[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|0{0,8}1[.)])[ \\t]").replace("html", te).getRegex();
|
|
2387
|
+
var ht = { ...Oe, lheading: rt, table: ct, paragraph: h(xe).replace("hr", ee).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", b.tableHeader).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", b.listInterruptsParagraph).replace("html", te).getRegex() };
|
|
2388
|
+
var dt = { ...Oe, html: h(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace("comment", Re).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: N, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: h(xe).replace("hr", ee).replace("heading", ` *#{1,6} *[^
|
|
2389
|
+
]`).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").replace("lheading", De).getRegex() };
|
|
2390
|
+
var gt = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
2391
|
+
var kt = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
2392
|
+
var He = /^( {2,}|\\)\n(?!\s*$)[ \t]*/;
|
|
2393
|
+
var ft = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
2394
|
+
var E = /[\p{P}\p{S}]/u;
|
|
2395
|
+
var Q = /[\s\p{P}\p{S}]/u;
|
|
2396
|
+
var ne = /[^\s\p{P}\p{S}]/u;
|
|
2397
|
+
var mt = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Q).getRegex();
|
|
2398
|
+
var xt = /[\p{Pi}\p{Ps}"']/u;
|
|
2399
|
+
var ve = /(?!~)[\p{P}\p{S}]/u;
|
|
2400
|
+
var bt = /(?!~)[\s\p{P}\p{S}]/u;
|
|
2401
|
+
var Rt = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
2402
|
+
var Ot = h(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", ze ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
2403
|
+
var Ze = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
2404
|
+
var Tt = h(Ze, "u").replace(/punct/g, E).getRegex();
|
|
2405
|
+
var wt = h(Ze, "u").replace(/punct/g, ve).getRegex();
|
|
2406
|
+
var Pt = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
2407
|
+
var yt = h(Pt, "u").replace(/openQuote/g, xt).replace(/punct/g, E).getRegex();
|
|
2408
|
+
var je = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
2409
|
+
var St = h(je, "gu").replace(/notPunctSpace/g, ne).replace(/punctSpace/g, Q).replace(/punct/g, E).getRegex();
|
|
2410
|
+
var _t = h(je, "gu").replace(/notPunctSpace/g, Rt).replace(/punctSpace/g, bt).replace(/punct/g, ve).getRegex();
|
|
2411
|
+
var $t = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
2412
|
+
var Ct = h($t, "gu").replace(/notPunctSpace/g, ne).replace(/punctSpace/g, Q).replace(/punct/g, E).getRegex();
|
|
2413
|
+
var It = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ne).replace(/punctSpace/g, Q).replace(/punct/g, E).getRegex();
|
|
2414
|
+
var Lt = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
|
|
2415
|
+
var At = h(Lt, "gu").replace(/notPunctSpace/g, ne).replace(/punctSpace/g, Q).replace(/punct/g, E).getRegex();
|
|
2416
|
+
var Et = h(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, E).getRegex();
|
|
2417
|
+
var zt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
2418
|
+
var Mt = h(zt, "gu").replace(/notPunctSpace/g, ne).replace(/punctSpace/g, Q).replace(/punct/g, E).getRegex();
|
|
2419
|
+
var Bt = h(/\\(punct)/, "gu").replace(/punct/g, E).getRegex();
|
|
2420
|
+
var Dt = h(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/, "gu").replace(/punct/g, E).getRegex();
|
|
2421
|
+
var qt = h(/^<(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();
|
|
2422
|
+
var Ht = h(Re).replace("(?:-->|$)", "-->").getRegex();
|
|
2423
|
+
var vt = h("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Ht).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
2424
|
+
var Ne = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
|
|
2425
|
+
var le = h(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", Ne).getRegex();
|
|
2426
|
+
var ue = /\\[^ \t\n\x00-\x1f]|\\(?=[ \t\n])|[^ \t\n\x00-\x1f\\()]/;
|
|
2427
|
+
var Zt = h(/\((?:char)*\)/).replace("char", ue).getRegex();
|
|
2428
|
+
var jt = h(/\((?:char|p1)*\)/).replace("char", ue).replace("p1", Zt).getRegex();
|
|
2429
|
+
var Nt = h(/\((?:char|p2)*\)/).replace("char", ue).replace("p2", jt).getRegex();
|
|
2430
|
+
var Ft = h(/(?!<)(?:char|p3)+/).replace("char", ue).replace("p3", Nt).getRegex();
|
|
2431
|
+
var Gt = h(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", le).replace("href", h(/<(?:\\.|[^\n<>\\])*>|bareHref|(?=\))/).replace("bareHref", Ft).getRegex()).replace("title", /"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex();
|
|
2432
|
+
var Qt = h(/^!?\[(label)\]\[(ref)\]/).replace("label", le).replace("ref", be).getRegex();
|
|
2433
|
+
var Wt = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", be).getRegex();
|
|
2434
|
+
var Ae = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/;
|
|
2435
|
+
var Ut = h(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", Ne).getRegex();
|
|
2436
|
+
var Kt = h("reflink|nolink(?!\\()", "g").replace("reflink", h(/^!?\[(label)\]\[(ref)\]/).replace("label", Ut).replace("ref", Ae).getRegex()).replace("nolink", h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Ae).getRegex()).getRegex();
|
|
2437
|
+
var Ee = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
2438
|
+
var Xt = /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/;
|
|
2439
|
+
var Vt = h(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, Xt).getRegex();
|
|
2440
|
+
var Te = { _backpedal: N, anyPunctuation: Bt, anyPunctuationOutsideCode: Dt, autolink: qt, blockSkip: Ot, br: He, code: kt, del: N, delLDelim: N, delRDelim: N, emStrongLDelim: Tt, emStrongRDelimAst: St, emStrongRDelimUnd: It, escape: gt, link: Gt, nolink: Wt, punctuation: mt, reflink: Qt, reflinkSearch: Kt, tag: vt, text: ft, url: N };
|
|
2441
|
+
var Jt = { ...Te, emStrongLDelim: yt, emStrongRDelimAst: Ct, emStrongRDelimUnd: At, link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", le).getRegex(), reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", le).getRegex() };
|
|
2442
|
+
var ke = { ...Te, emStrongRDelimAst: _t, emStrongLDelim: wt, delLDelim: Et, delRDelim: Mt, url: h(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", Vt).replace("protocol", Ee).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: h(/^(?:[A-Za-z0-9.+-]+(?=@)|[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", Ee).replace(/emailProtocol/g, /(?:mailto|xmpp):/).replace("wwwStart", ze ? "(?<![^\\s*_~(])www\\." : "www\\.").getRegex() };
|
|
2443
|
+
var Yt = { ...ke, br: h(He).replace("{2,}", "*").getRegex(), text: h(ke.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
2444
|
+
var re = { normal: Oe, gfm: ht, pedantic: dt };
|
|
2445
|
+
var W = { normal: Te, gfm: ke, breaks: Yt, pedantic: Jt };
|
|
2446
|
+
var en = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
2447
|
+
var Fe = (l) => en[l];
|
|
2448
|
+
function P(l, e) {
|
|
2449
|
+
if (e) {
|
|
2450
|
+
if (b.escapeTest.test(l))
|
|
2451
|
+
return l.replace(b.escapeReplace, Fe);
|
|
2452
|
+
} else if (b.escapeTestNoEncode.test(l))
|
|
2453
|
+
return l.replace(b.escapeReplaceNoEncode, Fe);
|
|
2454
|
+
return l;
|
|
2455
|
+
}
|
|
2456
|
+
function Qe(l) {
|
|
2457
|
+
return b.numericCharacterReference.test(l) ? l.replace(b.numericCharacterReferenceOrAmpersand, (e, t, n) => {
|
|
2458
|
+
if (t === undefined && n === undefined)
|
|
2459
|
+
return "&";
|
|
2460
|
+
let r = t === undefined ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
|
|
2461
|
+
return r === 0 || r > 1114111 || r >= 55296 && r <= 57343 ? "�" : r === 38 ? "&" : String.fromCodePoint(r);
|
|
2462
|
+
}) : l;
|
|
2463
|
+
}
|
|
2464
|
+
function we(l) {
|
|
2465
|
+
try {
|
|
2466
|
+
l = encodeURI(l).replace(b.percentDecode, "%");
|
|
2467
|
+
} catch {
|
|
2468
|
+
return null;
|
|
2469
|
+
}
|
|
2470
|
+
return l;
|
|
2471
|
+
}
|
|
2472
|
+
function pe(l, e) {
|
|
2473
|
+
let t = l.replace(b.findPipe, (s, o, i) => {
|
|
2474
|
+
let a = false, p = o;
|
|
2475
|
+
for (;--p >= 0 && i[p] === "\\"; )
|
|
2476
|
+
a = !a;
|
|
2477
|
+
return a ? "|" : " |";
|
|
2478
|
+
}), n = t.split(b.splitPipe), r = 0;
|
|
2479
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
|
|
2480
|
+
if (n.length > e)
|
|
2481
|
+
n.splice(e);
|
|
2482
|
+
else
|
|
2483
|
+
for (;n.length < e; )
|
|
2484
|
+
n.push("");
|
|
2485
|
+
for (;r < n.length; r++)
|
|
2486
|
+
n[r] = n[r].trim().replace(b.slashPipe, "|");
|
|
2487
|
+
return n;
|
|
2488
|
+
}
|
|
2489
|
+
function z(l, e, t) {
|
|
2490
|
+
let n = l.length;
|
|
2491
|
+
if (n === 0)
|
|
2492
|
+
return "";
|
|
2493
|
+
let r = 0;
|
|
2494
|
+
for (;r < n; ) {
|
|
2495
|
+
let s = l.charAt(n - r - 1);
|
|
2496
|
+
if (s === e && !t)
|
|
2497
|
+
r++;
|
|
2498
|
+
else if (s !== e && t)
|
|
2499
|
+
r++;
|
|
2500
|
+
else
|
|
2501
|
+
break;
|
|
2502
|
+
}
|
|
2503
|
+
return l.slice(0, n - r);
|
|
2504
|
+
}
|
|
2505
|
+
function Pe(l) {
|
|
2506
|
+
let e = l.split(`
|
|
2507
|
+
`), t = e.length - 1;
|
|
2508
|
+
for (;t >= 0 && b.blankLine.test(e[t]); )
|
|
2509
|
+
t--;
|
|
2510
|
+
return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
|
|
2511
|
+
`);
|
|
2512
|
+
}
|
|
2513
|
+
function K(l, e = false) {
|
|
2514
|
+
let t = e ? b.multipleSpaceGlobal : b.multipleSpaceTabGlobal;
|
|
2515
|
+
return l.trim().replace(t, " ").toLowerCase().toUpperCase().toLowerCase();
|
|
2516
|
+
}
|
|
2517
|
+
function ye(l, e) {
|
|
2518
|
+
if (l.indexOf(e[0]) === -1 && l.indexOf(e[1]) === -1)
|
|
2519
|
+
return -1;
|
|
2520
|
+
let t = 0;
|
|
2521
|
+
for (let n = 0;n < l.length; n++)
|
|
2522
|
+
if (l[n] === "\\")
|
|
2523
|
+
n++;
|
|
2524
|
+
else if (l[n] === e[0])
|
|
2525
|
+
t++;
|
|
2526
|
+
else if (l[n] === e[1] && (t--, t < 0))
|
|
2527
|
+
return n;
|
|
2528
|
+
return t > 0 ? -2 : -1;
|
|
2529
|
+
}
|
|
2530
|
+
var U = new WeakMap;
|
|
2531
|
+
function Se(l) {
|
|
2532
|
+
let e = { "*": -1, _: -1 }, t = -1, n = l.length;
|
|
2533
|
+
for (let r = 0;r < n; r++) {
|
|
2534
|
+
let s = l[r];
|
|
2535
|
+
if (s !== "*" && s !== "_" && s !== "~")
|
|
2536
|
+
continue;
|
|
2537
|
+
let o = r === 0 ? `
|
|
2538
|
+
` : l[r - 1], i = r + 1;
|
|
2539
|
+
for (;i < n && l[i] === s; )
|
|
2540
|
+
i++;
|
|
2541
|
+
o !== " " && o !== "\t" && o !== `
|
|
2542
|
+
` && o !== "\r" && o !== "\f" && (s === "~" ? t = r : e[s] = r), r = i - 1;
|
|
2543
|
+
}
|
|
2544
|
+
return { maskedSrc: l, lastPossibleEmStrongCloserIndex: e, lastPossibleDelCloserIndex: t };
|
|
2545
|
+
}
|
|
2546
|
+
function We(l, e) {
|
|
2547
|
+
let t = Se(e), n = U.get(l);
|
|
2548
|
+
n ? n.push(t) : U.set(l, [t]);
|
|
2549
|
+
}
|
|
2550
|
+
function Ue(l) {
|
|
2551
|
+
let e = U.get(l);
|
|
2552
|
+
e && (e.pop(), e.length === 0 && U.delete(l));
|
|
2553
|
+
}
|
|
2554
|
+
function ce(l, e, t) {
|
|
2555
|
+
let n = U.get(l)?.at(-1);
|
|
2556
|
+
return n && n.maskedSrc === e ? n.lastPossibleEmStrongCloserIndex[t] : Se(e).lastPossibleEmStrongCloserIndex[t];
|
|
2557
|
+
}
|
|
2558
|
+
function he(l, e) {
|
|
2559
|
+
let t = U.get(l)?.at(-1);
|
|
2560
|
+
return t && t.maskedSrc === e ? t.lastPossibleDelCloserIndex : Se(e).lastPossibleDelCloserIndex;
|
|
2561
|
+
}
|
|
2562
|
+
function X(l, e = 0) {
|
|
2563
|
+
let t = e, n = "";
|
|
2564
|
+
for (let r of l)
|
|
2565
|
+
if (r === "\t") {
|
|
2566
|
+
let s = 4 - t % 4;
|
|
2567
|
+
n += " ".repeat(s), t += s;
|
|
2568
|
+
} else
|
|
2569
|
+
n += r, t++;
|
|
2570
|
+
return n;
|
|
2571
|
+
}
|
|
2572
|
+
function Ke(l) {
|
|
2573
|
+
let e, t = false;
|
|
2574
|
+
return l.map((n) => {
|
|
2575
|
+
if (t)
|
|
2576
|
+
return n;
|
|
2577
|
+
let { depth: r, expanded: s, keptIndent: o, content: i } = tn(n, e?.depth ?? 1 / 0);
|
|
2578
|
+
if (e?.depth !== r && (e = undefined), e) {
|
|
2579
|
+
let p = b.blockquoteFenceClose.exec(i)?.[1];
|
|
2580
|
+
return !p || p[0] !== e.marker[0] || p.length < e.marker.length ? o : (e = undefined, s);
|
|
2581
|
+
}
|
|
2582
|
+
if (t = b.blockquoteListItemStart.test(i), t)
|
|
2583
|
+
return n;
|
|
2584
|
+
let a = b.blockquoteFenceOpen.exec(i)?.[1];
|
|
2585
|
+
return a && (e = { marker: a, depth: r }), s;
|
|
2586
|
+
}).join(`
|
|
2587
|
+
`);
|
|
2588
|
+
}
|
|
2589
|
+
function tn(l, e) {
|
|
2590
|
+
let t = 0, n = 0, r = 0, s = 0, o = "";
|
|
2591
|
+
for (;r < e; ) {
|
|
2592
|
+
let u = t, d = n;
|
|
2593
|
+
for (;l[u] === " " || l[u] === "\t"; )
|
|
2594
|
+
d += Ge(l[u], d), u++;
|
|
2595
|
+
if (l[u] !== ">" || d - s > 3)
|
|
2596
|
+
break;
|
|
2597
|
+
o += " ".repeat(d - n) + ">", r++, t = u + 1, n = d + 1, s = l[t] === " " || l[t] === "\t" ? n + 1 : n;
|
|
2598
|
+
}
|
|
2599
|
+
if (r === 0)
|
|
2600
|
+
return { depth: r, expanded: l, keptIndent: l, content: l };
|
|
2601
|
+
let i = "", a = "";
|
|
2602
|
+
for (;(l[t] === " " || l[t] === "\t") && n < s + 4; ) {
|
|
2603
|
+
let u = Ge(l[t], n);
|
|
2604
|
+
i += " ".repeat(u), a += n < s && u > 1 ? " ".repeat(u) : l[t], n += u, t++;
|
|
2605
|
+
}
|
|
2606
|
+
let p = l.slice(t);
|
|
2607
|
+
return { depth: r, expanded: o + i + p, keptIndent: o + a + p, content: " ".repeat(Math.max(0, n - s)) + p };
|
|
2608
|
+
}
|
|
2609
|
+
function Ge(l, e) {
|
|
2610
|
+
return l === "\t" ? 4 - e % 4 : 1;
|
|
2611
|
+
}
|
|
2612
|
+
function nn(l, e) {
|
|
2613
|
+
let t = "";
|
|
2614
|
+
for (let n = 0;n < l.length; n++) {
|
|
2615
|
+
if (l[n] === "`") {
|
|
2616
|
+
let r = e.inline.code.exec(l.slice(n));
|
|
2617
|
+
if (r) {
|
|
2618
|
+
t += r[0], n += r[0].length - 1;
|
|
2619
|
+
continue;
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
if (l[n] === "\\" && (l[n + 1] === "[" || l[n + 1] === "]")) {
|
|
2623
|
+
t += l[n + 1], n++;
|
|
2624
|
+
continue;
|
|
2625
|
+
}
|
|
2626
|
+
t += l[n];
|
|
2627
|
+
}
|
|
2628
|
+
return t;
|
|
2629
|
+
}
|
|
2630
|
+
function Xe(l, e, t, n, r) {
|
|
2631
|
+
let s = e.href, o = e.title || null, i = nn(l[1], r), a = l[0].charAt(0) === "!", p = n.state.inLink, u = n.state.linkEmitted, d = n.state.inRawBlock;
|
|
2632
|
+
n.state.inLink = true, n.state.linkEmitted = false;
|
|
2633
|
+
let k = n.inlineTokens(i), g = n.state.linkEmitted;
|
|
2634
|
+
if (n.state.linkEmitted = u, n.state.inLink = p, !a) {
|
|
2635
|
+
if (g) {
|
|
2636
|
+
n.state.inRawBlock = d;
|
|
2637
|
+
return;
|
|
2638
|
+
}
|
|
2639
|
+
n.state.linkEmitted = true;
|
|
2640
|
+
}
|
|
2641
|
+
return { type: a ? "image" : "link", raw: t, href: s, title: o, text: i, tokens: k };
|
|
2642
|
+
}
|
|
2643
|
+
function rn(l, e, t, n) {
|
|
2644
|
+
let r = l.match(t.other.indentCodeCompensation);
|
|
2645
|
+
if (r === null)
|
|
2646
|
+
return e;
|
|
2647
|
+
let s = r[1].length;
|
|
2648
|
+
return e.split(`
|
|
2649
|
+
`).map((o) => {
|
|
2650
|
+
let i = o.match(t.other.beginningSpace);
|
|
2651
|
+
if (i === null)
|
|
2652
|
+
return o;
|
|
2653
|
+
let [a] = i, p = a.indexOf("\t");
|
|
2654
|
+
if (p !== -1 && p < s) {
|
|
2655
|
+
if (n)
|
|
2656
|
+
return " ".repeat(4 - s) + o.slice(p + 1);
|
|
2657
|
+
if (l[s] === "~")
|
|
2658
|
+
return o;
|
|
2659
|
+
}
|
|
2660
|
+
return o.slice(Math.min(a.length, s));
|
|
2661
|
+
}).join(`
|
|
2662
|
+
`);
|
|
2663
|
+
}
|
|
2664
|
+
function Ve(l, e, t, n) {
|
|
2665
|
+
if (!e.includes("<"))
|
|
2666
|
+
return false;
|
|
2667
|
+
for (let r = 0;r < e.length; r++) {
|
|
2668
|
+
if (e[r] === "\\") {
|
|
2669
|
+
r++;
|
|
2670
|
+
continue;
|
|
2671
|
+
}
|
|
2672
|
+
if (e[r] === "`") {
|
|
2673
|
+
let i = n.inline.code.exec(e.slice(r));
|
|
2674
|
+
if (i) {
|
|
2675
|
+
r += i[0].length - 1;
|
|
2676
|
+
continue;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
if (e[r] !== "<")
|
|
2680
|
+
continue;
|
|
2681
|
+
let s = l.slice(t + r), o = n.inline.tag.exec(s) || n.inline.autolink.exec(s);
|
|
2682
|
+
if (o) {
|
|
2683
|
+
if (o[0].length > e.length - r)
|
|
2684
|
+
return true;
|
|
2685
|
+
r += o[0].length - 1;
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
return false;
|
|
2689
|
+
}
|
|
2690
|
+
var C = class {
|
|
2691
|
+
options;
|
|
2692
|
+
rules;
|
|
2693
|
+
lexer;
|
|
2694
|
+
constructor(e) {
|
|
2695
|
+
this.options = e || $;
|
|
2696
|
+
}
|
|
2697
|
+
space(e) {
|
|
2698
|
+
let t = this.rules.block.newline.exec(e);
|
|
2699
|
+
if (t && t[0].length > 0)
|
|
2700
|
+
return { type: "space", raw: t[0] };
|
|
2701
|
+
}
|
|
2702
|
+
code(e) {
|
|
2703
|
+
let t = this.rules.block.code.exec(e);
|
|
2704
|
+
if (t) {
|
|
2705
|
+
let n = this.options.pedantic ? t[0] : Pe(t[0]), r = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
2706
|
+
return { type: "code", raw: n, codeBlockStyle: "indented", text: r };
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
fences(e) {
|
|
2710
|
+
let t = this.rules.block.fences.exec(e);
|
|
2711
|
+
if (t) {
|
|
2712
|
+
let n = t[0], r = rn(n, t[3] || "", this.rules, this.lexer.state.top && !this.lexer.state.inBlockquote);
|
|
2713
|
+
t[3] !== undefined && (r === "" || r.endsWith(`
|
|
2714
|
+
`)) && (r += `
|
|
2715
|
+
`);
|
|
2716
|
+
let s = t[2];
|
|
2717
|
+
if (s) {
|
|
2718
|
+
let o = 0, i = s.length;
|
|
2719
|
+
for (;o < i && (s[o] === " " || s[o] === "\t"); )
|
|
2720
|
+
o++;
|
|
2721
|
+
for (;i > o && (s[i - 1] === " " || s[i - 1] === "\t"); )
|
|
2722
|
+
i--;
|
|
2723
|
+
s = s.slice(o, i).replace(this.rules.inline.anyPunctuation, "$1");
|
|
2724
|
+
}
|
|
2725
|
+
return { type: "code", raw: n, lang: s, text: r };
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
heading(e) {
|
|
2729
|
+
let t = this.rules.block.heading.exec(e);
|
|
2730
|
+
if (t) {
|
|
2731
|
+
let n = t[2].trim();
|
|
2732
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
2733
|
+
let r = z(n, "#");
|
|
2734
|
+
(this.options.pedantic || !r || this.rules.other.endingSpaceTabChar.test(r)) && (n = r.trim());
|
|
2735
|
+
}
|
|
2736
|
+
return { type: "heading", raw: z(t[0], `
|
|
2737
|
+
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
hr(e) {
|
|
2741
|
+
let t = this.rules.block.hr.exec(e);
|
|
2742
|
+
if (t)
|
|
2743
|
+
return { type: "hr", raw: z(t[0], `
|
|
2744
|
+
`) };
|
|
2745
|
+
}
|
|
2746
|
+
blockquote(e) {
|
|
2747
|
+
let t = this.rules.block.blockquote.exec(e);
|
|
2748
|
+
if (t) {
|
|
2749
|
+
let n = z(t[0], `
|
|
2750
|
+
`).split(`
|
|
2751
|
+
`), r = "", s = "", o = [];
|
|
2752
|
+
for (;n.length > 0; ) {
|
|
2753
|
+
let i = false, a = [], p;
|
|
2754
|
+
for (p = 0;p < n.length; p++)
|
|
2755
|
+
if (this.rules.other.blockquoteStart.test(n[p]))
|
|
2756
|
+
a.push(n[p]), i = true;
|
|
2757
|
+
else if (!i)
|
|
2758
|
+
a.push(n[p]);
|
|
2759
|
+
else
|
|
2760
|
+
break;
|
|
2761
|
+
n = n.slice(p);
|
|
2762
|
+
let u = a.join(`
|
|
2763
|
+
`), k = (this.lexer.state.top && !this.lexer.state.inBlockquote && u.includes("\t") ? Ke(a) : u).replace(this.rules.other.blockquoteMarkerWhitespace, (w, f, m) => m.startsWith(" ") ? f + " " + m.slice(1) : f + X(m, f.length)).replace(this.rules.other.blockquoteSetextReplace, `
|
|
2764
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
2765
|
+
r = r ? `${r}
|
|
2766
|
+
${u}` : u, s = s ? `${s}
|
|
2767
|
+
${k}` : k;
|
|
2768
|
+
let g = this.lexer.state.top, c = this.lexer.state.inBlockquote, R = this.lexer.state.lastToken;
|
|
2769
|
+
if (this.lexer.state.top = true, this.lexer.state.inBlockquote = true, this.lexer.blockTokens(k, o, true), this.lexer.state.top = g, this.lexer.state.inBlockquote = c, n.length === 0)
|
|
2770
|
+
break;
|
|
2771
|
+
let x = o.at(-1);
|
|
2772
|
+
if (x?.type === "code" || x?.type === "heading" || x?.type === "hr" || x?.type === "html" || x?.type === "table")
|
|
2773
|
+
break;
|
|
2774
|
+
if (x?.type === "blockquote") {
|
|
2775
|
+
let w = x, f = n.join(`
|
|
2776
|
+
`), m = w.raw + `
|
|
2777
|
+
` + f.replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
2778
|
+
this.lexer.state.inBlockquote = true, this.lexer.state.lastToken = o.at(-2);
|
|
2779
|
+
let _ = this.blockquote(m);
|
|
2780
|
+
this.lexer.state.inBlockquote = c, this.lexer.state.lastToken = R, o[o.length - 1] = _;
|
|
2781
|
+
let T = m.substring(_.raw.length).replace(/^\n/, ""), H = T ? T.split(`
|
|
2782
|
+
`).length : 0, D = H ? n.slice(0, -H) : n;
|
|
2783
|
+
if (D.length > 0 && (r = `${r}
|
|
2784
|
+
${D.join(`
|
|
2785
|
+
`)}`), s = s.substring(0, s.length - w.text.length) + _.text, n = n.slice(D.length), n.length > 0 && this.rules.other.blockquoteStart.test(n[0]))
|
|
2786
|
+
continue;
|
|
2787
|
+
break;
|
|
2788
|
+
} else if (x?.type === "list") {
|
|
2789
|
+
let w = x, f = w.raw + `
|
|
2790
|
+
` + n.join(`
|
|
2791
|
+
`);
|
|
2792
|
+
this.lexer.state.inBlockquote = true, this.lexer.state.lastToken = o.at(-2);
|
|
2793
|
+
let m = this.list(f);
|
|
2794
|
+
this.lexer.state.top = g, this.lexer.state.inBlockquote = c, this.lexer.state.lastToken = R, o[o.length - 1] = m;
|
|
2795
|
+
let _ = m.raw.length > w.raw.length ? f.slice(w.raw.length + 1, m.raw.length).split(`
|
|
2796
|
+
`).length : 0;
|
|
2797
|
+
if (_ > 0) {
|
|
2798
|
+
let T = n.slice(0, _).join(`
|
|
2799
|
+
`);
|
|
2800
|
+
r = `${r}
|
|
2801
|
+
${T}`, s = `${s}
|
|
2802
|
+
${T}`;
|
|
2803
|
+
}
|
|
2804
|
+
if (n = n.slice(_), n.length > 0 && !this.rules.other.blockquoteStart.test(n[0]))
|
|
2805
|
+
break;
|
|
2806
|
+
continue;
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
return { type: "blockquote", raw: r, tokens: o, text: s };
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
list(e) {
|
|
2813
|
+
let t = this.rules.block.list.exec(e);
|
|
2814
|
+
if (t) {
|
|
2815
|
+
if (!this.options.pedantic && this.lexer.state.lastToken?.type === "text" && !this.rules.other.listInterruptsParagraph.test(e))
|
|
2816
|
+
return;
|
|
2817
|
+
let n = e, r = () => n.length - e.length, s = t[1].trim(), o = s.length > 1, i = { type: "list", raw: "", ordered: o, start: o ? +s.slice(0, -1) : "", loose: false, items: [] };
|
|
2818
|
+
s = o ? `\\d{1,9}\\${s.slice(-1)}` : `\\${s}`, this.options.pedantic && (s = o ? s : "[*+-]");
|
|
2819
|
+
let a = this.rules.other.listItemRegex(s), p = false;
|
|
2820
|
+
for (;e; ) {
|
|
2821
|
+
let g = false, c = "";
|
|
2822
|
+
if (!(t = a.exec(e)) || this.rules.block.hr.test(e))
|
|
2823
|
+
break;
|
|
2824
|
+
let R = r();
|
|
2825
|
+
e = e.substring(t[0].length);
|
|
2826
|
+
let x = t[2].split(`
|
|
2827
|
+
`, 1)[0], w = t[1].length, f = this.options.pedantic ? X(x, w) : x.replace(this.rules.other.leadingSpaceTab, (D) => X(D, w)), m = e.split(`
|
|
2828
|
+
`, 1)[0], _ = !f.trim(), T = 0;
|
|
2829
|
+
if (this.options.pedantic ? (T = 2, c = f.trimStart()) : _ ? T = w + 1 : (T = f.search(this.rules.other.nonSpaceChar), T = T > 4 ? 1 : T, c = f.slice(T), f = c, T += w), _ && this.rules.other.blankLine.test(m) && (e = e.substring(m.length + 1), g = true), !g) {
|
|
2830
|
+
let D = this.rules.other.nextBulletRegex(T), V = this.rules.other.hrRegex(T), ie = this.rules.other.fencesBeginRegex(T), Z = this.options.pedantic ? this.rules.other.pedanticHeadingBeginRegex(T) : this.rules.other.headingBeginRegex(T), J = this.rules.other.htmlBeginRegex(T), oe = this.rules.other.blockquoteBeginRegex(T), ae = false;
|
|
2831
|
+
for (;e; ) {
|
|
2832
|
+
let $e = e.split(`
|
|
2833
|
+
`, 1)[0], L;
|
|
2834
|
+
if (m = $e, this.options.pedantic ? (m = m.replace(this.rules.other.listReplaceNesting, " "), L = m) : L = m.replace(this.rules.other.leadingSpaceTab, (I) => X(I)), ie.test(m) || Z.test(m) || J.test(m) || oe.test(m) || D.test(m) || V.test(m))
|
|
2835
|
+
break;
|
|
2836
|
+
if (L.search(this.rules.other.nonSpaceChar) >= T || !m.trim())
|
|
2837
|
+
c += `
|
|
2838
|
+
` + L.slice(T), ae = false;
|
|
2839
|
+
else {
|
|
2840
|
+
if (_)
|
|
2841
|
+
break;
|
|
2842
|
+
let I = f;
|
|
2843
|
+
if (!this.options.pedantic && !c.includes(`
|
|
2844
|
+
`) && !f.includes("\t")) {
|
|
2845
|
+
let A;
|
|
2846
|
+
for (;!V.test(I) && (A = this.rules.other.nestedBlockMarker.exec(I)); )
|
|
2847
|
+
I = I.slice(A[0].length);
|
|
2848
|
+
if (!I.trim())
|
|
2849
|
+
break;
|
|
2850
|
+
}
|
|
2851
|
+
if (I.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ie.test(I) || Z.test(I) || J.test(I) || V.test(I))
|
|
2852
|
+
break;
|
|
2853
|
+
if (!this.options.pedantic && !ae) {
|
|
2854
|
+
let A = f.replace(this.rules.other.nestedContainerMarkers, "");
|
|
2855
|
+
if (this.rules.block.fences.test(A) || this.rules.block.heading.test(A) || this.rules.block.hr.test(A))
|
|
2856
|
+
break;
|
|
2857
|
+
}
|
|
2858
|
+
let Ce = !this.options.pedantic && /^ {0,3}(?:=+|-+) *$/.test(m) && this.rules.block.lheading.test(`${f}
|
|
2859
|
+
${m}`) ? ` ${L.replace(/^ {0,3}/, "")}` : m, de = !this.options.pedantic && !ae && L.startsWith(" ") ? this.rules.block.list.exec(f) : null;
|
|
2860
|
+
if (de?.[2]) {
|
|
2861
|
+
let A = de[1].length, Ie = de[2].replace(this.rules.other.leadingSpaceTab, (Je) => X(Je, A)), Y = Ie.search(this.rules.other.nonSpaceChar);
|
|
2862
|
+
Y > 0 && Y <= 4 && !this.rules.other.nestedBlockMarker.test(Ie.slice(Y)) && L.search(this.rules.other.nonSpaceChar) >= A + Y && this.rules.other.listInterruptsParagraph.test(L.slice(A + Y)) && (Ce = ` ${L}`);
|
|
2863
|
+
}
|
|
2864
|
+
c += `
|
|
2865
|
+
` + Ce, ae = true;
|
|
2866
|
+
}
|
|
2867
|
+
_ = !m.trim(), e = e.substring($e.length + 1), f = L.slice(T);
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
let H = n.slice(R, r());
|
|
2871
|
+
i.loose || (p ? i.loose = true : this.rules.other.doubleBlankLine.test(H) && (p = true)), i.items.push({ type: "list_item", raw: H, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] });
|
|
2872
|
+
}
|
|
2873
|
+
let u = i.items.at(-1);
|
|
2874
|
+
if (u)
|
|
2875
|
+
u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
|
|
2876
|
+
else
|
|
2877
|
+
return;
|
|
2878
|
+
i.raw = n.slice(0, r()).trimEnd();
|
|
2879
|
+
let d = [], k = this.lexer.state.top;
|
|
2880
|
+
for (let g of i.items)
|
|
2881
|
+
if (this.lexer.state.top = false, d.push(this.lexer.inlineQueue.length), g.tokens = this.lexer.blockTokens(g.text, []), !i.loose) {
|
|
2882
|
+
let c = g.tokens.filter((x) => x.type === "space"), R = c.length > 0 && c.some((x) => this.rules.other.anyLine.test(x.raw));
|
|
2883
|
+
i.loose = R;
|
|
2884
|
+
}
|
|
2885
|
+
this.lexer.state.top = k;
|
|
2886
|
+
for (let g = 0;g < i.items.length; g++) {
|
|
2887
|
+
let c = i.items[g], R = c.tokens[0];
|
|
2888
|
+
if (c.task && (R?.type === "text" || R?.type === "paragraph")) {
|
|
2889
|
+
c.text = c.text.replace(this.rules.other.listReplaceTask, ""), R.raw = R.raw.replace(this.rules.other.listReplaceTask, ""), R.text = R.text.replace(this.rules.other.listReplaceTask, "");
|
|
2890
|
+
let x = this.lexer.inlineQueue;
|
|
2891
|
+
for (let f = d[g];f < x.length; f++)
|
|
2892
|
+
if (x[f].tokens === R.tokens) {
|
|
2893
|
+
x[f].src = x[f].src.replace(this.rules.other.listReplaceTask, "");
|
|
2894
|
+
break;
|
|
2895
|
+
}
|
|
2896
|
+
let w = this.rules.other.listTaskCheckbox.exec(c.raw);
|
|
2897
|
+
if (w) {
|
|
2898
|
+
let f = { type: "checkbox", raw: w[0] + " ", checked: w[0] !== "[ ]" };
|
|
2899
|
+
c.checked = f.checked, i.loose ? c.tokens[0] && ["paragraph", "text"].includes(c.tokens[0].type) && "tokens" in c.tokens[0] && c.tokens[0].tokens ? (c.tokens[0].raw = f.raw + c.tokens[0].raw, c.tokens[0].text = f.raw + c.tokens[0].text, c.tokens[0].tokens.unshift(f)) : c.tokens.unshift({ type: "paragraph", raw: f.raw, text: f.raw, tokens: [f] }) : c.tokens.unshift(f);
|
|
2900
|
+
}
|
|
2901
|
+
} else
|
|
2902
|
+
c.task && (c.task = false);
|
|
2903
|
+
}
|
|
2904
|
+
if (i.loose)
|
|
2905
|
+
for (let g of i.items) {
|
|
2906
|
+
g.loose = true;
|
|
2907
|
+
for (let c of g.tokens)
|
|
2908
|
+
c.type === "text" && (c.type = "paragraph");
|
|
2909
|
+
}
|
|
2910
|
+
return i;
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
html(e) {
|
|
2914
|
+
let t = this.rules.block.html.exec(e);
|
|
2915
|
+
if (t) {
|
|
2916
|
+
if (this.lexer.state.lastToken?.type === "paragraph" && !this.rules.other.htmlBeginRegex(4).test(e))
|
|
2917
|
+
return;
|
|
2918
|
+
let n = Pe(t[0]);
|
|
2919
|
+
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
def(e) {
|
|
2923
|
+
let t = this.rules.block.def.exec(e);
|
|
2924
|
+
if (t) {
|
|
2925
|
+
if (!this.rules.other.startAngleBracket.test(t[2]) && ye(t[2], "()") !== -1)
|
|
2926
|
+
return;
|
|
2927
|
+
let n = K(t[1], this.options.pedantic), r = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", s = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
2928
|
+
return { type: "def", tag: n, raw: z(t[0], `
|
|
2929
|
+
`), href: r, title: s };
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
table(e) {
|
|
2933
|
+
let t, n;
|
|
2934
|
+
if (this.options.gfm && !this.options.pedantic) {
|
|
2935
|
+
let i = this.rules.other.tableHeader.exec(e);
|
|
2936
|
+
if (!i || !this.rules.other.tableDelimiter.test(i[2]) || (t = pe(i[1]), n = i[2].replace(this.rules.other.tableAlignChars, "").split("|"), t.length !== n.length))
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
let r = this.rules.block.table.exec(e);
|
|
2940
|
+
if (!r || !this.rules.other.tableDelimiter.test(r[2]))
|
|
2941
|
+
return;
|
|
2942
|
+
t ??= pe(r[1]), n ??= r[2].replace(this.rules.other.tableAlignChars, "").split("|");
|
|
2943
|
+
let s = r[3]?.trim() ? r[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
2944
|
+
`) : [], o = { type: "table", raw: z(r[0], `
|
|
2945
|
+
`), header: [], align: [], rows: [] };
|
|
2946
|
+
if (t.length === n.length) {
|
|
2947
|
+
for (let i of n)
|
|
2948
|
+
this.rules.other.tableAlignRight.test(i) ? o.align.push("right") : this.rules.other.tableAlignCenter.test(i) ? o.align.push("center") : this.rules.other.tableAlignLeft.test(i) ? o.align.push("left") : o.align.push(null);
|
|
2949
|
+
for (let i = 0;i < t.length; i++)
|
|
2950
|
+
o.header.push({ text: t[i], tokens: this.lexer.inline(t[i]), header: true, align: o.align[i] });
|
|
2951
|
+
for (let i of s)
|
|
2952
|
+
o.rows.push(pe(i, o.header.length).map((a, p) => ({ text: a, tokens: this.lexer.inline(a), header: false, align: o.align[p] })));
|
|
2953
|
+
return o;
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
lheading(e) {
|
|
2957
|
+
let t = this.rules.block.lheading.exec(e);
|
|
2958
|
+
if (t) {
|
|
2959
|
+
let n = t[1].trim();
|
|
2960
|
+
return { type: "heading", raw: z(t[0], `
|
|
2961
|
+
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
paragraph(e) {
|
|
2965
|
+
let t = this.rules.block.paragraph.exec(e);
|
|
2966
|
+
if (t) {
|
|
2967
|
+
let n = t[1].charAt(t[1].length - 1) === `
|
|
2968
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
2969
|
+
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
text(e) {
|
|
2973
|
+
let t = this.rules.block.text.exec(e);
|
|
2974
|
+
if (t) {
|
|
2975
|
+
let n = t[0], r = t[0], s = this.rules.other.textIndentedContinuation.exec(e.slice(n.length));
|
|
2976
|
+
return s && (n += s[0], r += s[0].replace(this.rules.other.codeRemoveIndent, "")), { type: "text", raw: n, text: r, tokens: this.lexer.inline(r) };
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
escape(e) {
|
|
2980
|
+
if (e.charCodeAt(0) !== 92)
|
|
2981
|
+
return;
|
|
2982
|
+
let t = this.rules.inline.escape.exec(e);
|
|
2983
|
+
if (t)
|
|
2984
|
+
return { type: "escape", raw: t[0], text: t[1] };
|
|
2985
|
+
}
|
|
2986
|
+
tag(e) {
|
|
2987
|
+
if (e.charCodeAt(0) !== 60)
|
|
2988
|
+
return;
|
|
2989
|
+
let t = this.rules.inline.tag.exec(e);
|
|
2990
|
+
if (t)
|
|
2991
|
+
return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
|
|
2992
|
+
}
|
|
2993
|
+
link(e) {
|
|
2994
|
+
if (this.lexer.state.linkParenPossible === false)
|
|
2995
|
+
return;
|
|
2996
|
+
let t = e.charCodeAt(0);
|
|
2997
|
+
if (t !== 91 && t !== 33)
|
|
2998
|
+
return;
|
|
2999
|
+
let n = this.rules.inline.link.exec(e);
|
|
3000
|
+
if (n) {
|
|
3001
|
+
let r = n[0].charAt(0) === "!" ? 2 : 1;
|
|
3002
|
+
if (!this.options.pedantic && Ve(e, n[1], r, this.rules))
|
|
3003
|
+
return;
|
|
3004
|
+
let s = n[2].trim();
|
|
3005
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(s)) {
|
|
3006
|
+
if (!this.rules.other.endAngleBracket.test(s))
|
|
3007
|
+
return;
|
|
3008
|
+
let p = z(s.slice(0, -1), "\\");
|
|
3009
|
+
if ((s.length - p.length) % 2 === 0)
|
|
3010
|
+
return;
|
|
3011
|
+
} else {
|
|
3012
|
+
let p = ye(n[2], "()");
|
|
3013
|
+
if (p === -2)
|
|
3014
|
+
return;
|
|
3015
|
+
if (p > -1) {
|
|
3016
|
+
let d = (n[0].indexOf("!") === 0 ? 5 : 4) + n[1].length + p;
|
|
3017
|
+
n[2] = n[2].substring(0, p), n[0] = n[0].substring(0, d).trim(), n[3] = "";
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
let o = z(n[0].slice(0, -1), "\\");
|
|
3021
|
+
if ((n[0].length - o.length) % 2 === 0)
|
|
3022
|
+
return;
|
|
3023
|
+
let i = n[2], a = "";
|
|
3024
|
+
if (this.options.pedantic) {
|
|
3025
|
+
let p = this.rules.other.pedanticHrefTitle.exec(i);
|
|
3026
|
+
p && (i = p[1], a = p[3]);
|
|
3027
|
+
} else
|
|
3028
|
+
a = n[3] ? n[3].slice(1, -1) : "";
|
|
3029
|
+
return this.options.pedantic && (i = i.trim()), this.rules.other.startAngleBracket.test(i) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(s) ? i = i.slice(1) : i = i.slice(1, -1)), Xe(n, { href: i && i.replace(this.rules.inline.anyPunctuation, "$1"), title: a && a.replace(this.rules.inline.anyPunctuation, "$1") }, n[0], this.lexer, this.rules);
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
reflink(e, t) {
|
|
3033
|
+
let n = e.charCodeAt(0);
|
|
3034
|
+
if (n !== 91 && n !== 33)
|
|
3035
|
+
return;
|
|
3036
|
+
let r;
|
|
3037
|
+
if ((r = this.rules.inline.reflink.exec(e)) || (r = this.rules.inline.nolink.exec(e))) {
|
|
3038
|
+
let s = r[0].charAt(0) === "!" ? 2 : 1;
|
|
3039
|
+
if (!this.options.pedantic && Ve(e, r[1], s, this.rules))
|
|
3040
|
+
return;
|
|
3041
|
+
let o = t[K(r[2] || r[1], this.options.pedantic)];
|
|
3042
|
+
if (!o) {
|
|
3043
|
+
let i = r[0].charAt(0);
|
|
3044
|
+
return { type: "text", raw: i, text: i };
|
|
3045
|
+
}
|
|
3046
|
+
return Xe(r, o, r[0], this.lexer, this.rules);
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
emStrong(e, t, n = "") {
|
|
3050
|
+
let r = this.rules.inline.emStrongLDelim.exec(e);
|
|
3051
|
+
if (!r || !r[1] && !r[2] && !r[3] && !r[4])
|
|
3052
|
+
return;
|
|
3053
|
+
let s = r[0][0], o = n === s, i = t.length - e.length, a = i;
|
|
3054
|
+
for (;!this.options.pedantic && a > 0 && t[a - 1] === s; )
|
|
3055
|
+
a--;
|
|
3056
|
+
let p = [...t.slice(Math.max(0, a - 2), a)].at(-1) ?? "", u = p === "*" || p === "_" || !!this.rules.inline.punctuation.exec(p);
|
|
3057
|
+
a < i && (n = p);
|
|
3058
|
+
let d = a < i ? u : n === "*" || n === "_" || !!this.rules.inline.punctuation.exec(n);
|
|
3059
|
+
if (r[4] && n.match(this.rules.other.unicodeAlphaNumeric))
|
|
3060
|
+
return;
|
|
3061
|
+
let k = r[1] || r[3] || "";
|
|
3062
|
+
if (!k || !n || d) {
|
|
3063
|
+
let g = [...r[0]].length - 1, c, R, x = g, w = 0, f = i - a + g, m = !this.options.pedantic && !!p.trim() && (!!k || s === "*" && !u);
|
|
3064
|
+
if (s !== "*" && s !== "_")
|
|
3065
|
+
return;
|
|
3066
|
+
let _ = s === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd, T = ce(this, t, s), H = t.length - e.length + g;
|
|
3067
|
+
if (T < H)
|
|
3068
|
+
return;
|
|
3069
|
+
t = t.slice(-1 * e.length + g);
|
|
3070
|
+
let D = T - H;
|
|
3071
|
+
for (_.lastIndex = 0;(r = _.exec(t)) !== null && !(r.index > D); ) {
|
|
3072
|
+
if (c = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !c)
|
|
3073
|
+
continue;
|
|
3074
|
+
R = [...c].length;
|
|
3075
|
+
let V = R > x - g;
|
|
3076
|
+
if (r[3] || r[4]) {
|
|
3077
|
+
x += R;
|
|
3078
|
+
continue;
|
|
3079
|
+
} else if ((r[5] || r[6] || m && V) && f % 3 && !((f + R) % 3)) {
|
|
3080
|
+
if (o && (r[5] || r[6]))
|
|
3081
|
+
break;
|
|
3082
|
+
w += R;
|
|
3083
|
+
continue;
|
|
3084
|
+
}
|
|
3085
|
+
if (x -= R, x > 0)
|
|
3086
|
+
continue;
|
|
3087
|
+
R = Math.min(R, R + x + w);
|
|
3088
|
+
let ie = [...r[0]][0].length, Z = e.slice(0, g + r.index + ie + R);
|
|
3089
|
+
if (Math.min(g, R) % 2) {
|
|
3090
|
+
let oe = Z.slice(1, -1);
|
|
3091
|
+
return { type: "em", raw: Z, text: oe, tokens: this.lexer.inlineTokens(oe) };
|
|
3092
|
+
}
|
|
3093
|
+
let J = Z.slice(2, -2);
|
|
3094
|
+
return { type: "strong", raw: Z, text: J, tokens: this.lexer.inlineTokens(J) };
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
codespan(e) {
|
|
3099
|
+
if (e.charCodeAt(0) !== 96)
|
|
3100
|
+
return;
|
|
3101
|
+
let t = this.rules.inline.code.exec(e);
|
|
3102
|
+
if (t) {
|
|
3103
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), r = this.rules.other.nonSpaceChar.test(n), s = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
3104
|
+
return r && s && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
br(e) {
|
|
3108
|
+
let t = e.charCodeAt(0);
|
|
3109
|
+
if (t !== 32 && t !== 92 && t !== 10)
|
|
3110
|
+
return;
|
|
3111
|
+
let n = this.rules.inline.br.exec(e);
|
|
3112
|
+
if (n)
|
|
3113
|
+
return { type: "br", raw: n[0] };
|
|
3114
|
+
}
|
|
3115
|
+
del(e, t, n = "") {
|
|
3116
|
+
if (e.charCodeAt(0) !== 126)
|
|
3117
|
+
return;
|
|
3118
|
+
let r = this.rules.inline.delLDelim.exec(e);
|
|
3119
|
+
if (!r)
|
|
3120
|
+
return;
|
|
3121
|
+
if (!(r[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
3122
|
+
let o = [...r[0]].length - 1, i, a, p = o, u = this.rules.inline.delRDelim, d = he(this, t), k = t.length - e.length + o;
|
|
3123
|
+
if (d < k)
|
|
3124
|
+
return;
|
|
3125
|
+
t = t.slice(-1 * e.length + o);
|
|
3126
|
+
let g = d - k;
|
|
3127
|
+
for (u.lastIndex = 0;(r = u.exec(t)) !== null && !(r.index > g); ) {
|
|
3128
|
+
if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i || (a = [...i].length, a !== o))
|
|
3129
|
+
continue;
|
|
3130
|
+
if (r[3] || r[4]) {
|
|
3131
|
+
p += a;
|
|
3132
|
+
continue;
|
|
3133
|
+
}
|
|
3134
|
+
if (p -= a, p > 0)
|
|
3135
|
+
continue;
|
|
3136
|
+
a = Math.min(a, a + p);
|
|
3137
|
+
let c = [...r[0]][0].length, R = e.slice(0, o + r.index + c + a), x = R.slice(o, -o);
|
|
3138
|
+
return { type: "del", raw: R, text: x, tokens: this.lexer.inlineTokens(x) };
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
autolink(e) {
|
|
3143
|
+
if (e.charCodeAt(0) !== 60)
|
|
3144
|
+
return;
|
|
3145
|
+
let t = this.rules.inline.autolink.exec(e);
|
|
3146
|
+
if (t) {
|
|
3147
|
+
let n, r;
|
|
3148
|
+
return t[2] === "@" ? (n = t[1], r = "mailto:" + n) : (n = t[1], r = n), { type: "link", raw: t[0], text: n, href: r, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
url(e) {
|
|
3152
|
+
let t;
|
|
3153
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
3154
|
+
let n, r;
|
|
3155
|
+
if (t[2] === "@")
|
|
3156
|
+
n = t[0], r = "mailto:" + n;
|
|
3157
|
+
else {
|
|
3158
|
+
let s;
|
|
3159
|
+
do
|
|
3160
|
+
s = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
3161
|
+
while (s !== t[0]);
|
|
3162
|
+
n = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
|
|
3163
|
+
}
|
|
3164
|
+
return { type: "link", raw: t[0], text: n, href: r, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
inlineText(e) {
|
|
3168
|
+
let t = this.rules.inline.text.exec(e);
|
|
3169
|
+
if (t) {
|
|
3170
|
+
let n = this.lexer.state.inRawBlock;
|
|
3171
|
+
return { type: "text", raw: t[0], text: n ? t[0] : Qe(t[0]), escaped: n };
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
};
|
|
3175
|
+
var y = class l {
|
|
3176
|
+
tokens;
|
|
3177
|
+
options;
|
|
3178
|
+
state;
|
|
3179
|
+
inlineQueue;
|
|
3180
|
+
tokenizer;
|
|
3181
|
+
constructor(e) {
|
|
3182
|
+
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || $, this.options.tokenizer = this.options.tokenizer || new C, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, linkParenPossible: true, top: true, inBlockquote: false };
|
|
3183
|
+
let t = { other: b, block: re.normal, inline: W.normal };
|
|
3184
|
+
this.options.pedantic ? (t.block = re.pedantic, t.inline = W.pedantic) : this.options.gfm && (t.block = re.gfm, this.options.breaks ? t.inline = W.breaks : t.inline = W.gfm), this.tokenizer.rules = t;
|
|
3185
|
+
}
|
|
3186
|
+
static get rules() {
|
|
3187
|
+
return { block: re, inline: W };
|
|
3188
|
+
}
|
|
3189
|
+
static lex(e, t) {
|
|
3190
|
+
return new l(t).lex(e);
|
|
3191
|
+
}
|
|
3192
|
+
static lexInline(e, t) {
|
|
3193
|
+
let n = new l(t);
|
|
3194
|
+
return e.includes("\r") && (e = e.replace(b.carriageReturn, `
|
|
3195
|
+
`)), n.inlineTokens(e);
|
|
3196
|
+
}
|
|
3197
|
+
lex(e) {
|
|
3198
|
+
e = e.replace(b.carriageReturn, `
|
|
3199
|
+
`), this.blockTokens(e, this.tokens);
|
|
3200
|
+
for (let t = 0;t < this.inlineQueue.length; t++) {
|
|
3201
|
+
let n = this.inlineQueue[t];
|
|
3202
|
+
this.state.inRawBlock = false, this.inlineTokens(n.src, n.tokens);
|
|
3203
|
+
}
|
|
3204
|
+
return this.inlineQueue = [], this.tokens;
|
|
3205
|
+
}
|
|
3206
|
+
blockTokens(e, t = [], n = false) {
|
|
3207
|
+
this.tokenizer.lexer = this;
|
|
3208
|
+
let r = this.state.lastToken;
|
|
3209
|
+
this.options.pedantic && (e = e.replace(b.tabCharGlobal, " ").replace(b.spaceLine, ""));
|
|
3210
|
+
let s = 1 / 0, o, i = this.options.gfm && !this.options.pedantic && this.tokenizer.paragraph === C.prototype.paragraph;
|
|
3211
|
+
for (;e; ) {
|
|
3212
|
+
if (e.length < s)
|
|
3213
|
+
s = e.length;
|
|
3214
|
+
else {
|
|
3215
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
3216
|
+
break;
|
|
3217
|
+
}
|
|
3218
|
+
this.state.lastToken = t.at(-1);
|
|
3219
|
+
let a;
|
|
3220
|
+
if (this.options.extensions?.block?.some((u) => (a = u.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false))
|
|
3221
|
+
continue;
|
|
3222
|
+
if (a = this.tokenizer.space(e)) {
|
|
3223
|
+
e = e.substring(a.raw.length);
|
|
3224
|
+
let u = t.at(-1);
|
|
3225
|
+
a.raw.length === 1 && u !== undefined ? u.raw += `
|
|
3226
|
+
` : t.push(a);
|
|
3227
|
+
continue;
|
|
3228
|
+
}
|
|
3229
|
+
if (a = this.tokenizer.code(e)) {
|
|
3230
|
+
e = e.substring(a.raw.length);
|
|
3231
|
+
let u = t.at(-1);
|
|
3232
|
+
u?.type === "paragraph" || u?.type === "text" ? (u.raw += (u.raw.endsWith(`
|
|
3233
|
+
`) ? "" : `
|
|
3234
|
+
`) + a.raw, u.text += `
|
|
3235
|
+
` + a.text, this.inlineQueue.at(-1).src = u.text) : t.push(a);
|
|
3236
|
+
continue;
|
|
3237
|
+
}
|
|
3238
|
+
if (a = this.tokenizer.fences(e)) {
|
|
3239
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
3240
|
+
continue;
|
|
3241
|
+
}
|
|
3242
|
+
if (a = this.tokenizer.heading(e)) {
|
|
3243
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
3244
|
+
continue;
|
|
3245
|
+
}
|
|
3246
|
+
if (a = this.tokenizer.hr(e)) {
|
|
3247
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
3248
|
+
continue;
|
|
3249
|
+
}
|
|
3250
|
+
if (a = this.tokenizer.blockquote(e)) {
|
|
3251
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
3252
|
+
continue;
|
|
3253
|
+
}
|
|
3254
|
+
if (a = this.tokenizer.list(e)) {
|
|
3255
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
3256
|
+
continue;
|
|
3257
|
+
}
|
|
3258
|
+
if (a = this.tokenizer.html(e)) {
|
|
3259
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
3260
|
+
continue;
|
|
3261
|
+
}
|
|
3262
|
+
if (a = this.tokenizer.def(e)) {
|
|
3263
|
+
e = e.substring(a.raw.length);
|
|
3264
|
+
let u = t.at(-1);
|
|
3265
|
+
u?.type === "paragraph" || u?.type === "text" ? (u.raw += (u.raw.endsWith(`
|
|
3266
|
+
`) ? "" : `
|
|
3267
|
+
`) + a.raw, u.text += `
|
|
3268
|
+
` + a.raw, this.inlineQueue.at(-1).src = u.text) : (this.tokens.links[a.tag] || (this.tokens.links[a.tag] = { href: a.href, title: a.title }), t.push(a));
|
|
3269
|
+
continue;
|
|
3270
|
+
}
|
|
3271
|
+
if (a = this.tokenizer.table(e)) {
|
|
3272
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
3273
|
+
continue;
|
|
3274
|
+
}
|
|
3275
|
+
if (a = this.tokenizer.lheading(e)) {
|
|
3276
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
3277
|
+
continue;
|
|
3278
|
+
}
|
|
3279
|
+
let p = e;
|
|
3280
|
+
if (this.options.extensions?.startBlock) {
|
|
3281
|
+
let u = 1 / 0, d = e.slice(1), k;
|
|
3282
|
+
this.options.extensions.startBlock.forEach((g) => {
|
|
3283
|
+
k = g.call({ lexer: this }, d), typeof k == "number" && k >= 0 && (u = Math.min(u, k));
|
|
3284
|
+
}), u < 1 / 0 && u >= 0 && (p = e.substring(0, u + 1));
|
|
3285
|
+
}
|
|
3286
|
+
if (this.state.top && (a = this.tokenizer.paragraph(p))) {
|
|
3287
|
+
let u = t.at(-1);
|
|
3288
|
+
(n || u === o && i) && u?.type === "paragraph" ? (u.raw += (u.raw.endsWith(`
|
|
3289
|
+
`) ? "" : `
|
|
3290
|
+
`) + a.raw, u.text += `
|
|
3291
|
+
` + a.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = u.text, o = u) : (t.push(a), o = a), n = p.length !== e.length, e = e.substring(a.raw.length);
|
|
3292
|
+
continue;
|
|
3293
|
+
}
|
|
3294
|
+
if (a = this.tokenizer.text(e)) {
|
|
3295
|
+
e = e.substring(a.raw.length);
|
|
3296
|
+
let u = t.at(-1);
|
|
3297
|
+
u?.type === "text" ? (u.raw += (u.raw.endsWith(`
|
|
3298
|
+
`) ? "" : `
|
|
3299
|
+
`) + a.raw, u.text += `
|
|
3300
|
+
` + a.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = u.text) : t.push(a);
|
|
3301
|
+
continue;
|
|
3302
|
+
}
|
|
3303
|
+
if (e) {
|
|
3304
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
3305
|
+
break;
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
return this.state.top = true, this.state.lastToken = r, t;
|
|
3309
|
+
}
|
|
3310
|
+
inline(e, t = []) {
|
|
3311
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
3312
|
+
}
|
|
3313
|
+
linkInText(e) {
|
|
3314
|
+
if (!e.includes("["))
|
|
3315
|
+
return false;
|
|
3316
|
+
let t = this.tokenizer.rules.inline.link;
|
|
3317
|
+
for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))
|
|
3318
|
+
if (t.test(n[0]) && e.charAt(n.index - 1) !== "!")
|
|
3319
|
+
return true;
|
|
3320
|
+
for (let n of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
|
|
3321
|
+
let r = n[0], s = r.lastIndexOf("[");
|
|
3322
|
+
if (!(r.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, K(r.slice(s + 1, -1), this.options.pedantic))) && !(s > 1 && this.linkInText(r.slice(1, s - 1))))
|
|
3323
|
+
return true;
|
|
3324
|
+
}
|
|
3325
|
+
return false;
|
|
3326
|
+
}
|
|
3327
|
+
inlineTokens(e, t = []) {
|
|
3328
|
+
this.tokenizer.lexer = this;
|
|
3329
|
+
let n = this.state.linkParenPossible;
|
|
3330
|
+
this.state.linkParenPossible = e.includes(")");
|
|
3331
|
+
try {
|
|
3332
|
+
return this.#t(e, t);
|
|
3333
|
+
} finally {
|
|
3334
|
+
this.state.linkParenPossible = n;
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
#t(e, t) {
|
|
3338
|
+
let n = e.includes("*") || e.includes("_") || e.includes("~"), r = n || this.options.hooks?.emStrongMask || this.tokenizer.emStrong !== C.prototype.emStrong || this.tokenizer.del !== C.prototype.del ? this.#r(e) : e;
|
|
3339
|
+
if (!n)
|
|
3340
|
+
return this.#e(e, r, t);
|
|
3341
|
+
We(this.tokenizer, r);
|
|
3342
|
+
try {
|
|
3343
|
+
return this.#e(e, r, t);
|
|
3344
|
+
} finally {
|
|
3345
|
+
Ue(this.tokenizer);
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
#e(e, t, n) {
|
|
3349
|
+
let r = false, s = "", o = 1 / 0;
|
|
3350
|
+
for (;e; ) {
|
|
3351
|
+
if (e.length < o)
|
|
3352
|
+
o = e.length;
|
|
3353
|
+
else {
|
|
3354
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
3355
|
+
break;
|
|
3356
|
+
}
|
|
3357
|
+
r || (s = ""), r = false;
|
|
3358
|
+
let i;
|
|
3359
|
+
if (this.options.extensions?.inline?.some((u) => (i = u.call({ lexer: this }, e, n)) ? (e = e.substring(i.raw.length), n.push(i), true) : false))
|
|
3360
|
+
continue;
|
|
3361
|
+
if (i = this.tokenizer.escape(e)) {
|
|
3362
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3363
|
+
continue;
|
|
3364
|
+
}
|
|
3365
|
+
if (i = this.tokenizer.tag(e)) {
|
|
3366
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3367
|
+
continue;
|
|
3368
|
+
}
|
|
3369
|
+
if (i = this.tokenizer.link(e)) {
|
|
3370
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3371
|
+
continue;
|
|
3372
|
+
}
|
|
3373
|
+
if (i = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
3374
|
+
e = e.substring(i.raw.length);
|
|
3375
|
+
let u = n.at(-1);
|
|
3376
|
+
i.type === "text" && u?.type === "text" ? (u.raw += i.raw, u.text += i.text) : n.push(i);
|
|
3377
|
+
continue;
|
|
3378
|
+
}
|
|
3379
|
+
let a = e[0];
|
|
3380
|
+
if (a === "*" || a === "_") {
|
|
3381
|
+
let u = t.length - e.length;
|
|
3382
|
+
if (ce(this.tokenizer, t, a) <= u) {
|
|
3383
|
+
let k = 1;
|
|
3384
|
+
for (;k < e.length && e.charCodeAt(k) === a.charCodeAt(0); )
|
|
3385
|
+
k++;
|
|
3386
|
+
let g = e.substring(0, k), c = n.at(-1);
|
|
3387
|
+
c?.type === "text" && !c.escaped ? (c.raw += g, c.text += g) : n.push({ type: "text", raw: g, text: g, escaped: false }), e = e.substring(k), s = a, r = true;
|
|
3388
|
+
continue;
|
|
3389
|
+
}
|
|
3390
|
+
} else if (a === "~") {
|
|
3391
|
+
let u = t.length - e.length;
|
|
3392
|
+
if (he(this.tokenizer, t) <= u) {
|
|
3393
|
+
let k = 1;
|
|
3394
|
+
for (;k < e.length && e.charCodeAt(k) === 126; )
|
|
3395
|
+
k++;
|
|
3396
|
+
let g = e.substring(0, k), c = n.at(-1);
|
|
3397
|
+
c?.type === "text" && !c.escaped ? (c.raw += g, c.text += g) : n.push({ type: "text", raw: g, text: g, escaped: false }), e = e.substring(k), s = a, r = true;
|
|
3398
|
+
continue;
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
if (i = this.tokenizer.emStrong(e, t, s)) {
|
|
3402
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3403
|
+
continue;
|
|
3404
|
+
}
|
|
3405
|
+
if (i = this.tokenizer.codespan(e)) {
|
|
3406
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3407
|
+
continue;
|
|
3408
|
+
}
|
|
3409
|
+
if (i = this.tokenizer.br(e)) {
|
|
3410
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3411
|
+
continue;
|
|
3412
|
+
}
|
|
3413
|
+
if (i = this.tokenizer.del(e, t, s)) {
|
|
3414
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3415
|
+
continue;
|
|
3416
|
+
}
|
|
3417
|
+
if (i = this.tokenizer.autolink(e)) {
|
|
3418
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3419
|
+
continue;
|
|
3420
|
+
}
|
|
3421
|
+
if (!this.state.inLink && (i = this.tokenizer.url(e))) {
|
|
3422
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
3423
|
+
continue;
|
|
3424
|
+
}
|
|
3425
|
+
let p = e;
|
|
3426
|
+
if (this.options.extensions?.startInline) {
|
|
3427
|
+
let u = 1 / 0, d = e.slice(1), k;
|
|
3428
|
+
this.options.extensions.startInline.forEach((g) => {
|
|
3429
|
+
k = g.call({ lexer: this }, d), typeof k == "number" && k >= 0 && (u = Math.min(u, k));
|
|
3430
|
+
}), u < 1 / 0 && u >= 0 && (p = e.substring(0, u + 1));
|
|
3431
|
+
}
|
|
3432
|
+
if (i = this.tokenizer.inlineText(p)) {
|
|
3433
|
+
e = e.substring(i.raw.length), i.raw.slice(-1) !== "_" && (s = i.raw.slice(-1)), r = true;
|
|
3434
|
+
let u = n.at(-1);
|
|
3435
|
+
u?.type === "text" ? (u.raw += i.raw, u.text += i.text) : n.push(i);
|
|
3436
|
+
continue;
|
|
3437
|
+
}
|
|
3438
|
+
if (e) {
|
|
3439
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
3440
|
+
break;
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
return n;
|
|
3444
|
+
}
|
|
3445
|
+
#n(e) {
|
|
3446
|
+
let { blockSkip: t, tag: n, autolink: r } = this.tokenizer.rules.inline, s = "", o = 0, i;
|
|
3447
|
+
for (t.lastIndex = 0;i = t.exec(e); ) {
|
|
3448
|
+
let a = i.index + (i[2] ? i[2].length : 0), p = i.index + i[0].length;
|
|
3449
|
+
if (e.charAt(a) === "<") {
|
|
3450
|
+
let u = e.slice(a), d = n.exec(u) || r.exec(u);
|
|
3451
|
+
if (!d) {
|
|
3452
|
+
t.lastIndex = a + 1;
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
p = a + d[0].length, t.lastIndex = p;
|
|
3456
|
+
}
|
|
3457
|
+
s += e.slice(o, a) + "[" + "a".repeat(p - a - 2) + "]", o = p;
|
|
3458
|
+
}
|
|
3459
|
+
return s + e.slice(o);
|
|
3460
|
+
}
|
|
3461
|
+
#r(e) {
|
|
3462
|
+
let t = e;
|
|
3463
|
+
if (this.tokens.links && e.includes("[")) {
|
|
3464
|
+
let n = this.tokenizer.rules.inline.reflinkSearch, r = (s) => {
|
|
3465
|
+
let o = s.lastIndexOf("[");
|
|
3466
|
+
if (!Object.hasOwn(this.tokens.links, K(s.slice(o + 1, -1), this.options.pedantic)))
|
|
3467
|
+
return s;
|
|
3468
|
+
if (o > 1 && s.charAt(0) !== "!") {
|
|
3469
|
+
let i = s.slice(1, o - 1);
|
|
3470
|
+
if (this.linkInText(i))
|
|
3471
|
+
return "[" + i.replace(n, r) + "][" + "a".repeat(s.length - o - 2) + "]";
|
|
3472
|
+
}
|
|
3473
|
+
return "[" + "a".repeat(s.length - 2) + "]";
|
|
3474
|
+
};
|
|
3475
|
+
t = t.replace(n, r);
|
|
3476
|
+
}
|
|
3477
|
+
return t = t.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode, (n, r, s) => s ? "+".repeat(n.length) : r ? r + n.slice(r.length, -r.length).replace(/`/g, "+") + r : n), t = this.#n(t), t = this.options.hooks?.emStrongMask?.call({ lexer: this }, t) ?? t, t;
|
|
3478
|
+
}
|
|
3479
|
+
infiniteLoopError(e) {
|
|
3480
|
+
let t = "Infinite loop on byte: " + e;
|
|
3481
|
+
if (this.options.silent)
|
|
3482
|
+
console.error(t);
|
|
3483
|
+
else
|
|
3484
|
+
throw new Error(t);
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
function _e(l, e = false) {
|
|
3488
|
+
let t;
|
|
3489
|
+
for (let n = 0;n < l.length; n++) {
|
|
3490
|
+
let r = l[n], s = r;
|
|
3491
|
+
if (r.type === "codespan" || r.type === "escape" || e && r.type === "text") {
|
|
3492
|
+
let o = P(r.text, true);
|
|
3493
|
+
o !== r.text && (s = { ...r, text: o });
|
|
3494
|
+
} else if (r.type === "link" && r.autolink) {
|
|
3495
|
+
let o = P(r.text, true), i = r.tokens, a = i && (i.length === 1 && i[0].type === "text" && i[0].text === r.text ? o !== r.text ? [{ ...i[0], text: o }] : i : _e(i, true));
|
|
3496
|
+
(o !== r.text || a !== i) && (s = a !== i ? { ...r, text: o, tokens: a } : { ...r, text: o });
|
|
3497
|
+
} else if ("tokens" in r && r.tokens) {
|
|
3498
|
+
let o = _e(r.tokens, e);
|
|
3499
|
+
o !== r.tokens && (s = { ...r, tokens: o });
|
|
3500
|
+
}
|
|
3501
|
+
s !== r ? (t || (t = l.slice(0, n)), t.push(s)) : t && t.push(r);
|
|
3502
|
+
}
|
|
3503
|
+
return t || l;
|
|
3504
|
+
}
|
|
3505
|
+
var M = class {
|
|
3506
|
+
options;
|
|
3507
|
+
parser;
|
|
3508
|
+
constructor(e) {
|
|
3509
|
+
this.options = e || $;
|
|
3510
|
+
}
|
|
3511
|
+
space(e) {
|
|
3512
|
+
return "";
|
|
3513
|
+
}
|
|
3514
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
3515
|
+
let r = (t || "").trim().match(b.notSpaceStart)?.[0], s = e ? e.replace(b.endingNewline, "") + `
|
|
3516
|
+
` : "";
|
|
3517
|
+
return r ? '<pre><code class="language-' + P(r) + '">' + (n ? s : P(s, true)) + `</code></pre>
|
|
3518
|
+
` : "<pre><code>" + (n ? s : P(s, true)) + `</code></pre>
|
|
3519
|
+
`;
|
|
3520
|
+
}
|
|
3521
|
+
blockquote({ tokens: e }) {
|
|
3522
|
+
return `<blockquote>
|
|
3523
|
+
${this.parser.parse(e)}</blockquote>
|
|
3524
|
+
`;
|
|
3525
|
+
}
|
|
3526
|
+
html({ text: e }) {
|
|
3527
|
+
return e;
|
|
3528
|
+
}
|
|
3529
|
+
def(e) {
|
|
3530
|
+
return "";
|
|
3531
|
+
}
|
|
3532
|
+
heading({ tokens: e, depth: t }) {
|
|
3533
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
3534
|
+
`;
|
|
3535
|
+
}
|
|
3536
|
+
hr(e) {
|
|
3537
|
+
return `<hr>
|
|
3538
|
+
`;
|
|
3539
|
+
}
|
|
3540
|
+
list(e) {
|
|
3541
|
+
let { ordered: t, start: n } = e, r = "";
|
|
3542
|
+
for (let i = 0;i < e.items.length; i++) {
|
|
3543
|
+
let a = e.items[i];
|
|
3544
|
+
r += this.listitem(a);
|
|
3545
|
+
}
|
|
3546
|
+
let s = t ? "ol" : "ul", o = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
3547
|
+
return "<" + s + o + `>
|
|
3548
|
+
` + r + "</" + s + `>
|
|
3549
|
+
`;
|
|
3550
|
+
}
|
|
3551
|
+
listitem(e) {
|
|
3552
|
+
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
3553
|
+
`;
|
|
3554
|
+
}
|
|
3555
|
+
checkbox({ checked: e }) {
|
|
3556
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
3557
|
+
}
|
|
3558
|
+
paragraph({ tokens: e }) {
|
|
3559
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
3560
|
+
`;
|
|
3561
|
+
}
|
|
3562
|
+
table(e) {
|
|
3563
|
+
let t = "", n = "";
|
|
3564
|
+
for (let s = 0;s < e.header.length; s++)
|
|
3565
|
+
n += this.tablecell(e.header[s]);
|
|
3566
|
+
t += this.tablerow({ text: n });
|
|
3567
|
+
let r = "";
|
|
3568
|
+
for (let s = 0;s < e.rows.length; s++) {
|
|
3569
|
+
let o = e.rows[s];
|
|
3570
|
+
n = "";
|
|
3571
|
+
for (let i = 0;i < o.length; i++)
|
|
3572
|
+
n += this.tablecell(o[i]);
|
|
3573
|
+
r += this.tablerow({ text: n });
|
|
3574
|
+
}
|
|
3575
|
+
return r && (r = `<tbody>${r}</tbody>`), `<table>
|
|
3576
|
+
<thead>
|
|
3577
|
+
` + t + `</thead>
|
|
3578
|
+
` + r + `</table>
|
|
3579
|
+
`;
|
|
3580
|
+
}
|
|
3581
|
+
tablerow({ text: e }) {
|
|
3582
|
+
return `<tr>
|
|
3583
|
+
${e}</tr>
|
|
3584
|
+
`;
|
|
3585
|
+
}
|
|
3586
|
+
tablecell(e) {
|
|
3587
|
+
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
3588
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
3589
|
+
`;
|
|
3590
|
+
}
|
|
3591
|
+
strong({ tokens: e }) {
|
|
3592
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
3593
|
+
}
|
|
3594
|
+
em({ tokens: e }) {
|
|
3595
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
3596
|
+
}
|
|
3597
|
+
codespan({ text: e }) {
|
|
3598
|
+
return `<code>${P(e, true)}</code>`;
|
|
3599
|
+
}
|
|
3600
|
+
br(e) {
|
|
3601
|
+
return "<br>";
|
|
3602
|
+
}
|
|
3603
|
+
del({ tokens: e }) {
|
|
3604
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
3605
|
+
}
|
|
3606
|
+
link({ href: e, title: t, text: n, tokens: r, autolink: s }) {
|
|
3607
|
+
let o = s ? P(n, true) : this.parser.parseInline(r), i = we(e);
|
|
3608
|
+
if (i === null)
|
|
3609
|
+
return o;
|
|
3610
|
+
e = P(i, s);
|
|
3611
|
+
let a = '<a href="' + e + '"';
|
|
3612
|
+
return t && (a += ' title="' + P(t) + '"'), a += ">" + o + "</a>", a;
|
|
3613
|
+
}
|
|
3614
|
+
image({ href: e, title: t, text: n, tokens: r }) {
|
|
3615
|
+
r && (n = this.parser.parseInline(_e(r), this.parser.textRenderer));
|
|
3616
|
+
let s = we(e);
|
|
3617
|
+
if (s === null)
|
|
3618
|
+
return P(n);
|
|
3619
|
+
e = s;
|
|
3620
|
+
let o = `<img src="${P(e)}" alt="${P(n)}"`;
|
|
3621
|
+
return t && (o += ` title="${P(t)}"`), o += ">", o;
|
|
3622
|
+
}
|
|
3623
|
+
text(e) {
|
|
3624
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : P(e.text);
|
|
3625
|
+
}
|
|
3626
|
+
};
|
|
3627
|
+
var q = class {
|
|
3628
|
+
parser;
|
|
3629
|
+
strong({ text: e, tokens: t }) {
|
|
3630
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3631
|
+
}
|
|
3632
|
+
em({ text: e, tokens: t }) {
|
|
3633
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3634
|
+
}
|
|
3635
|
+
codespan({ text: e }) {
|
|
3636
|
+
return e;
|
|
3637
|
+
}
|
|
3638
|
+
del({ text: e, tokens: t }) {
|
|
3639
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3640
|
+
}
|
|
3641
|
+
html({ text: e }) {
|
|
3642
|
+
return e;
|
|
3643
|
+
}
|
|
3644
|
+
text({ text: e }) {
|
|
3645
|
+
return e;
|
|
3646
|
+
}
|
|
3647
|
+
link({ text: e, tokens: t }) {
|
|
3648
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3649
|
+
}
|
|
3650
|
+
image({ text: e, tokens: t }) {
|
|
3651
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
3652
|
+
}
|
|
3653
|
+
br() {
|
|
3654
|
+
return `
|
|
3655
|
+
`;
|
|
3656
|
+
}
|
|
3657
|
+
checkbox({ raw: e }) {
|
|
3658
|
+
return e;
|
|
3659
|
+
}
|
|
3660
|
+
};
|
|
3661
|
+
var S = class l {
|
|
3662
|
+
options;
|
|
3663
|
+
renderer;
|
|
3664
|
+
textRenderer;
|
|
3665
|
+
constructor(e) {
|
|
3666
|
+
this.options = e || $, this.options.renderer = this.options.renderer || new M, this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new q, this.textRenderer.parser = this;
|
|
3667
|
+
}
|
|
3668
|
+
static parse(e, t) {
|
|
3669
|
+
return new l(t).parse(e);
|
|
3670
|
+
}
|
|
3671
|
+
static parseInline(e, t) {
|
|
3672
|
+
return new l(t).parseInline(e);
|
|
3673
|
+
}
|
|
3674
|
+
parse(e) {
|
|
3675
|
+
this.renderer.parser = this;
|
|
3676
|
+
let t = "";
|
|
3677
|
+
for (let n = 0;n < e.length; n++) {
|
|
3678
|
+
let r = e[n], s = this.options.extensions?.renderers;
|
|
3679
|
+
if (s && Object.hasOwn(s, r.type) && s[r.type]) {
|
|
3680
|
+
let i = r, a = s[i.type].call({ parser: this }, i);
|
|
3681
|
+
if (a !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
3682
|
+
t += a === false ? "" : a ?? "";
|
|
3683
|
+
continue;
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
let o = r;
|
|
3687
|
+
switch (o.type) {
|
|
3688
|
+
case "space": {
|
|
3689
|
+
t += this.renderer.space(o);
|
|
3690
|
+
break;
|
|
3691
|
+
}
|
|
3692
|
+
case "hr": {
|
|
3693
|
+
t += this.renderer.hr(o);
|
|
3694
|
+
break;
|
|
3695
|
+
}
|
|
3696
|
+
case "heading": {
|
|
3697
|
+
t += this.renderer.heading(o);
|
|
3698
|
+
break;
|
|
3699
|
+
}
|
|
3700
|
+
case "code": {
|
|
3701
|
+
t += this.renderer.code(o);
|
|
3702
|
+
break;
|
|
3703
|
+
}
|
|
3704
|
+
case "table": {
|
|
3705
|
+
t += this.renderer.table(o);
|
|
3706
|
+
break;
|
|
3707
|
+
}
|
|
3708
|
+
case "blockquote": {
|
|
3709
|
+
t += this.renderer.blockquote(o);
|
|
3710
|
+
break;
|
|
3711
|
+
}
|
|
3712
|
+
case "list": {
|
|
3713
|
+
t += this.renderer.list(o);
|
|
3714
|
+
break;
|
|
3715
|
+
}
|
|
3716
|
+
case "checkbox": {
|
|
3717
|
+
t += this.renderer.checkbox(o);
|
|
3718
|
+
break;
|
|
3719
|
+
}
|
|
3720
|
+
case "html": {
|
|
3721
|
+
t += this.renderer.html(o);
|
|
3722
|
+
break;
|
|
3723
|
+
}
|
|
3724
|
+
case "def": {
|
|
3725
|
+
t += this.renderer.def(o);
|
|
3726
|
+
break;
|
|
3727
|
+
}
|
|
3728
|
+
case "paragraph": {
|
|
3729
|
+
t += this.renderer.paragraph(o);
|
|
3730
|
+
break;
|
|
3731
|
+
}
|
|
3732
|
+
case "text": {
|
|
3733
|
+
t += this.renderer.text(o);
|
|
3734
|
+
break;
|
|
3735
|
+
}
|
|
3736
|
+
default: {
|
|
3737
|
+
let i = 'Token with "' + o.type + '" type was not found.';
|
|
3738
|
+
if (this.options.silent)
|
|
3739
|
+
return console.error(i), "";
|
|
3740
|
+
throw new Error(i);
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
return t;
|
|
3745
|
+
}
|
|
3746
|
+
parseInline(e, t = this.renderer) {
|
|
3747
|
+
this.renderer.parser = this;
|
|
3748
|
+
let n = "";
|
|
3749
|
+
for (let r = 0;r < e.length; r++) {
|
|
3750
|
+
let s = e[r], o = this.options.extensions?.renderers;
|
|
3751
|
+
if (o && Object.hasOwn(o, s.type) && o[s.type]) {
|
|
3752
|
+
let a = o[s.type].call({ parser: this }, s);
|
|
3753
|
+
if (a !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(s.type)) {
|
|
3754
|
+
n += a === false ? "" : a ?? "";
|
|
3755
|
+
continue;
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
let i = s;
|
|
3759
|
+
switch (i.type) {
|
|
3760
|
+
case "escape": {
|
|
3761
|
+
n += t.text(i);
|
|
3762
|
+
break;
|
|
3763
|
+
}
|
|
3764
|
+
case "html": {
|
|
3765
|
+
n += t.html(i);
|
|
3766
|
+
break;
|
|
3767
|
+
}
|
|
3768
|
+
case "link": {
|
|
3769
|
+
n += t.link(i);
|
|
3770
|
+
break;
|
|
3771
|
+
}
|
|
3772
|
+
case "image": {
|
|
3773
|
+
n += t.image(i);
|
|
3774
|
+
break;
|
|
3775
|
+
}
|
|
3776
|
+
case "checkbox": {
|
|
3777
|
+
n += t.checkbox(i);
|
|
3778
|
+
break;
|
|
3779
|
+
}
|
|
3780
|
+
case "strong": {
|
|
3781
|
+
n += t.strong(i);
|
|
3782
|
+
break;
|
|
3783
|
+
}
|
|
3784
|
+
case "em": {
|
|
3785
|
+
n += t.em(i);
|
|
3786
|
+
break;
|
|
3787
|
+
}
|
|
3788
|
+
case "codespan": {
|
|
3789
|
+
n += t.codespan(i);
|
|
3790
|
+
break;
|
|
3791
|
+
}
|
|
3792
|
+
case "br": {
|
|
3793
|
+
n += t.br(i);
|
|
3794
|
+
break;
|
|
3795
|
+
}
|
|
3796
|
+
case "del": {
|
|
3797
|
+
n += t.del(i);
|
|
3798
|
+
break;
|
|
3799
|
+
}
|
|
3800
|
+
case "text": {
|
|
3801
|
+
n += t.text(i);
|
|
3802
|
+
break;
|
|
3803
|
+
}
|
|
3804
|
+
default: {
|
|
3805
|
+
let a = 'Token with "' + i.type + '" type was not found.';
|
|
3806
|
+
if (this.options.silent)
|
|
3807
|
+
return console.error(a), "";
|
|
3808
|
+
throw new Error(a);
|
|
3809
|
+
}
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
return n;
|
|
3813
|
+
}
|
|
3814
|
+
};
|
|
3815
|
+
var B = class {
|
|
3816
|
+
options;
|
|
3817
|
+
block;
|
|
3818
|
+
constructor(e) {
|
|
3819
|
+
this.options = e || $;
|
|
3820
|
+
}
|
|
3821
|
+
static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
3822
|
+
static passThroughHooksRespectAsync = new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
3823
|
+
preprocess(e) {
|
|
3824
|
+
return e;
|
|
3825
|
+
}
|
|
3826
|
+
postprocess(e) {
|
|
3827
|
+
return e;
|
|
3828
|
+
}
|
|
3829
|
+
processAllTokens(e) {
|
|
3830
|
+
return e;
|
|
3831
|
+
}
|
|
3832
|
+
emStrongMask(e) {
|
|
3833
|
+
return e;
|
|
3834
|
+
}
|
|
3835
|
+
provideLexer(e = this.block) {
|
|
3836
|
+
return e ? y.lex : y.lexInline;
|
|
3837
|
+
}
|
|
3838
|
+
provideParser(e = this.block) {
|
|
3839
|
+
return e ? S.parse : S.parseInline;
|
|
3840
|
+
}
|
|
3841
|
+
};
|
|
3842
|
+
function v(l, e) {
|
|
3843
|
+
if (Array.isArray(e))
|
|
3844
|
+
for (let t = 0;t < e.length; t++)
|
|
3845
|
+
l.push(e[t]);
|
|
3846
|
+
else
|
|
3847
|
+
l.push(e);
|
|
3848
|
+
}
|
|
3849
|
+
var se = class {
|
|
3850
|
+
defaults = G();
|
|
3851
|
+
options = this.setOptions;
|
|
3852
|
+
parse = this.parseMarkdown(true);
|
|
3853
|
+
parseInline = this.parseMarkdown(false);
|
|
3854
|
+
Parser = S;
|
|
3855
|
+
Renderer = M;
|
|
3856
|
+
TextRenderer = q;
|
|
3857
|
+
Lexer = y;
|
|
3858
|
+
Tokenizer = C;
|
|
3859
|
+
Hooks = B;
|
|
3860
|
+
constructor(...e) {
|
|
3861
|
+
this.use(...e);
|
|
3862
|
+
}
|
|
3863
|
+
walkTokens(e, t) {
|
|
3864
|
+
let n = [];
|
|
3865
|
+
for (let r of e)
|
|
3866
|
+
switch (v(n, t.call(this, r)), r.type) {
|
|
3867
|
+
case "table": {
|
|
3868
|
+
let s = r;
|
|
3869
|
+
for (let o of s.header)
|
|
3870
|
+
v(n, this.walkTokens(o.tokens, t));
|
|
3871
|
+
for (let o of s.rows)
|
|
3872
|
+
for (let i of o)
|
|
3873
|
+
v(n, this.walkTokens(i.tokens, t));
|
|
3874
|
+
break;
|
|
3875
|
+
}
|
|
3876
|
+
case "list": {
|
|
3877
|
+
let s = r;
|
|
3878
|
+
v(n, this.walkTokens(s.items, t));
|
|
3879
|
+
break;
|
|
3880
|
+
}
|
|
3881
|
+
default: {
|
|
3882
|
+
let s = r;
|
|
3883
|
+
this.defaults.extensions?.childTokens?.[s.type] ? this.defaults.extensions.childTokens[s.type].forEach((o) => {
|
|
3884
|
+
if (s[o]) {
|
|
3885
|
+
let i = s[o].flat(1 / 0);
|
|
3886
|
+
v(n, this.walkTokens(i, t));
|
|
3887
|
+
}
|
|
3888
|
+
}) : s.tokens && v(n, this.walkTokens(s.tokens, t));
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
return n;
|
|
3892
|
+
}
|
|
3893
|
+
use(...e) {
|
|
3894
|
+
let t = this.defaults.extensions || { renderers: Object.create(null), childTokens: Object.create(null) };
|
|
3895
|
+
return e.forEach((n) => {
|
|
3896
|
+
let r = { ...n };
|
|
3897
|
+
if (r.async = this.defaults.async || r.async || false, n.extensions && (n.extensions.forEach((s) => {
|
|
3898
|
+
if (!s.name)
|
|
3899
|
+
throw new Error("extension name required");
|
|
3900
|
+
if ("renderer" in s && s.renderer) {
|
|
3901
|
+
let o = s.renderer, i = t.renderers[s.name];
|
|
3902
|
+
i ? t.renderers[s.name] = function(...a) {
|
|
3903
|
+
let p = o.apply(this, a);
|
|
3904
|
+
return p === false && (p = i.apply(this, a)), p;
|
|
3905
|
+
} : t.renderers[s.name] = o;
|
|
3906
|
+
}
|
|
3907
|
+
if ("tokenizer" in s && s.tokenizer) {
|
|
3908
|
+
if (!s.level || s.level !== "block" && s.level !== "inline")
|
|
3909
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
3910
|
+
let o = t[s.level];
|
|
3911
|
+
o ? o.unshift(s.tokenizer) : t[s.level] = [s.tokenizer], s.start && (s.level === "block" ? t.startBlock ? t.startBlock.push(s.start) : t.startBlock = [s.start] : s.level === "inline" && (t.startInline ? t.startInline.push(s.start) : t.startInline = [s.start]));
|
|
3912
|
+
}
|
|
3913
|
+
"childTokens" in s && s.childTokens && (t.childTokens[s.name] = s.childTokens);
|
|
3914
|
+
}), r.extensions = t), n.renderer) {
|
|
3915
|
+
let s = this.defaults.renderer || new M(this.defaults);
|
|
3916
|
+
for (let o in n.renderer) {
|
|
3917
|
+
if (!(o in s))
|
|
3918
|
+
throw new Error(`renderer '${o}' does not exist`);
|
|
3919
|
+
if (["options", "parser"].includes(o))
|
|
3920
|
+
continue;
|
|
3921
|
+
let i = o, a = n.renderer[i];
|
|
3922
|
+
if (a === undefined)
|
|
3923
|
+
continue;
|
|
3924
|
+
let p = s[i];
|
|
3925
|
+
s[i] = (...u) => {
|
|
3926
|
+
let d = a.apply(s, u);
|
|
3927
|
+
return d === false && (d = p.apply(s, u)), d === false ? "" : d ?? "";
|
|
3928
|
+
};
|
|
3929
|
+
}
|
|
3930
|
+
r.renderer = s;
|
|
3931
|
+
}
|
|
3932
|
+
if (n.tokenizer) {
|
|
3933
|
+
let s = this.defaults.tokenizer || new C(this.defaults);
|
|
3934
|
+
for (let o in n.tokenizer) {
|
|
3935
|
+
if (!(o in s))
|
|
3936
|
+
throw new Error(`tokenizer '${o}' does not exist`);
|
|
3937
|
+
if (["options", "rules", "lexer"].includes(o))
|
|
3938
|
+
continue;
|
|
3939
|
+
let i = o, a = n.tokenizer[i];
|
|
3940
|
+
if (a === undefined)
|
|
3941
|
+
continue;
|
|
3942
|
+
let p = s[i];
|
|
3943
|
+
s[i] = (...u) => {
|
|
3944
|
+
let d = a.apply(s, u);
|
|
3945
|
+
return d === false && (d = p.apply(s, u)), d;
|
|
3946
|
+
};
|
|
3947
|
+
}
|
|
3948
|
+
r.tokenizer = s;
|
|
3949
|
+
}
|
|
3950
|
+
if (n.hooks) {
|
|
3951
|
+
let s = this.defaults.hooks || new B;
|
|
3952
|
+
for (let o in n.hooks) {
|
|
3953
|
+
if (!(o in s))
|
|
3954
|
+
throw new Error(`hook '${o}' does not exist`);
|
|
3955
|
+
if (["options", "block"].includes(o))
|
|
3956
|
+
continue;
|
|
3957
|
+
let i = o, a = n.hooks[i];
|
|
3958
|
+
if (a === undefined)
|
|
3959
|
+
continue;
|
|
3960
|
+
let p = s[i];
|
|
3961
|
+
B.passThroughHooks.has(o) ? s[i] = (u) => {
|
|
3962
|
+
if (s.options.async && B.passThroughHooksRespectAsync.has(o))
|
|
3963
|
+
return (async () => {
|
|
3964
|
+
let k = await a.call(s, u);
|
|
3965
|
+
return p.call(s, k);
|
|
3966
|
+
})();
|
|
3967
|
+
let d = a.call(s, u);
|
|
3968
|
+
return p.call(s, d);
|
|
3969
|
+
} : s[i] = (...u) => {
|
|
3970
|
+
if (s.options.async)
|
|
3971
|
+
return (async () => {
|
|
3972
|
+
let k = await a.apply(s, u);
|
|
3973
|
+
return k === false && (k = await p.apply(s, u)), k;
|
|
3974
|
+
})();
|
|
3975
|
+
let d = a.apply(s, u);
|
|
3976
|
+
return d === false && (d = p.apply(s, u)), d;
|
|
3977
|
+
};
|
|
3978
|
+
}
|
|
3979
|
+
r.hooks = s;
|
|
3980
|
+
}
|
|
3981
|
+
if (n.walkTokens) {
|
|
3982
|
+
let s = this.defaults.walkTokens, o = n.walkTokens;
|
|
3983
|
+
r.walkTokens = function(i) {
|
|
3984
|
+
let a = [];
|
|
3985
|
+
return v(a, o.call(this, i)), s && v(a, s.call(this, i)), a;
|
|
3986
|
+
};
|
|
3987
|
+
}
|
|
3988
|
+
this.defaults = { ...this.defaults, ...r };
|
|
3989
|
+
}), this;
|
|
3990
|
+
}
|
|
3991
|
+
setOptions(e) {
|
|
3992
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
3993
|
+
}
|
|
3994
|
+
lexer(e, t) {
|
|
3995
|
+
return y.lex(e, t ?? this.defaults);
|
|
3996
|
+
}
|
|
3997
|
+
parser(e, t) {
|
|
3998
|
+
return S.parse(e, t ?? this.defaults);
|
|
3999
|
+
}
|
|
4000
|
+
parseMarkdown(e) {
|
|
4001
|
+
return (n, r) => {
|
|
4002
|
+
let s = { ...r }, o = { ...this.defaults, ...s }, i = this.onError(!!o.silent, !!o.async);
|
|
4003
|
+
if (this.defaults.async === true && s.async === false)
|
|
4004
|
+
return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
4005
|
+
if (typeof n > "u" || n === null)
|
|
4006
|
+
return i(new Error("marked(): input parameter is undefined or null"));
|
|
4007
|
+
if (typeof n != "string")
|
|
4008
|
+
return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
4009
|
+
if (o.hooks && (o.hooks.options = o, o.hooks.block = e), o.async)
|
|
4010
|
+
return (async () => {
|
|
4011
|
+
let a = o.hooks ? await o.hooks.preprocess(n) : n, u = await (o.hooks ? await o.hooks.provideLexer(e) : e ? y.lex : y.lexInline)(a, o), d = o.hooks ? await o.hooks.processAllTokens(u) : u;
|
|
4012
|
+
o.walkTokens && await Promise.all(this.walkTokens(d, o.walkTokens));
|
|
4013
|
+
let g = await (o.hooks ? await o.hooks.provideParser(e) : e ? S.parse : S.parseInline)(d, o);
|
|
4014
|
+
return o.hooks ? await o.hooks.postprocess(g) : g;
|
|
4015
|
+
})().catch(i);
|
|
4016
|
+
try {
|
|
4017
|
+
o.hooks && (n = o.hooks.preprocess(n));
|
|
4018
|
+
let p = (o.hooks ? o.hooks.provideLexer(e) : e ? y.lex : y.lexInline)(n, o);
|
|
4019
|
+
o.hooks && (p = o.hooks.processAllTokens(p)), o.walkTokens && this.walkTokens(p, o.walkTokens);
|
|
4020
|
+
let d = (o.hooks ? o.hooks.provideParser(e) : e ? S.parse : S.parseInline)(p, o);
|
|
4021
|
+
return o.hooks && (d = o.hooks.postprocess(d)), d;
|
|
4022
|
+
} catch (a) {
|
|
4023
|
+
return i(a);
|
|
4024
|
+
}
|
|
4025
|
+
};
|
|
4026
|
+
}
|
|
4027
|
+
onError(e, t) {
|
|
4028
|
+
return (n) => {
|
|
4029
|
+
let r = n instanceof Error ? n : new Error(String(n));
|
|
4030
|
+
if (r.message += `
|
|
4031
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
4032
|
+
let s = "<p>An error occurred:</p><pre>" + P(r.message + "", true) + "</pre>";
|
|
4033
|
+
return t ? Promise.resolve(s) : s;
|
|
4034
|
+
}
|
|
4035
|
+
if (t)
|
|
4036
|
+
return Promise.reject(r);
|
|
4037
|
+
throw r;
|
|
4038
|
+
};
|
|
4039
|
+
}
|
|
4040
|
+
};
|
|
4041
|
+
var F = new se;
|
|
4042
|
+
function O(l, e) {
|
|
4043
|
+
return F.parse(l, e);
|
|
4044
|
+
}
|
|
4045
|
+
function sn(l, e) {
|
|
4046
|
+
return F.parseInline(l, e);
|
|
4047
|
+
}
|
|
4048
|
+
O.options = O.setOptions = function(l) {
|
|
4049
|
+
return F.setOptions(l), O.defaults = F.defaults, ge(O.defaults), O;
|
|
4050
|
+
};
|
|
4051
|
+
O.getDefaults = G;
|
|
4052
|
+
O.defaults = $;
|
|
4053
|
+
function on(...l) {
|
|
4054
|
+
return F.use(...l), O.defaults = F.defaults, ge(O.defaults), O;
|
|
4055
|
+
}
|
|
4056
|
+
O.use = on;
|
|
4057
|
+
O.walkTokens = function(l, e) {
|
|
4058
|
+
return F.walkTokens(l, e);
|
|
4059
|
+
};
|
|
4060
|
+
O.parseInline = sn;
|
|
4061
|
+
O.Parser = S;
|
|
4062
|
+
O.parser = S.parse;
|
|
4063
|
+
O.Renderer = M;
|
|
4064
|
+
O.TextRenderer = q;
|
|
4065
|
+
O.Lexer = y;
|
|
4066
|
+
O.lexer = y.lex;
|
|
4067
|
+
O.Tokenizer = C;
|
|
4068
|
+
O.Hooks = B;
|
|
4069
|
+
O.parse = O;
|
|
4070
|
+
var Xn = O.options;
|
|
4071
|
+
var Vn = O.setOptions;
|
|
4072
|
+
var Jn = O.walkTokens;
|
|
4073
|
+
var Yn = O.parseInline;
|
|
4074
|
+
var tr = S.parse;
|
|
4075
|
+
var nr = y.lex;
|
|
4076
|
+
|
|
4077
|
+
// src/ui/waiver-document.ts
|
|
4078
|
+
function renderWaiverDocumentBody(markdown) {
|
|
4079
|
+
const fragment = purify_default.sanitize(O.parse(markdown, { async: false, breaks: true }), {
|
|
4080
|
+
RETURN_DOM_FRAGMENT: true,
|
|
4081
|
+
ALLOWED_TAGS: [
|
|
4082
|
+
"a",
|
|
4083
|
+
"blockquote",
|
|
4084
|
+
"br",
|
|
4085
|
+
"code",
|
|
4086
|
+
"del",
|
|
4087
|
+
"em",
|
|
4088
|
+
"h1",
|
|
4089
|
+
"h2",
|
|
4090
|
+
"h3",
|
|
4091
|
+
"h4",
|
|
4092
|
+
"h5",
|
|
4093
|
+
"h6",
|
|
4094
|
+
"hr",
|
|
4095
|
+
"li",
|
|
4096
|
+
"ol",
|
|
4097
|
+
"p",
|
|
4098
|
+
"pre",
|
|
4099
|
+
"strong",
|
|
4100
|
+
"table",
|
|
4101
|
+
"tbody",
|
|
4102
|
+
"td",
|
|
4103
|
+
"th",
|
|
4104
|
+
"thead",
|
|
4105
|
+
"tr",
|
|
4106
|
+
"ul"
|
|
4107
|
+
],
|
|
4108
|
+
ALLOWED_ATTR: ["href", "start", "title"],
|
|
4109
|
+
ALLOW_ARIA_ATTR: false,
|
|
4110
|
+
ALLOW_DATA_ATTR: false
|
|
4111
|
+
});
|
|
4112
|
+
for (const link of fragment.querySelectorAll("a[href]")) {
|
|
4113
|
+
link.target = "_blank";
|
|
4114
|
+
link.rel = "noopener noreferrer";
|
|
4115
|
+
}
|
|
4116
|
+
return fragment;
|
|
4117
|
+
}
|
|
4118
|
+
export {
|
|
4119
|
+
renderWaiverDocumentBody
|
|
4120
|
+
};
|