@fairfox/polly 0.26.0 → 0.27.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/src/elysia/index.js +32 -6
- package/dist/src/elysia/index.js.map +3 -3
- package/dist/src/elysia/signaling-server-plugin.d.ts +20 -2
- package/dist/src/mesh.js +115 -34
- package/dist/src/mesh.js.map +7 -7
- package/dist/src/polly-ui/markdown.js +2410 -0
- package/dist/src/polly-ui/markdown.js.map +12 -0
- package/dist/src/shared/lib/mesh-signaling-client.d.ts +22 -1
- package/dist/src/shared/lib/mesh-state.d.ts +13 -11
- package/dist/src/shared/lib/mesh-webrtc-adapter.d.ts +44 -3
- package/dist/tools/test/src/browser/run.js +32 -6
- package/dist/tools/test/src/browser/run.js.map +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,2410 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toCommonJS = (from) => {
|
|
33
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
34
|
+
if (entry)
|
|
35
|
+
return entry;
|
|
36
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
37
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
38
|
+
for (var key of __getOwnPropNames(from))
|
|
39
|
+
if (!__hasOwnProp.call(entry, key))
|
|
40
|
+
__defProp(entry, key, {
|
|
41
|
+
get: __accessProp.bind(from, key),
|
|
42
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
__moduleCache.set(from, entry);
|
|
46
|
+
return entry;
|
|
47
|
+
};
|
|
48
|
+
var __moduleCache;
|
|
49
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
50
|
+
var __returnValue = (v) => v;
|
|
51
|
+
function __exportSetter(name, newValue) {
|
|
52
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
53
|
+
}
|
|
54
|
+
var __export = (target, all) => {
|
|
55
|
+
for (var name in all)
|
|
56
|
+
__defProp(target, name, {
|
|
57
|
+
get: all[name],
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
set: __exportSetter.bind(all, name)
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
64
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
65
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
66
|
+
}) : x)(function(x) {
|
|
67
|
+
if (typeof require !== "undefined")
|
|
68
|
+
return require.apply(this, arguments);
|
|
69
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// node_modules/.bun/dompurify@3.4.0/node_modules/dompurify/dist/purify.es.mjs
|
|
73
|
+
/*! @license DOMPurify 3.4.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.4.0/LICENSE */
|
|
74
|
+
var {
|
|
75
|
+
entries,
|
|
76
|
+
setPrototypeOf,
|
|
77
|
+
isFrozen,
|
|
78
|
+
getPrototypeOf,
|
|
79
|
+
getOwnPropertyDescriptor
|
|
80
|
+
} = Object;
|
|
81
|
+
var {
|
|
82
|
+
freeze,
|
|
83
|
+
seal,
|
|
84
|
+
create
|
|
85
|
+
} = Object;
|
|
86
|
+
var {
|
|
87
|
+
apply,
|
|
88
|
+
construct
|
|
89
|
+
} = typeof Reflect !== "undefined" && Reflect;
|
|
90
|
+
if (!freeze) {
|
|
91
|
+
freeze = function freeze2(x) {
|
|
92
|
+
return x;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (!seal) {
|
|
96
|
+
seal = function seal2(x) {
|
|
97
|
+
return x;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (!apply) {
|
|
101
|
+
apply = function apply2(func, thisArg) {
|
|
102
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2;_key < _len; _key++) {
|
|
103
|
+
args[_key - 2] = arguments[_key];
|
|
104
|
+
}
|
|
105
|
+
return func.apply(thisArg, args);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (!construct) {
|
|
109
|
+
construct = function construct2(Func) {
|
|
110
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1;_key2 < _len2; _key2++) {
|
|
111
|
+
args[_key2 - 1] = arguments[_key2];
|
|
112
|
+
}
|
|
113
|
+
return new Func(...args);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
var arrayForEach = unapply(Array.prototype.forEach);
|
|
117
|
+
var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
118
|
+
var arrayPop = unapply(Array.prototype.pop);
|
|
119
|
+
var arrayPush = unapply(Array.prototype.push);
|
|
120
|
+
var arraySplice = unapply(Array.prototype.splice);
|
|
121
|
+
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
122
|
+
var stringToString = unapply(String.prototype.toString);
|
|
123
|
+
var stringMatch = unapply(String.prototype.match);
|
|
124
|
+
var stringReplace = unapply(String.prototype.replace);
|
|
125
|
+
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
126
|
+
var stringTrim = unapply(String.prototype.trim);
|
|
127
|
+
var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
128
|
+
var regExpTest = unapply(RegExp.prototype.test);
|
|
129
|
+
var typeErrorCreate = unconstruct(TypeError);
|
|
130
|
+
function unapply(func) {
|
|
131
|
+
return function(thisArg) {
|
|
132
|
+
if (thisArg instanceof RegExp) {
|
|
133
|
+
thisArg.lastIndex = 0;
|
|
134
|
+
}
|
|
135
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1;_key3 < _len3; _key3++) {
|
|
136
|
+
args[_key3 - 1] = arguments[_key3];
|
|
137
|
+
}
|
|
138
|
+
return apply(func, thisArg, args);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function unconstruct(Func) {
|
|
142
|
+
return function() {
|
|
143
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0;_key4 < _len4; _key4++) {
|
|
144
|
+
args[_key4] = arguments[_key4];
|
|
145
|
+
}
|
|
146
|
+
return construct(Func, args);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function addToSet(set, array) {
|
|
150
|
+
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
|
|
151
|
+
if (setPrototypeOf) {
|
|
152
|
+
setPrototypeOf(set, null);
|
|
153
|
+
}
|
|
154
|
+
let l = array.length;
|
|
155
|
+
while (l--) {
|
|
156
|
+
let element = array[l];
|
|
157
|
+
if (typeof element === "string") {
|
|
158
|
+
const lcElement = transformCaseFunc(element);
|
|
159
|
+
if (lcElement !== element) {
|
|
160
|
+
if (!isFrozen(array)) {
|
|
161
|
+
array[l] = lcElement;
|
|
162
|
+
}
|
|
163
|
+
element = lcElement;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
set[element] = true;
|
|
167
|
+
}
|
|
168
|
+
return set;
|
|
169
|
+
}
|
|
170
|
+
function cleanArray(array) {
|
|
171
|
+
for (let index = 0;index < array.length; index++) {
|
|
172
|
+
const isPropertyExist = objectHasOwnProperty(array, index);
|
|
173
|
+
if (!isPropertyExist) {
|
|
174
|
+
array[index] = null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return array;
|
|
178
|
+
}
|
|
179
|
+
function clone(object) {
|
|
180
|
+
const newObject = create(null);
|
|
181
|
+
for (const [property, value] of entries(object)) {
|
|
182
|
+
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
183
|
+
if (isPropertyExist) {
|
|
184
|
+
if (Array.isArray(value)) {
|
|
185
|
+
newObject[property] = cleanArray(value);
|
|
186
|
+
} else if (value && typeof value === "object" && value.constructor === Object) {
|
|
187
|
+
newObject[property] = clone(value);
|
|
188
|
+
} else {
|
|
189
|
+
newObject[property] = value;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return newObject;
|
|
194
|
+
}
|
|
195
|
+
function lookupGetter(object, prop) {
|
|
196
|
+
while (object !== null) {
|
|
197
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
198
|
+
if (desc) {
|
|
199
|
+
if (desc.get) {
|
|
200
|
+
return unapply(desc.get);
|
|
201
|
+
}
|
|
202
|
+
if (typeof desc.value === "function") {
|
|
203
|
+
return unapply(desc.value);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
object = getPrototypeOf(object);
|
|
207
|
+
}
|
|
208
|
+
function fallbackValue() {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
return fallbackValue;
|
|
212
|
+
}
|
|
213
|
+
var html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
|
|
214
|
+
var svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
|
|
215
|
+
var svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
|
|
216
|
+
var svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
|
|
217
|
+
var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
|
|
218
|
+
var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
219
|
+
var text = freeze(["#text"]);
|
|
220
|
+
var html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]);
|
|
221
|
+
var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
|
|
222
|
+
var mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
|
|
223
|
+
var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
224
|
+
var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
|
|
225
|
+
var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
226
|
+
var TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm);
|
|
227
|
+
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
|
228
|
+
var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
|
229
|
+
var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
|
|
230
|
+
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
231
|
+
var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
|
|
232
|
+
var DOCTYPE_NAME = seal(/^html$/i);
|
|
233
|
+
var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
234
|
+
var EXPRESSIONS = /* @__PURE__ */ Object.freeze({
|
|
235
|
+
__proto__: null,
|
|
236
|
+
ARIA_ATTR,
|
|
237
|
+
ATTR_WHITESPACE,
|
|
238
|
+
CUSTOM_ELEMENT,
|
|
239
|
+
DATA_ATTR,
|
|
240
|
+
DOCTYPE_NAME,
|
|
241
|
+
ERB_EXPR,
|
|
242
|
+
IS_ALLOWED_URI,
|
|
243
|
+
IS_SCRIPT_OR_DATA,
|
|
244
|
+
MUSTACHE_EXPR,
|
|
245
|
+
TMPLIT_EXPR
|
|
246
|
+
});
|
|
247
|
+
var NODE_TYPE = {
|
|
248
|
+
element: 1,
|
|
249
|
+
text: 3,
|
|
250
|
+
progressingInstruction: 7,
|
|
251
|
+
comment: 8,
|
|
252
|
+
document: 9
|
|
253
|
+
};
|
|
254
|
+
var getGlobal = function getGlobal2() {
|
|
255
|
+
return typeof window === "undefined" ? null : window;
|
|
256
|
+
};
|
|
257
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
|
|
258
|
+
if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
let suffix = null;
|
|
262
|
+
const ATTR_NAME = "data-tt-policy-suffix";
|
|
263
|
+
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
|
|
264
|
+
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
265
|
+
}
|
|
266
|
+
const policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
|
267
|
+
try {
|
|
268
|
+
return trustedTypes.createPolicy(policyName, {
|
|
269
|
+
createHTML(html2) {
|
|
270
|
+
return html2;
|
|
271
|
+
},
|
|
272
|
+
createScriptURL(scriptUrl) {
|
|
273
|
+
return scriptUrl;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
} catch (_) {
|
|
277
|
+
console.warn("TrustedTypes policy " + policyName + " could not be created.");
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
var _createHooksMap = function _createHooksMap2() {
|
|
282
|
+
return {
|
|
283
|
+
afterSanitizeAttributes: [],
|
|
284
|
+
afterSanitizeElements: [],
|
|
285
|
+
afterSanitizeShadowDOM: [],
|
|
286
|
+
beforeSanitizeAttributes: [],
|
|
287
|
+
beforeSanitizeElements: [],
|
|
288
|
+
beforeSanitizeShadowDOM: [],
|
|
289
|
+
uponSanitizeAttribute: [],
|
|
290
|
+
uponSanitizeElement: [],
|
|
291
|
+
uponSanitizeShadowNode: []
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
function createDOMPurify() {
|
|
295
|
+
let window2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
296
|
+
const DOMPurify = (root) => createDOMPurify(root);
|
|
297
|
+
DOMPurify.version = "3.4.0";
|
|
298
|
+
DOMPurify.removed = [];
|
|
299
|
+
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
300
|
+
DOMPurify.isSupported = false;
|
|
301
|
+
return DOMPurify;
|
|
302
|
+
}
|
|
303
|
+
let {
|
|
304
|
+
document
|
|
305
|
+
} = window2;
|
|
306
|
+
const originalDocument = document;
|
|
307
|
+
const currentScript = originalDocument.currentScript;
|
|
308
|
+
const {
|
|
309
|
+
DocumentFragment,
|
|
310
|
+
HTMLTemplateElement,
|
|
311
|
+
Node,
|
|
312
|
+
Element,
|
|
313
|
+
NodeFilter,
|
|
314
|
+
NamedNodeMap = window2.NamedNodeMap || window2.MozNamedAttrMap,
|
|
315
|
+
HTMLFormElement,
|
|
316
|
+
DOMParser,
|
|
317
|
+
trustedTypes
|
|
318
|
+
} = window2;
|
|
319
|
+
const ElementPrototype = Element.prototype;
|
|
320
|
+
const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
|
|
321
|
+
const remove = lookupGetter(ElementPrototype, "remove");
|
|
322
|
+
const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
|
|
323
|
+
const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
|
|
324
|
+
const getParentNode = lookupGetter(ElementPrototype, "parentNode");
|
|
325
|
+
if (typeof HTMLTemplateElement === "function") {
|
|
326
|
+
const template = document.createElement("template");
|
|
327
|
+
if (template.content && template.content.ownerDocument) {
|
|
328
|
+
document = template.content.ownerDocument;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
let trustedTypesPolicy;
|
|
332
|
+
let emptyHTML = "";
|
|
333
|
+
const {
|
|
334
|
+
implementation,
|
|
335
|
+
createNodeIterator,
|
|
336
|
+
createDocumentFragment,
|
|
337
|
+
getElementsByTagName
|
|
338
|
+
} = document;
|
|
339
|
+
const {
|
|
340
|
+
importNode
|
|
341
|
+
} = originalDocument;
|
|
342
|
+
let hooks = _createHooksMap();
|
|
343
|
+
DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== undefined;
|
|
344
|
+
const {
|
|
345
|
+
MUSTACHE_EXPR: MUSTACHE_EXPR2,
|
|
346
|
+
ERB_EXPR: ERB_EXPR2,
|
|
347
|
+
TMPLIT_EXPR: TMPLIT_EXPR2,
|
|
348
|
+
DATA_ATTR: DATA_ATTR2,
|
|
349
|
+
ARIA_ATTR: ARIA_ATTR2,
|
|
350
|
+
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA2,
|
|
351
|
+
ATTR_WHITESPACE: ATTR_WHITESPACE2,
|
|
352
|
+
CUSTOM_ELEMENT: CUSTOM_ELEMENT2
|
|
353
|
+
} = EXPRESSIONS;
|
|
354
|
+
let {
|
|
355
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
356
|
+
} = EXPRESSIONS;
|
|
357
|
+
let ALLOWED_TAGS = null;
|
|
358
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
|
359
|
+
let ALLOWED_ATTR = null;
|
|
360
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
361
|
+
let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
362
|
+
tagNameCheck: {
|
|
363
|
+
writable: true,
|
|
364
|
+
configurable: false,
|
|
365
|
+
enumerable: true,
|
|
366
|
+
value: null
|
|
367
|
+
},
|
|
368
|
+
attributeNameCheck: {
|
|
369
|
+
writable: true,
|
|
370
|
+
configurable: false,
|
|
371
|
+
enumerable: true,
|
|
372
|
+
value: null
|
|
373
|
+
},
|
|
374
|
+
allowCustomizedBuiltInElements: {
|
|
375
|
+
writable: true,
|
|
376
|
+
configurable: false,
|
|
377
|
+
enumerable: true,
|
|
378
|
+
value: false
|
|
379
|
+
}
|
|
380
|
+
}));
|
|
381
|
+
let FORBID_TAGS = null;
|
|
382
|
+
let FORBID_ATTR = null;
|
|
383
|
+
const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
384
|
+
tagCheck: {
|
|
385
|
+
writable: true,
|
|
386
|
+
configurable: false,
|
|
387
|
+
enumerable: true,
|
|
388
|
+
value: null
|
|
389
|
+
},
|
|
390
|
+
attributeCheck: {
|
|
391
|
+
writable: true,
|
|
392
|
+
configurable: false,
|
|
393
|
+
enumerable: true,
|
|
394
|
+
value: null
|
|
395
|
+
}
|
|
396
|
+
}));
|
|
397
|
+
let ALLOW_ARIA_ATTR = true;
|
|
398
|
+
let ALLOW_DATA_ATTR = true;
|
|
399
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
400
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
401
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
402
|
+
let SAFE_FOR_XML = true;
|
|
403
|
+
let WHOLE_DOCUMENT = false;
|
|
404
|
+
let SET_CONFIG = false;
|
|
405
|
+
let FORCE_BODY = false;
|
|
406
|
+
let RETURN_DOM = false;
|
|
407
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
408
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
409
|
+
let SANITIZE_DOM = true;
|
|
410
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
411
|
+
const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
|
|
412
|
+
let KEEP_CONTENT = true;
|
|
413
|
+
let IN_PLACE = false;
|
|
414
|
+
let USE_PROFILES = {};
|
|
415
|
+
let FORBID_CONTENTS = null;
|
|
416
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
|
|
417
|
+
let DATA_URI_TAGS = null;
|
|
418
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
419
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
420
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
|
|
421
|
+
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
422
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
423
|
+
const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
424
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
425
|
+
let IS_EMPTY_INPUT = false;
|
|
426
|
+
let ALLOWED_NAMESPACES = null;
|
|
427
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
428
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
|
|
429
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
|
|
430
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
|
|
431
|
+
let PARSER_MEDIA_TYPE = null;
|
|
432
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
433
|
+
const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
|
|
434
|
+
let transformCaseFunc = null;
|
|
435
|
+
let CONFIG = null;
|
|
436
|
+
const formElement = document.createElement("form");
|
|
437
|
+
const isRegexOrFunction = function isRegexOrFunction2(testValue) {
|
|
438
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
439
|
+
};
|
|
440
|
+
const _parseConfig = function _parseConfig2() {
|
|
441
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
442
|
+
if (CONFIG && CONFIG === cfg) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (!cfg || typeof cfg !== "object") {
|
|
446
|
+
cfg = {};
|
|
447
|
+
}
|
|
448
|
+
cfg = clone(cfg);
|
|
449
|
+
PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
450
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
451
|
+
ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
452
|
+
ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
453
|
+
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
454
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
455
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
|
456
|
+
FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
457
|
+
FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
|
|
458
|
+
FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
|
|
459
|
+
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES : false;
|
|
460
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
461
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
462
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
|
463
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
|
|
464
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
|
|
465
|
+
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
|
|
466
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
|
|
467
|
+
RETURN_DOM = cfg.RETURN_DOM || false;
|
|
468
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
|
|
469
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
|
|
470
|
+
FORCE_BODY = cfg.FORCE_BODY || false;
|
|
471
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
|
|
472
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
|
473
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
|
474
|
+
IN_PLACE = cfg.IN_PLACE || false;
|
|
475
|
+
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
|
476
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
477
|
+
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
|
|
478
|
+
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
|
|
479
|
+
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || create(null);
|
|
480
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
481
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
482
|
+
}
|
|
483
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
|
484
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
|
|
485
|
+
}
|
|
486
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
|
|
487
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
|
|
488
|
+
}
|
|
489
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
490
|
+
ALLOW_DATA_ATTR = false;
|
|
491
|
+
}
|
|
492
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
493
|
+
RETURN_DOM = true;
|
|
494
|
+
}
|
|
495
|
+
if (USE_PROFILES) {
|
|
496
|
+
ALLOWED_TAGS = addToSet({}, text);
|
|
497
|
+
ALLOWED_ATTR = create(null);
|
|
498
|
+
if (USE_PROFILES.html === true) {
|
|
499
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
500
|
+
addToSet(ALLOWED_ATTR, html);
|
|
501
|
+
}
|
|
502
|
+
if (USE_PROFILES.svg === true) {
|
|
503
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
504
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
505
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
506
|
+
}
|
|
507
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
508
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
509
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
510
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
511
|
+
}
|
|
512
|
+
if (USE_PROFILES.mathMl === true) {
|
|
513
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
514
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
515
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
519
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
520
|
+
if (cfg.ADD_TAGS) {
|
|
521
|
+
if (typeof cfg.ADD_TAGS === "function") {
|
|
522
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
523
|
+
} else {
|
|
524
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
525
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
526
|
+
}
|
|
527
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (cfg.ADD_ATTR) {
|
|
531
|
+
if (typeof cfg.ADD_ATTR === "function") {
|
|
532
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
533
|
+
} else {
|
|
534
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
535
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
536
|
+
}
|
|
537
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
541
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
542
|
+
}
|
|
543
|
+
if (cfg.FORBID_CONTENTS) {
|
|
544
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
545
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
546
|
+
}
|
|
547
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
548
|
+
}
|
|
549
|
+
if (cfg.ADD_FORBID_CONTENTS) {
|
|
550
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
551
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
552
|
+
}
|
|
553
|
+
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
|
|
554
|
+
}
|
|
555
|
+
if (KEEP_CONTENT) {
|
|
556
|
+
ALLOWED_TAGS["#text"] = true;
|
|
557
|
+
}
|
|
558
|
+
if (WHOLE_DOCUMENT) {
|
|
559
|
+
addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
|
|
560
|
+
}
|
|
561
|
+
if (ALLOWED_TAGS.table) {
|
|
562
|
+
addToSet(ALLOWED_TAGS, ["tbody"]);
|
|
563
|
+
delete FORBID_TAGS.tbody;
|
|
564
|
+
}
|
|
565
|
+
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
566
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
|
|
567
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
568
|
+
}
|
|
569
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
|
|
570
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
571
|
+
}
|
|
572
|
+
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
573
|
+
emptyHTML = trustedTypesPolicy.createHTML("");
|
|
574
|
+
} else {
|
|
575
|
+
if (trustedTypesPolicy === undefined) {
|
|
576
|
+
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
577
|
+
}
|
|
578
|
+
if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
|
|
579
|
+
emptyHTML = trustedTypesPolicy.createHTML("");
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (freeze) {
|
|
583
|
+
freeze(cfg);
|
|
584
|
+
}
|
|
585
|
+
CONFIG = cfg;
|
|
586
|
+
};
|
|
587
|
+
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
588
|
+
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
589
|
+
const _checkValidNamespace = function _checkValidNamespace2(element) {
|
|
590
|
+
let parent = getParentNode(element);
|
|
591
|
+
if (!parent || !parent.tagName) {
|
|
592
|
+
parent = {
|
|
593
|
+
namespaceURI: NAMESPACE,
|
|
594
|
+
tagName: "template"
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
const tagName = stringToLowerCase(element.tagName);
|
|
598
|
+
const parentTagName = stringToLowerCase(parent.tagName);
|
|
599
|
+
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
600
|
+
return false;
|
|
601
|
+
}
|
|
602
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
603
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
604
|
+
return tagName === "svg";
|
|
605
|
+
}
|
|
606
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
607
|
+
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
608
|
+
}
|
|
609
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
610
|
+
}
|
|
611
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
612
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
613
|
+
return tagName === "math";
|
|
614
|
+
}
|
|
615
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
616
|
+
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
617
|
+
}
|
|
618
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
619
|
+
}
|
|
620
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
621
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
628
|
+
}
|
|
629
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
630
|
+
return true;
|
|
631
|
+
}
|
|
632
|
+
return false;
|
|
633
|
+
};
|
|
634
|
+
const _forceRemove = function _forceRemove2(node) {
|
|
635
|
+
arrayPush(DOMPurify.removed, {
|
|
636
|
+
element: node
|
|
637
|
+
});
|
|
638
|
+
try {
|
|
639
|
+
getParentNode(node).removeChild(node);
|
|
640
|
+
} catch (_) {
|
|
641
|
+
remove(node);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
const _removeAttribute = function _removeAttribute2(name, element) {
|
|
645
|
+
try {
|
|
646
|
+
arrayPush(DOMPurify.removed, {
|
|
647
|
+
attribute: element.getAttributeNode(name),
|
|
648
|
+
from: element
|
|
649
|
+
});
|
|
650
|
+
} catch (_) {
|
|
651
|
+
arrayPush(DOMPurify.removed, {
|
|
652
|
+
attribute: null,
|
|
653
|
+
from: element
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
element.removeAttribute(name);
|
|
657
|
+
if (name === "is") {
|
|
658
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
659
|
+
try {
|
|
660
|
+
_forceRemove(element);
|
|
661
|
+
} catch (_) {}
|
|
662
|
+
} else {
|
|
663
|
+
try {
|
|
664
|
+
element.setAttribute(name, "");
|
|
665
|
+
} catch (_) {}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
const _initDocument = function _initDocument2(dirty) {
|
|
670
|
+
let doc = null;
|
|
671
|
+
let leadingWhitespace = null;
|
|
672
|
+
if (FORCE_BODY) {
|
|
673
|
+
dirty = "<remove></remove>" + dirty;
|
|
674
|
+
} else {
|
|
675
|
+
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
676
|
+
leadingWhitespace = matches && matches[0];
|
|
677
|
+
}
|
|
678
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
|
|
679
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
|
|
680
|
+
}
|
|
681
|
+
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
682
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
683
|
+
try {
|
|
684
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
685
|
+
} catch (_) {}
|
|
686
|
+
}
|
|
687
|
+
if (!doc || !doc.documentElement) {
|
|
688
|
+
doc = implementation.createDocument(NAMESPACE, "template", null);
|
|
689
|
+
try {
|
|
690
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
691
|
+
} catch (_) {}
|
|
692
|
+
}
|
|
693
|
+
const body = doc.body || doc.documentElement;
|
|
694
|
+
if (dirty && leadingWhitespace) {
|
|
695
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
696
|
+
}
|
|
697
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
698
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
|
|
699
|
+
}
|
|
700
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
701
|
+
};
|
|
702
|
+
const _createNodeIterator = function _createNodeIterator2(root) {
|
|
703
|
+
return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
704
|
+
};
|
|
705
|
+
const _isClobbered = function _isClobbered2(element) {
|
|
706
|
+
return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
|
|
707
|
+
};
|
|
708
|
+
const _isNode = function _isNode2(value) {
|
|
709
|
+
return typeof Node === "function" && value instanceof Node;
|
|
710
|
+
};
|
|
711
|
+
function _executeHooks(hooks2, currentNode, data) {
|
|
712
|
+
arrayForEach(hooks2, (hook) => {
|
|
713
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
const _sanitizeElements = function _sanitizeElements2(currentNode) {
|
|
717
|
+
let content = null;
|
|
718
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
719
|
+
if (_isClobbered(currentNode)) {
|
|
720
|
+
_forceRemove(currentNode);
|
|
721
|
+
return true;
|
|
722
|
+
}
|
|
723
|
+
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
724
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
725
|
+
tagName,
|
|
726
|
+
allowedTags: ALLOWED_TAGS
|
|
727
|
+
});
|
|
728
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
|
|
729
|
+
_forceRemove(currentNode);
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
732
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
|
|
733
|
+
_forceRemove(currentNode);
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
737
|
+
_forceRemove(currentNode);
|
|
738
|
+
return true;
|
|
739
|
+
}
|
|
740
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
741
|
+
_forceRemove(currentNode);
|
|
742
|
+
return true;
|
|
743
|
+
}
|
|
744
|
+
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
745
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
746
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
750
|
+
return false;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
754
|
+
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
755
|
+
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
756
|
+
if (childNodes && parentNode) {
|
|
757
|
+
const childCount = childNodes.length;
|
|
758
|
+
for (let i = childCount - 1;i >= 0; --i) {
|
|
759
|
+
const childClone = cloneNode(childNodes[i], true);
|
|
760
|
+
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
761
|
+
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
_forceRemove(currentNode);
|
|
766
|
+
return true;
|
|
767
|
+
}
|
|
768
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
769
|
+
_forceRemove(currentNode);
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
772
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
|
773
|
+
_forceRemove(currentNode);
|
|
774
|
+
return true;
|
|
775
|
+
}
|
|
776
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
777
|
+
content = currentNode.textContent;
|
|
778
|
+
arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
|
|
779
|
+
content = stringReplace(content, expr, " ");
|
|
780
|
+
});
|
|
781
|
+
if (currentNode.textContent !== content) {
|
|
782
|
+
arrayPush(DOMPurify.removed, {
|
|
783
|
+
element: currentNode.cloneNode()
|
|
784
|
+
});
|
|
785
|
+
currentNode.textContent = content;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
789
|
+
return false;
|
|
790
|
+
};
|
|
791
|
+
const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
|
|
792
|
+
if (FORBID_ATTR[lcName]) {
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && ((value in document) || (value in formElement))) {
|
|
796
|
+
return false;
|
|
797
|
+
}
|
|
798
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName))
|
|
799
|
+
;
|
|
800
|
+
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName))
|
|
801
|
+
;
|
|
802
|
+
else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag))
|
|
803
|
+
;
|
|
804
|
+
else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
805
|
+
if (_isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value)))
|
|
806
|
+
;
|
|
807
|
+
else {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName])
|
|
811
|
+
;
|
|
812
|
+
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE2, "")))
|
|
813
|
+
;
|
|
814
|
+
else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag])
|
|
815
|
+
;
|
|
816
|
+
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA2, stringReplace(value, ATTR_WHITESPACE2, "")))
|
|
817
|
+
;
|
|
818
|
+
else if (value) {
|
|
819
|
+
return false;
|
|
820
|
+
} else
|
|
821
|
+
;
|
|
822
|
+
return true;
|
|
823
|
+
};
|
|
824
|
+
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
825
|
+
return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT2);
|
|
826
|
+
};
|
|
827
|
+
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
|
828
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
829
|
+
const {
|
|
830
|
+
attributes
|
|
831
|
+
} = currentNode;
|
|
832
|
+
if (!attributes || _isClobbered(currentNode)) {
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
const hookEvent = {
|
|
836
|
+
attrName: "",
|
|
837
|
+
attrValue: "",
|
|
838
|
+
keepAttr: true,
|
|
839
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
840
|
+
forceKeepAttr: undefined
|
|
841
|
+
};
|
|
842
|
+
let l = attributes.length;
|
|
843
|
+
while (l--) {
|
|
844
|
+
const attr = attributes[l];
|
|
845
|
+
const {
|
|
846
|
+
name,
|
|
847
|
+
namespaceURI,
|
|
848
|
+
value: attrValue
|
|
849
|
+
} = attr;
|
|
850
|
+
const lcName = transformCaseFunc(name);
|
|
851
|
+
const initValue = attrValue;
|
|
852
|
+
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
853
|
+
hookEvent.attrName = lcName;
|
|
854
|
+
hookEvent.attrValue = value;
|
|
855
|
+
hookEvent.keepAttr = true;
|
|
856
|
+
hookEvent.forceKeepAttr = undefined;
|
|
857
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
858
|
+
value = hookEvent.attrValue;
|
|
859
|
+
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
|
|
860
|
+
_removeAttribute(name, currentNode);
|
|
861
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
862
|
+
}
|
|
863
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
864
|
+
_removeAttribute(name, currentNode);
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
if (lcName === "attributename" && stringMatch(value, "href")) {
|
|
868
|
+
_removeAttribute(name, currentNode);
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
if (hookEvent.forceKeepAttr) {
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
874
|
+
if (!hookEvent.keepAttr) {
|
|
875
|
+
_removeAttribute(name, currentNode);
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
|
879
|
+
_removeAttribute(name, currentNode);
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
883
|
+
arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
|
|
884
|
+
value = stringReplace(value, expr, " ");
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
888
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
889
|
+
_removeAttribute(name, currentNode);
|
|
890
|
+
continue;
|
|
891
|
+
}
|
|
892
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
|
|
893
|
+
if (namespaceURI)
|
|
894
|
+
;
|
|
895
|
+
else {
|
|
896
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
897
|
+
case "TrustedHTML": {
|
|
898
|
+
value = trustedTypesPolicy.createHTML(value);
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
901
|
+
case "TrustedScriptURL": {
|
|
902
|
+
value = trustedTypesPolicy.createScriptURL(value);
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
if (value !== initValue) {
|
|
909
|
+
try {
|
|
910
|
+
if (namespaceURI) {
|
|
911
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
912
|
+
} else {
|
|
913
|
+
currentNode.setAttribute(name, value);
|
|
914
|
+
}
|
|
915
|
+
if (_isClobbered(currentNode)) {
|
|
916
|
+
_forceRemove(currentNode);
|
|
917
|
+
} else {
|
|
918
|
+
arrayPop(DOMPurify.removed);
|
|
919
|
+
}
|
|
920
|
+
} catch (_) {
|
|
921
|
+
_removeAttribute(name, currentNode);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
926
|
+
};
|
|
927
|
+
const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
|
|
928
|
+
let shadowNode = null;
|
|
929
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
930
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
931
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
932
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
933
|
+
_sanitizeElements(shadowNode);
|
|
934
|
+
_sanitizeAttributes(shadowNode);
|
|
935
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
936
|
+
_sanitizeShadowDOM2(shadowNode.content);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
940
|
+
};
|
|
941
|
+
DOMPurify.sanitize = function(dirty) {
|
|
942
|
+
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
943
|
+
let body = null;
|
|
944
|
+
let importedNode = null;
|
|
945
|
+
let currentNode = null;
|
|
946
|
+
let returnNode = null;
|
|
947
|
+
IS_EMPTY_INPUT = !dirty;
|
|
948
|
+
if (IS_EMPTY_INPUT) {
|
|
949
|
+
dirty = "<!-->";
|
|
950
|
+
}
|
|
951
|
+
if (typeof dirty !== "string" && !_isNode(dirty)) {
|
|
952
|
+
if (typeof dirty.toString === "function") {
|
|
953
|
+
dirty = dirty.toString();
|
|
954
|
+
if (typeof dirty !== "string") {
|
|
955
|
+
throw typeErrorCreate("dirty is not a string, aborting");
|
|
956
|
+
}
|
|
957
|
+
} else {
|
|
958
|
+
throw typeErrorCreate("toString is not a function");
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
if (!DOMPurify.isSupported) {
|
|
962
|
+
return dirty;
|
|
963
|
+
}
|
|
964
|
+
if (!SET_CONFIG) {
|
|
965
|
+
_parseConfig(cfg);
|
|
966
|
+
}
|
|
967
|
+
DOMPurify.removed = [];
|
|
968
|
+
if (typeof dirty === "string") {
|
|
969
|
+
IN_PLACE = false;
|
|
970
|
+
}
|
|
971
|
+
if (IN_PLACE) {
|
|
972
|
+
if (dirty.nodeName) {
|
|
973
|
+
const tagName = transformCaseFunc(dirty.nodeName);
|
|
974
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
975
|
+
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
} else if (dirty instanceof Node) {
|
|
979
|
+
body = _initDocument("<!---->");
|
|
980
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
981
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
|
|
982
|
+
body = importedNode;
|
|
983
|
+
} else if (importedNode.nodeName === "HTML") {
|
|
984
|
+
body = importedNode;
|
|
985
|
+
} else {
|
|
986
|
+
body.appendChild(importedNode);
|
|
987
|
+
}
|
|
988
|
+
} else {
|
|
989
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) {
|
|
990
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
991
|
+
}
|
|
992
|
+
body = _initDocument(dirty);
|
|
993
|
+
if (!body) {
|
|
994
|
+
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
if (body && FORCE_BODY) {
|
|
998
|
+
_forceRemove(body.firstChild);
|
|
999
|
+
}
|
|
1000
|
+
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
|
1001
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
1002
|
+
_sanitizeElements(currentNode);
|
|
1003
|
+
_sanitizeAttributes(currentNode);
|
|
1004
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
1005
|
+
_sanitizeShadowDOM2(currentNode.content);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
if (IN_PLACE) {
|
|
1009
|
+
return dirty;
|
|
1010
|
+
}
|
|
1011
|
+
if (RETURN_DOM) {
|
|
1012
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1013
|
+
body.normalize();
|
|
1014
|
+
let html2 = body.innerHTML;
|
|
1015
|
+
arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
|
|
1016
|
+
html2 = stringReplace(html2, expr, " ");
|
|
1017
|
+
});
|
|
1018
|
+
body.innerHTML = html2;
|
|
1019
|
+
}
|
|
1020
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
1021
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
1022
|
+
while (body.firstChild) {
|
|
1023
|
+
returnNode.appendChild(body.firstChild);
|
|
1024
|
+
}
|
|
1025
|
+
} else {
|
|
1026
|
+
returnNode = body;
|
|
1027
|
+
}
|
|
1028
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
|
1029
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
1030
|
+
}
|
|
1031
|
+
return returnNode;
|
|
1032
|
+
}
|
|
1033
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
1034
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
1035
|
+
serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + `>
|
|
1036
|
+
` + serializedHTML;
|
|
1037
|
+
}
|
|
1038
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1039
|
+
arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
|
|
1040
|
+
serializedHTML = stringReplace(serializedHTML, expr, " ");
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
1044
|
+
};
|
|
1045
|
+
DOMPurify.setConfig = function() {
|
|
1046
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1047
|
+
_parseConfig(cfg);
|
|
1048
|
+
SET_CONFIG = true;
|
|
1049
|
+
};
|
|
1050
|
+
DOMPurify.clearConfig = function() {
|
|
1051
|
+
CONFIG = null;
|
|
1052
|
+
SET_CONFIG = false;
|
|
1053
|
+
};
|
|
1054
|
+
DOMPurify.isValidAttribute = function(tag, attr, value) {
|
|
1055
|
+
if (!CONFIG) {
|
|
1056
|
+
_parseConfig({});
|
|
1057
|
+
}
|
|
1058
|
+
const lcTag = transformCaseFunc(tag);
|
|
1059
|
+
const lcName = transformCaseFunc(attr);
|
|
1060
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
1061
|
+
};
|
|
1062
|
+
DOMPurify.addHook = function(entryPoint, hookFunction) {
|
|
1063
|
+
if (typeof hookFunction !== "function") {
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
1067
|
+
};
|
|
1068
|
+
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
1069
|
+
if (hookFunction !== undefined) {
|
|
1070
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
1071
|
+
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
1072
|
+
}
|
|
1073
|
+
return arrayPop(hooks[entryPoint]);
|
|
1074
|
+
};
|
|
1075
|
+
DOMPurify.removeHooks = function(entryPoint) {
|
|
1076
|
+
hooks[entryPoint] = [];
|
|
1077
|
+
};
|
|
1078
|
+
DOMPurify.removeAllHooks = function() {
|
|
1079
|
+
hooks = _createHooksMap();
|
|
1080
|
+
};
|
|
1081
|
+
return DOMPurify;
|
|
1082
|
+
}
|
|
1083
|
+
var purify = createDOMPurify();
|
|
1084
|
+
|
|
1085
|
+
// node_modules/.bun/marked@18.0.1/node_modules/marked/lib/marked.esm.js
|
|
1086
|
+
function z() {
|
|
1087
|
+
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
1088
|
+
}
|
|
1089
|
+
var T = z();
|
|
1090
|
+
function G(l) {
|
|
1091
|
+
T = l;
|
|
1092
|
+
}
|
|
1093
|
+
var _ = { exec: () => null };
|
|
1094
|
+
function k(l, e = "") {
|
|
1095
|
+
let t = typeof l == "string" ? l : l.source, n = { replace: (r, i) => {
|
|
1096
|
+
let s = typeof i == "string" ? i : i.source;
|
|
1097
|
+
return s = s.replace(m.caret, "$1"), t = t.replace(r, s), n;
|
|
1098
|
+
}, getRegex: () => new RegExp(t, e) };
|
|
1099
|
+
return n;
|
|
1100
|
+
}
|
|
1101
|
+
var Re = ((l = "") => {
|
|
1102
|
+
try {
|
|
1103
|
+
return !!new RegExp("(?<=1)(?<!1)" + l);
|
|
1104
|
+
} catch {
|
|
1105
|
+
return false;
|
|
1106
|
+
}
|
|
1107
|
+
})();
|
|
1108
|
+
var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, 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, 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: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}#`), htmlBeginRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}>`) };
|
|
1109
|
+
var Te = /^(?:[ \t]*(?:\n|$))+/;
|
|
1110
|
+
var Oe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
1111
|
+
var we = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
1112
|
+
var C = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
1113
|
+
var ye = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
1114
|
+
var Q = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
1115
|
+
var ie = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
1116
|
+
var oe = k(ie).replace(/bull/g, Q).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
1117
|
+
var Pe = k(ie).replace(/bull/g, Q).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
1118
|
+
var j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
1119
|
+
var Se = /^[^\n]+/;
|
|
1120
|
+
var F = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
1121
|
+
var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", F).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
1122
|
+
var Le = k(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Q).getRegex();
|
|
1123
|
+
var v = "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";
|
|
1124
|
+
var U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
1125
|
+
var _e = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))", "i").replace("comment", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
1126
|
+
var ae = k(j).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
|
|
1127
|
+
var Me = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex();
|
|
1128
|
+
var K = { blockquote: Me, code: Oe, def: $e, fences: we, heading: ye, hr: C, html: _e, lheading: oe, list: Le, newline: Te, paragraph: ae, table: _, text: Se };
|
|
1129
|
+
var re = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}\t)[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
|
|
1130
|
+
var ze = { ...K, lheading: Pe, table: re, paragraph: k(j).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() };
|
|
1131
|
+
var Ee = { ...K, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(j).replace("hr", C).replace("heading", ` *#{1,6} *[^
|
|
1132
|
+
]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
1133
|
+
var Ie = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
1134
|
+
var Ae = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
1135
|
+
var le = /^( {2,}|\\)\n(?!\s*$)/;
|
|
1136
|
+
var Ce = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
1137
|
+
var E = /[\p{P}\p{S}]/u;
|
|
1138
|
+
var H = /[\s\p{P}\p{S}]/u;
|
|
1139
|
+
var W = /[^\s\p{P}\p{S}]/u;
|
|
1140
|
+
var Be = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, H).getRegex();
|
|
1141
|
+
var ue = /(?!~)[\p{P}\p{S}]/u;
|
|
1142
|
+
var De = /(?!~)[\s\p{P}\p{S}]/u;
|
|
1143
|
+
var qe = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
1144
|
+
var ve = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Re ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
1145
|
+
var pe = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
1146
|
+
var He = k(pe, "u").replace(/punct/g, E).getRegex();
|
|
1147
|
+
var Ze = k(pe, "u").replace(/punct/g, ue).getRegex();
|
|
1148
|
+
var ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
1149
|
+
var Ge = k(ce, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1150
|
+
var Ne = k(ce, "gu").replace(/notPunctSpace/g, qe).replace(/punctSpace/g, De).replace(/punct/g, ue).getRegex();
|
|
1151
|
+
var Qe = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1152
|
+
var je = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, E).getRegex();
|
|
1153
|
+
var Fe = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
1154
|
+
var Ue = k(Fe, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1155
|
+
var Ke = k(/\\(punct)/, "gu").replace(/punct/g, E).getRegex();
|
|
1156
|
+
var We = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
1157
|
+
var Xe = k(U).replace("(?:-->|$)", "-->").getRegex();
|
|
1158
|
+
var Je = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Xe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
1159
|
+
var q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
|
1160
|
+
var Ve = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
1161
|
+
var he = k(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", F).getRegex();
|
|
1162
|
+
var ke = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex();
|
|
1163
|
+
var Ye = k("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
|
|
1164
|
+
var se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
1165
|
+
var X = { _backpedal: _, anyPunctuation: Ke, autolink: We, blockSkip: ve, br: le, code: Ae, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: He, emStrongRDelimAst: Ge, emStrongRDelimUnd: Qe, escape: Ie, link: Ve, nolink: ke, punctuation: Be, reflink: he, reflinkSearch: Ye, tag: Je, text: Ce, url: _ };
|
|
1166
|
+
var et = { ...X, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
|
|
1167
|
+
var N = { ...X, emStrongRDelimAst: Ne, emStrongLDelim: Ze, delLDelim: je, delRDelim: Ue, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", se).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", se).getRegex() };
|
|
1168
|
+
var tt = { ...N, br: k(le).replace("{2,}", "*").getRegex(), text: k(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
1169
|
+
var B = { normal: K, gfm: ze, pedantic: Ee };
|
|
1170
|
+
var I = { normal: X, gfm: N, breaks: tt, pedantic: et };
|
|
1171
|
+
var nt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
1172
|
+
var de = (l) => nt[l];
|
|
1173
|
+
function O(l, e) {
|
|
1174
|
+
if (e) {
|
|
1175
|
+
if (m.escapeTest.test(l))
|
|
1176
|
+
return l.replace(m.escapeReplace, de);
|
|
1177
|
+
} else if (m.escapeTestNoEncode.test(l))
|
|
1178
|
+
return l.replace(m.escapeReplaceNoEncode, de);
|
|
1179
|
+
return l;
|
|
1180
|
+
}
|
|
1181
|
+
function J(l) {
|
|
1182
|
+
try {
|
|
1183
|
+
l = encodeURI(l).replace(m.percentDecode, "%");
|
|
1184
|
+
} catch {
|
|
1185
|
+
return null;
|
|
1186
|
+
}
|
|
1187
|
+
return l;
|
|
1188
|
+
}
|
|
1189
|
+
function V(l, e) {
|
|
1190
|
+
let t = l.replace(m.findPipe, (i, s, a) => {
|
|
1191
|
+
let o = false, u = s;
|
|
1192
|
+
for (;--u >= 0 && a[u] === "\\"; )
|
|
1193
|
+
o = !o;
|
|
1194
|
+
return o ? "|" : " |";
|
|
1195
|
+
}), n = t.split(m.splitPipe), r = 0;
|
|
1196
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
|
|
1197
|
+
if (n.length > e)
|
|
1198
|
+
n.splice(e);
|
|
1199
|
+
else
|
|
1200
|
+
for (;n.length < e; )
|
|
1201
|
+
n.push("");
|
|
1202
|
+
for (;r < n.length; r++)
|
|
1203
|
+
n[r] = n[r].trim().replace(m.slashPipe, "|");
|
|
1204
|
+
return n;
|
|
1205
|
+
}
|
|
1206
|
+
function $(l, e, t) {
|
|
1207
|
+
let n = l.length;
|
|
1208
|
+
if (n === 0)
|
|
1209
|
+
return "";
|
|
1210
|
+
let r = 0;
|
|
1211
|
+
for (;r < n; ) {
|
|
1212
|
+
let i = l.charAt(n - r - 1);
|
|
1213
|
+
if (i === e && !t)
|
|
1214
|
+
r++;
|
|
1215
|
+
else if (i !== e && t)
|
|
1216
|
+
r++;
|
|
1217
|
+
else
|
|
1218
|
+
break;
|
|
1219
|
+
}
|
|
1220
|
+
return l.slice(0, n - r);
|
|
1221
|
+
}
|
|
1222
|
+
function Y(l) {
|
|
1223
|
+
let e = l.split(`
|
|
1224
|
+
`), t = e.length - 1;
|
|
1225
|
+
for (;t >= 0 && !e[t].trim(); )
|
|
1226
|
+
t--;
|
|
1227
|
+
return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
|
|
1228
|
+
`);
|
|
1229
|
+
}
|
|
1230
|
+
function ge(l, e) {
|
|
1231
|
+
if (l.indexOf(e[1]) === -1)
|
|
1232
|
+
return -1;
|
|
1233
|
+
let t = 0;
|
|
1234
|
+
for (let n = 0;n < l.length; n++)
|
|
1235
|
+
if (l[n] === "\\")
|
|
1236
|
+
n++;
|
|
1237
|
+
else if (l[n] === e[0])
|
|
1238
|
+
t++;
|
|
1239
|
+
else if (l[n] === e[1] && (t--, t < 0))
|
|
1240
|
+
return n;
|
|
1241
|
+
return t > 0 ? -2 : -1;
|
|
1242
|
+
}
|
|
1243
|
+
function fe(l, e = 0) {
|
|
1244
|
+
let t = e, n = "";
|
|
1245
|
+
for (let r of l)
|
|
1246
|
+
if (r === "\t") {
|
|
1247
|
+
let i = 4 - t % 4;
|
|
1248
|
+
n += " ".repeat(i), t += i;
|
|
1249
|
+
} else
|
|
1250
|
+
n += r, t++;
|
|
1251
|
+
return n;
|
|
1252
|
+
}
|
|
1253
|
+
function me(l, e, t, n, r) {
|
|
1254
|
+
let i = e.href, s = e.title || null, a = l[1].replace(r.other.outputLinkReplace, "$1");
|
|
1255
|
+
n.state.inLink = true;
|
|
1256
|
+
let o = { type: l[0].charAt(0) === "!" ? "image" : "link", raw: t, href: i, title: s, text: a, tokens: n.inlineTokens(a) };
|
|
1257
|
+
return n.state.inLink = false, o;
|
|
1258
|
+
}
|
|
1259
|
+
function rt(l, e, t) {
|
|
1260
|
+
let n = l.match(t.other.indentCodeCompensation);
|
|
1261
|
+
if (n === null)
|
|
1262
|
+
return e;
|
|
1263
|
+
let r = n[1];
|
|
1264
|
+
return e.split(`
|
|
1265
|
+
`).map((i) => {
|
|
1266
|
+
let s = i.match(t.other.beginningSpace);
|
|
1267
|
+
if (s === null)
|
|
1268
|
+
return i;
|
|
1269
|
+
let [a] = s;
|
|
1270
|
+
return a.length >= r.length ? i.slice(r.length) : i;
|
|
1271
|
+
}).join(`
|
|
1272
|
+
`);
|
|
1273
|
+
}
|
|
1274
|
+
var w = class {
|
|
1275
|
+
options;
|
|
1276
|
+
rules;
|
|
1277
|
+
lexer;
|
|
1278
|
+
constructor(e) {
|
|
1279
|
+
this.options = e || T;
|
|
1280
|
+
}
|
|
1281
|
+
space(e) {
|
|
1282
|
+
let t = this.rules.block.newline.exec(e);
|
|
1283
|
+
if (t && t[0].length > 0)
|
|
1284
|
+
return { type: "space", raw: t[0] };
|
|
1285
|
+
}
|
|
1286
|
+
code(e) {
|
|
1287
|
+
let t = this.rules.block.code.exec(e);
|
|
1288
|
+
if (t) {
|
|
1289
|
+
let n = this.options.pedantic ? t[0] : Y(t[0]), r = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
1290
|
+
return { type: "code", raw: n, codeBlockStyle: "indented", text: r };
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
fences(e) {
|
|
1294
|
+
let t = this.rules.block.fences.exec(e);
|
|
1295
|
+
if (t) {
|
|
1296
|
+
let n = t[0], r = rt(n, t[3] || "", this.rules);
|
|
1297
|
+
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: r };
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
heading(e) {
|
|
1301
|
+
let t = this.rules.block.heading.exec(e);
|
|
1302
|
+
if (t) {
|
|
1303
|
+
let n = t[2].trim();
|
|
1304
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
1305
|
+
let r = $(n, "#");
|
|
1306
|
+
(this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (n = r.trim());
|
|
1307
|
+
}
|
|
1308
|
+
return { type: "heading", raw: $(t[0], `
|
|
1309
|
+
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
hr(e) {
|
|
1313
|
+
let t = this.rules.block.hr.exec(e);
|
|
1314
|
+
if (t)
|
|
1315
|
+
return { type: "hr", raw: $(t[0], `
|
|
1316
|
+
`) };
|
|
1317
|
+
}
|
|
1318
|
+
blockquote(e) {
|
|
1319
|
+
let t = this.rules.block.blockquote.exec(e);
|
|
1320
|
+
if (t) {
|
|
1321
|
+
let n = $(t[0], `
|
|
1322
|
+
`).split(`
|
|
1323
|
+
`), r = "", i = "", s = [];
|
|
1324
|
+
for (;n.length > 0; ) {
|
|
1325
|
+
let a = false, o = [], u;
|
|
1326
|
+
for (u = 0;u < n.length; u++)
|
|
1327
|
+
if (this.rules.other.blockquoteStart.test(n[u]))
|
|
1328
|
+
o.push(n[u]), a = true;
|
|
1329
|
+
else if (!a)
|
|
1330
|
+
o.push(n[u]);
|
|
1331
|
+
else
|
|
1332
|
+
break;
|
|
1333
|
+
n = n.slice(u);
|
|
1334
|
+
let p = o.join(`
|
|
1335
|
+
`), c = p.replace(this.rules.other.blockquoteSetextReplace, `
|
|
1336
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1337
|
+
r = r ? `${r}
|
|
1338
|
+
${p}` : p, i = i ? `${i}
|
|
1339
|
+
${c}` : c;
|
|
1340
|
+
let d = this.lexer.state.top;
|
|
1341
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = d, n.length === 0)
|
|
1342
|
+
break;
|
|
1343
|
+
let h = s.at(-1);
|
|
1344
|
+
if (h?.type === "code")
|
|
1345
|
+
break;
|
|
1346
|
+
if (h?.type === "blockquote") {
|
|
1347
|
+
let R = h, f = R.raw + `
|
|
1348
|
+
` + n.join(`
|
|
1349
|
+
`), S = this.blockquote(f);
|
|
1350
|
+
s[s.length - 1] = S, r = r.substring(0, r.length - R.raw.length) + S.raw, i = i.substring(0, i.length - R.text.length) + S.text;
|
|
1351
|
+
break;
|
|
1352
|
+
} else if (h?.type === "list") {
|
|
1353
|
+
let R = h, f = R.raw + `
|
|
1354
|
+
` + n.join(`
|
|
1355
|
+
`), S = this.list(f);
|
|
1356
|
+
s[s.length - 1] = S, r = r.substring(0, r.length - h.raw.length) + S.raw, i = i.substring(0, i.length - R.raw.length) + S.raw, n = f.substring(s.at(-1).raw.length).split(`
|
|
1357
|
+
`);
|
|
1358
|
+
continue;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
return { type: "blockquote", raw: r, tokens: s, text: i };
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
list(e) {
|
|
1365
|
+
let t = this.rules.block.list.exec(e);
|
|
1366
|
+
if (t) {
|
|
1367
|
+
let n = t[1].trim(), r = n.length > 1, i = { type: "list", raw: "", ordered: r, start: r ? +n.slice(0, -1) : "", loose: false, items: [] };
|
|
1368
|
+
n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
|
|
1369
|
+
let s = this.rules.other.listItemRegex(n), a = false;
|
|
1370
|
+
for (;e; ) {
|
|
1371
|
+
let u = false, p = "", c = "";
|
|
1372
|
+
if (!(t = s.exec(e)) || this.rules.block.hr.test(e))
|
|
1373
|
+
break;
|
|
1374
|
+
p = t[0], e = e.substring(p.length);
|
|
1375
|
+
let d = fe(t[2].split(`
|
|
1376
|
+
`, 1)[0], t[1].length), h = e.split(`
|
|
1377
|
+
`, 1)[0], R = !d.trim(), f = 0;
|
|
1378
|
+
if (this.options.pedantic ? (f = 2, c = d.trimStart()) : R ? f = t[1].length + 1 : (f = d.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = d.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (p += h + `
|
|
1379
|
+
`, e = e.substring(h.length + 1), u = true), !u) {
|
|
1380
|
+
let S = this.rules.other.nextBulletRegex(f), ee = this.rules.other.hrRegex(f), te = this.rules.other.fencesBeginRegex(f), ne = this.rules.other.headingBeginRegex(f), xe = this.rules.other.htmlBeginRegex(f), be = this.rules.other.blockquoteBeginRegex(f);
|
|
1381
|
+
for (;e; ) {
|
|
1382
|
+
let Z = e.split(`
|
|
1383
|
+
`, 1)[0], A;
|
|
1384
|
+
if (h = Z, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), A = h) : A = h.replace(this.rules.other.tabCharGlobal, " "), te.test(h) || ne.test(h) || xe.test(h) || be.test(h) || S.test(h) || ee.test(h))
|
|
1385
|
+
break;
|
|
1386
|
+
if (A.search(this.rules.other.nonSpaceChar) >= f || !h.trim())
|
|
1387
|
+
c += `
|
|
1388
|
+
` + A.slice(f);
|
|
1389
|
+
else {
|
|
1390
|
+
if (R || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(d) || ne.test(d) || ee.test(d))
|
|
1391
|
+
break;
|
|
1392
|
+
c += `
|
|
1393
|
+
` + h;
|
|
1394
|
+
}
|
|
1395
|
+
R = !h.trim(), p += Z + `
|
|
1396
|
+
`, e = e.substring(Z.length + 1), d = A.slice(f);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
i.loose || (a ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (a = true)), i.items.push({ type: "list_item", raw: p, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), i.raw += p;
|
|
1400
|
+
}
|
|
1401
|
+
let o = i.items.at(-1);
|
|
1402
|
+
if (o)
|
|
1403
|
+
o.raw = o.raw.trimEnd(), o.text = o.text.trimEnd();
|
|
1404
|
+
else
|
|
1405
|
+
return;
|
|
1406
|
+
i.raw = i.raw.trimEnd();
|
|
1407
|
+
for (let u of i.items) {
|
|
1408
|
+
if (this.lexer.state.top = false, u.tokens = this.lexer.blockTokens(u.text, []), u.task) {
|
|
1409
|
+
if (u.text = u.text.replace(this.rules.other.listReplaceTask, ""), u.tokens[0]?.type === "text" || u.tokens[0]?.type === "paragraph") {
|
|
1410
|
+
u.tokens[0].raw = u.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), u.tokens[0].text = u.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
|
|
1411
|
+
for (let c = this.lexer.inlineQueue.length - 1;c >= 0; c--)
|
|
1412
|
+
if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)) {
|
|
1413
|
+
this.lexer.inlineQueue[c].src = this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask, "");
|
|
1414
|
+
break;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
let p = this.rules.other.listTaskCheckbox.exec(u.raw);
|
|
1418
|
+
if (p) {
|
|
1419
|
+
let c = { type: "checkbox", raw: p[0] + " ", checked: p[0] !== "[ ]" };
|
|
1420
|
+
u.checked = c.checked, i.loose ? u.tokens[0] && ["paragraph", "text"].includes(u.tokens[0].type) && "tokens" in u.tokens[0] && u.tokens[0].tokens ? (u.tokens[0].raw = c.raw + u.tokens[0].raw, u.tokens[0].text = c.raw + u.tokens[0].text, u.tokens[0].tokens.unshift(c)) : u.tokens.unshift({ type: "paragraph", raw: c.raw, text: c.raw, tokens: [c] }) : u.tokens.unshift(c);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
if (!i.loose) {
|
|
1424
|
+
let p = u.tokens.filter((d) => d.type === "space"), c = p.length > 0 && p.some((d) => this.rules.other.anyLine.test(d.raw));
|
|
1425
|
+
i.loose = c;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
if (i.loose)
|
|
1429
|
+
for (let u of i.items) {
|
|
1430
|
+
u.loose = true;
|
|
1431
|
+
for (let p of u.tokens)
|
|
1432
|
+
p.type === "text" && (p.type = "paragraph");
|
|
1433
|
+
}
|
|
1434
|
+
return i;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
html(e) {
|
|
1438
|
+
let t = this.rules.block.html.exec(e);
|
|
1439
|
+
if (t) {
|
|
1440
|
+
let n = Y(t[0]);
|
|
1441
|
+
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
def(e) {
|
|
1445
|
+
let t = this.rules.block.def.exec(e);
|
|
1446
|
+
if (t) {
|
|
1447
|
+
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), r = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", i = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
1448
|
+
return { type: "def", tag: n, raw: $(t[0], `
|
|
1449
|
+
`), href: r, title: i };
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
table(e) {
|
|
1453
|
+
let t = this.rules.block.table.exec(e);
|
|
1454
|
+
if (!t || !this.rules.other.tableDelimiter.test(t[2]))
|
|
1455
|
+
return;
|
|
1456
|
+
let n = V(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
1457
|
+
`) : [], s = { type: "table", raw: $(t[0], `
|
|
1458
|
+
`), header: [], align: [], rows: [] };
|
|
1459
|
+
if (n.length === r.length) {
|
|
1460
|
+
for (let a of r)
|
|
1461
|
+
this.rules.other.tableAlignRight.test(a) ? s.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? s.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? s.align.push("left") : s.align.push(null);
|
|
1462
|
+
for (let a = 0;a < n.length; a++)
|
|
1463
|
+
s.header.push({ text: n[a], tokens: this.lexer.inline(n[a]), header: true, align: s.align[a] });
|
|
1464
|
+
for (let a of i)
|
|
1465
|
+
s.rows.push(V(a, s.header.length).map((o, u) => ({ text: o, tokens: this.lexer.inline(o), header: false, align: s.align[u] })));
|
|
1466
|
+
return s;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
lheading(e) {
|
|
1470
|
+
let t = this.rules.block.lheading.exec(e);
|
|
1471
|
+
if (t) {
|
|
1472
|
+
let n = t[1].trim();
|
|
1473
|
+
return { type: "heading", raw: $(t[0], `
|
|
1474
|
+
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
paragraph(e) {
|
|
1478
|
+
let t = this.rules.block.paragraph.exec(e);
|
|
1479
|
+
if (t) {
|
|
1480
|
+
let n = t[1].charAt(t[1].length - 1) === `
|
|
1481
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
1482
|
+
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
text(e) {
|
|
1486
|
+
let t = this.rules.block.text.exec(e);
|
|
1487
|
+
if (t)
|
|
1488
|
+
return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
1489
|
+
}
|
|
1490
|
+
escape(e) {
|
|
1491
|
+
let t = this.rules.inline.escape.exec(e);
|
|
1492
|
+
if (t)
|
|
1493
|
+
return { type: "escape", raw: t[0], text: t[1] };
|
|
1494
|
+
}
|
|
1495
|
+
tag(e) {
|
|
1496
|
+
let t = this.rules.inline.tag.exec(e);
|
|
1497
|
+
if (t)
|
|
1498
|
+
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] };
|
|
1499
|
+
}
|
|
1500
|
+
link(e) {
|
|
1501
|
+
let t = this.rules.inline.link.exec(e);
|
|
1502
|
+
if (t) {
|
|
1503
|
+
let n = t[2].trim();
|
|
1504
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
1505
|
+
if (!this.rules.other.endAngleBracket.test(n))
|
|
1506
|
+
return;
|
|
1507
|
+
let s = $(n.slice(0, -1), "\\");
|
|
1508
|
+
if ((n.length - s.length) % 2 === 0)
|
|
1509
|
+
return;
|
|
1510
|
+
} else {
|
|
1511
|
+
let s = ge(t[2], "()");
|
|
1512
|
+
if (s === -2)
|
|
1513
|
+
return;
|
|
1514
|
+
if (s > -1) {
|
|
1515
|
+
let o = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
|
|
1516
|
+
t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, o).trim(), t[3] = "";
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
let r = t[2], i = "";
|
|
1520
|
+
if (this.options.pedantic) {
|
|
1521
|
+
let s = this.rules.other.pedanticHrefTitle.exec(r);
|
|
1522
|
+
s && (r = s[1], i = s[3]);
|
|
1523
|
+
} else
|
|
1524
|
+
i = t[3] ? t[3].slice(1, -1) : "";
|
|
1525
|
+
return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), me(t, { href: r && r.replace(this.rules.inline.anyPunctuation, "$1"), title: i && i.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
reflink(e, t) {
|
|
1529
|
+
let n;
|
|
1530
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
1531
|
+
let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = t[r.toLowerCase()];
|
|
1532
|
+
if (!i) {
|
|
1533
|
+
let s = n[0].charAt(0);
|
|
1534
|
+
return { type: "text", raw: s, text: s };
|
|
1535
|
+
}
|
|
1536
|
+
return me(n, i, n[0], this.lexer, this.rules);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
emStrong(e, t, n = "") {
|
|
1540
|
+
let r = this.rules.inline.emStrongLDelim.exec(e);
|
|
1541
|
+
if (!r || !r[1] && !r[2] && !r[3] && !r[4] || r[4] && n.match(this.rules.other.unicodeAlphaNumeric))
|
|
1542
|
+
return;
|
|
1543
|
+
if (!(r[1] || r[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
1544
|
+
let s = [...r[0]].length - 1, a, o, u = s, p = 0, c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
1545
|
+
for (c.lastIndex = 0, t = t.slice(-1 * e.length + s);(r = c.exec(t)) !== null; ) {
|
|
1546
|
+
if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a)
|
|
1547
|
+
continue;
|
|
1548
|
+
if (o = [...a].length, r[3] || r[4]) {
|
|
1549
|
+
u += o;
|
|
1550
|
+
continue;
|
|
1551
|
+
} else if ((r[5] || r[6]) && s % 3 && !((s + o) % 3)) {
|
|
1552
|
+
p += o;
|
|
1553
|
+
continue;
|
|
1554
|
+
}
|
|
1555
|
+
if (u -= o, u > 0)
|
|
1556
|
+
continue;
|
|
1557
|
+
o = Math.min(o, o + u + p);
|
|
1558
|
+
let d = [...r[0]][0].length, h = e.slice(0, s + r.index + d + o);
|
|
1559
|
+
if (Math.min(s, o) % 2) {
|
|
1560
|
+
let f = h.slice(1, -1);
|
|
1561
|
+
return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
|
|
1562
|
+
}
|
|
1563
|
+
let R = h.slice(2, -2);
|
|
1564
|
+
return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
codespan(e) {
|
|
1569
|
+
let t = this.rules.inline.code.exec(e);
|
|
1570
|
+
if (t) {
|
|
1571
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), r = this.rules.other.nonSpaceChar.test(n), i = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
1572
|
+
return r && i && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
br(e) {
|
|
1576
|
+
let t = this.rules.inline.br.exec(e);
|
|
1577
|
+
if (t)
|
|
1578
|
+
return { type: "br", raw: t[0] };
|
|
1579
|
+
}
|
|
1580
|
+
del(e, t, n = "") {
|
|
1581
|
+
let r = this.rules.inline.delLDelim.exec(e);
|
|
1582
|
+
if (!r)
|
|
1583
|
+
return;
|
|
1584
|
+
if (!(r[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
1585
|
+
let s = [...r[0]].length - 1, a, o, u = s, p = this.rules.inline.delRDelim;
|
|
1586
|
+
for (p.lastIndex = 0, t = t.slice(-1 * e.length + s);(r = p.exec(t)) !== null; ) {
|
|
1587
|
+
if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a || (o = [...a].length, o !== s))
|
|
1588
|
+
continue;
|
|
1589
|
+
if (r[3] || r[4]) {
|
|
1590
|
+
u += o;
|
|
1591
|
+
continue;
|
|
1592
|
+
}
|
|
1593
|
+
if (u -= o, u > 0)
|
|
1594
|
+
continue;
|
|
1595
|
+
o = Math.min(o, o + u);
|
|
1596
|
+
let c = [...r[0]][0].length, d = e.slice(0, s + r.index + c + o), h = d.slice(s, -s);
|
|
1597
|
+
return { type: "del", raw: d, text: h, tokens: this.lexer.inlineTokens(h) };
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
autolink(e) {
|
|
1602
|
+
let t = this.rules.inline.autolink.exec(e);
|
|
1603
|
+
if (t) {
|
|
1604
|
+
let n, r;
|
|
1605
|
+
return t[2] === "@" ? (n = t[1], r = "mailto:" + n) : (n = t[1], r = n), { type: "link", raw: t[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] };
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
url(e) {
|
|
1609
|
+
let t;
|
|
1610
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
1611
|
+
let n, r;
|
|
1612
|
+
if (t[2] === "@")
|
|
1613
|
+
n = t[0], r = "mailto:" + n;
|
|
1614
|
+
else {
|
|
1615
|
+
let i;
|
|
1616
|
+
do
|
|
1617
|
+
i = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
1618
|
+
while (i !== t[0]);
|
|
1619
|
+
n = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
|
|
1620
|
+
}
|
|
1621
|
+
return { type: "link", raw: t[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] };
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
inlineText(e) {
|
|
1625
|
+
let t = this.rules.inline.text.exec(e);
|
|
1626
|
+
if (t) {
|
|
1627
|
+
let n = this.lexer.state.inRawBlock;
|
|
1628
|
+
return { type: "text", raw: t[0], text: t[0], escaped: n };
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
var x = class l {
|
|
1633
|
+
tokens;
|
|
1634
|
+
options;
|
|
1635
|
+
state;
|
|
1636
|
+
inlineQueue;
|
|
1637
|
+
tokenizer;
|
|
1638
|
+
constructor(e) {
|
|
1639
|
+
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
|
|
1640
|
+
let t = { other: m, block: B.normal, inline: I.normal };
|
|
1641
|
+
this.options.pedantic ? (t.block = B.pedantic, t.inline = I.pedantic) : this.options.gfm && (t.block = B.gfm, this.options.breaks ? t.inline = I.breaks : t.inline = I.gfm), this.tokenizer.rules = t;
|
|
1642
|
+
}
|
|
1643
|
+
static get rules() {
|
|
1644
|
+
return { block: B, inline: I };
|
|
1645
|
+
}
|
|
1646
|
+
static lex(e, t) {
|
|
1647
|
+
return new l(t).lex(e);
|
|
1648
|
+
}
|
|
1649
|
+
static lexInline(e, t) {
|
|
1650
|
+
return new l(t).inlineTokens(e);
|
|
1651
|
+
}
|
|
1652
|
+
lex(e) {
|
|
1653
|
+
e = e.replace(m.carriageReturn, `
|
|
1654
|
+
`), this.blockTokens(e, this.tokens);
|
|
1655
|
+
for (let t = 0;t < this.inlineQueue.length; t++) {
|
|
1656
|
+
let n = this.inlineQueue[t];
|
|
1657
|
+
this.inlineTokens(n.src, n.tokens);
|
|
1658
|
+
}
|
|
1659
|
+
return this.inlineQueue = [], this.tokens;
|
|
1660
|
+
}
|
|
1661
|
+
blockTokens(e, t = [], n = false) {
|
|
1662
|
+
for (this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));e; ) {
|
|
1663
|
+
let r;
|
|
1664
|
+
if (this.options.extensions?.block?.some((s) => (r = s.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false))
|
|
1665
|
+
continue;
|
|
1666
|
+
if (r = this.tokenizer.space(e)) {
|
|
1667
|
+
e = e.substring(r.raw.length);
|
|
1668
|
+
let s = t.at(-1);
|
|
1669
|
+
r.raw.length === 1 && s !== undefined ? s.raw += `
|
|
1670
|
+
` : t.push(r);
|
|
1671
|
+
continue;
|
|
1672
|
+
}
|
|
1673
|
+
if (r = this.tokenizer.code(e)) {
|
|
1674
|
+
e = e.substring(r.raw.length);
|
|
1675
|
+
let s = t.at(-1);
|
|
1676
|
+
s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(`
|
|
1677
|
+
`) ? "" : `
|
|
1678
|
+
`) + r.raw, s.text += `
|
|
1679
|
+
` + r.text, this.inlineQueue.at(-1).src = s.text) : t.push(r);
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1682
|
+
if (r = this.tokenizer.fences(e)) {
|
|
1683
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1684
|
+
continue;
|
|
1685
|
+
}
|
|
1686
|
+
if (r = this.tokenizer.heading(e)) {
|
|
1687
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1688
|
+
continue;
|
|
1689
|
+
}
|
|
1690
|
+
if (r = this.tokenizer.hr(e)) {
|
|
1691
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1692
|
+
continue;
|
|
1693
|
+
}
|
|
1694
|
+
if (r = this.tokenizer.blockquote(e)) {
|
|
1695
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1696
|
+
continue;
|
|
1697
|
+
}
|
|
1698
|
+
if (r = this.tokenizer.list(e)) {
|
|
1699
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1700
|
+
continue;
|
|
1701
|
+
}
|
|
1702
|
+
if (r = this.tokenizer.html(e)) {
|
|
1703
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1704
|
+
continue;
|
|
1705
|
+
}
|
|
1706
|
+
if (r = this.tokenizer.def(e)) {
|
|
1707
|
+
e = e.substring(r.raw.length);
|
|
1708
|
+
let s = t.at(-1);
|
|
1709
|
+
s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(`
|
|
1710
|
+
`) ? "" : `
|
|
1711
|
+
`) + r.raw, s.text += `
|
|
1712
|
+
` + r.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
if (r = this.tokenizer.table(e)) {
|
|
1716
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1717
|
+
continue;
|
|
1718
|
+
}
|
|
1719
|
+
if (r = this.tokenizer.lheading(e)) {
|
|
1720
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
1721
|
+
continue;
|
|
1722
|
+
}
|
|
1723
|
+
let i = e;
|
|
1724
|
+
if (this.options.extensions?.startBlock) {
|
|
1725
|
+
let s = 1 / 0, a = e.slice(1), o;
|
|
1726
|
+
this.options.extensions.startBlock.forEach((u) => {
|
|
1727
|
+
o = u.call({ lexer: this }, a), typeof o == "number" && o >= 0 && (s = Math.min(s, o));
|
|
1728
|
+
}), s < 1 / 0 && s >= 0 && (i = e.substring(0, s + 1));
|
|
1729
|
+
}
|
|
1730
|
+
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
1731
|
+
let s = t.at(-1);
|
|
1732
|
+
n && s?.type === "paragraph" ? (s.raw += (s.raw.endsWith(`
|
|
1733
|
+
`) ? "" : `
|
|
1734
|
+
`) + r.raw, s.text += `
|
|
1735
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
|
|
1736
|
+
continue;
|
|
1737
|
+
}
|
|
1738
|
+
if (r = this.tokenizer.text(e)) {
|
|
1739
|
+
e = e.substring(r.raw.length);
|
|
1740
|
+
let s = t.at(-1);
|
|
1741
|
+
s?.type === "text" ? (s.raw += (s.raw.endsWith(`
|
|
1742
|
+
`) ? "" : `
|
|
1743
|
+
`) + r.raw, s.text += `
|
|
1744
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r);
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
if (e) {
|
|
1748
|
+
let s = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
1749
|
+
if (this.options.silent) {
|
|
1750
|
+
console.error(s);
|
|
1751
|
+
break;
|
|
1752
|
+
} else
|
|
1753
|
+
throw new Error(s);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return this.state.top = true, t;
|
|
1757
|
+
}
|
|
1758
|
+
inline(e, t = []) {
|
|
1759
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
1760
|
+
}
|
|
1761
|
+
inlineTokens(e, t = []) {
|
|
1762
|
+
this.tokenizer.lexer = this;
|
|
1763
|
+
let n = e, r = null;
|
|
1764
|
+
if (this.tokens.links) {
|
|
1765
|
+
let o = Object.keys(this.tokens.links);
|
|
1766
|
+
if (o.length > 0)
|
|
1767
|
+
for (;(r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null; )
|
|
1768
|
+
o.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
1769
|
+
}
|
|
1770
|
+
for (;(r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null; )
|
|
1771
|
+
n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1772
|
+
let i;
|
|
1773
|
+
for (;(r = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null; )
|
|
1774
|
+
i = r[2] ? r[2].length : 0, n = n.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1775
|
+
n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
1776
|
+
let s = false, a = "";
|
|
1777
|
+
for (;e; ) {
|
|
1778
|
+
s || (a = ""), s = false;
|
|
1779
|
+
let o;
|
|
1780
|
+
if (this.options.extensions?.inline?.some((p) => (o = p.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false))
|
|
1781
|
+
continue;
|
|
1782
|
+
if (o = this.tokenizer.escape(e)) {
|
|
1783
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1784
|
+
continue;
|
|
1785
|
+
}
|
|
1786
|
+
if (o = this.tokenizer.tag(e)) {
|
|
1787
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1788
|
+
continue;
|
|
1789
|
+
}
|
|
1790
|
+
if (o = this.tokenizer.link(e)) {
|
|
1791
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1792
|
+
continue;
|
|
1793
|
+
}
|
|
1794
|
+
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
1795
|
+
e = e.substring(o.raw.length);
|
|
1796
|
+
let p = t.at(-1);
|
|
1797
|
+
o.type === "text" && p?.type === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
|
|
1798
|
+
continue;
|
|
1799
|
+
}
|
|
1800
|
+
if (o = this.tokenizer.emStrong(e, n, a)) {
|
|
1801
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1802
|
+
continue;
|
|
1803
|
+
}
|
|
1804
|
+
if (o = this.tokenizer.codespan(e)) {
|
|
1805
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1806
|
+
continue;
|
|
1807
|
+
}
|
|
1808
|
+
if (o = this.tokenizer.br(e)) {
|
|
1809
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
if (o = this.tokenizer.del(e, n, a)) {
|
|
1813
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1814
|
+
continue;
|
|
1815
|
+
}
|
|
1816
|
+
if (o = this.tokenizer.autolink(e)) {
|
|
1817
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1818
|
+
continue;
|
|
1819
|
+
}
|
|
1820
|
+
if (!this.state.inLink && (o = this.tokenizer.url(e))) {
|
|
1821
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
1822
|
+
continue;
|
|
1823
|
+
}
|
|
1824
|
+
let u = e;
|
|
1825
|
+
if (this.options.extensions?.startInline) {
|
|
1826
|
+
let p = 1 / 0, c = e.slice(1), d;
|
|
1827
|
+
this.options.extensions.startInline.forEach((h) => {
|
|
1828
|
+
d = h.call({ lexer: this }, c), typeof d == "number" && d >= 0 && (p = Math.min(p, d));
|
|
1829
|
+
}), p < 1 / 0 && p >= 0 && (u = e.substring(0, p + 1));
|
|
1830
|
+
}
|
|
1831
|
+
if (o = this.tokenizer.inlineText(u)) {
|
|
1832
|
+
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (a = o.raw.slice(-1)), s = true;
|
|
1833
|
+
let p = t.at(-1);
|
|
1834
|
+
p?.type === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
|
|
1835
|
+
continue;
|
|
1836
|
+
}
|
|
1837
|
+
if (e) {
|
|
1838
|
+
let p = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
1839
|
+
if (this.options.silent) {
|
|
1840
|
+
console.error(p);
|
|
1841
|
+
break;
|
|
1842
|
+
} else
|
|
1843
|
+
throw new Error(p);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
return t;
|
|
1847
|
+
}
|
|
1848
|
+
};
|
|
1849
|
+
var y = class {
|
|
1850
|
+
options;
|
|
1851
|
+
parser;
|
|
1852
|
+
constructor(e) {
|
|
1853
|
+
this.options = e || T;
|
|
1854
|
+
}
|
|
1855
|
+
space(e) {
|
|
1856
|
+
return "";
|
|
1857
|
+
}
|
|
1858
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
1859
|
+
let r = (t || "").match(m.notSpaceStart)?.[0], i = e.replace(m.endingNewline, "") + `
|
|
1860
|
+
`;
|
|
1861
|
+
return r ? '<pre><code class="language-' + O(r) + '">' + (n ? i : O(i, true)) + `</code></pre>
|
|
1862
|
+
` : "<pre><code>" + (n ? i : O(i, true)) + `</code></pre>
|
|
1863
|
+
`;
|
|
1864
|
+
}
|
|
1865
|
+
blockquote({ tokens: e }) {
|
|
1866
|
+
return `<blockquote>
|
|
1867
|
+
${this.parser.parse(e)}</blockquote>
|
|
1868
|
+
`;
|
|
1869
|
+
}
|
|
1870
|
+
html({ text: e }) {
|
|
1871
|
+
return e;
|
|
1872
|
+
}
|
|
1873
|
+
def(e) {
|
|
1874
|
+
return "";
|
|
1875
|
+
}
|
|
1876
|
+
heading({ tokens: e, depth: t }) {
|
|
1877
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
1878
|
+
`;
|
|
1879
|
+
}
|
|
1880
|
+
hr(e) {
|
|
1881
|
+
return `<hr>
|
|
1882
|
+
`;
|
|
1883
|
+
}
|
|
1884
|
+
list(e) {
|
|
1885
|
+
let { ordered: t, start: n } = e, r = "";
|
|
1886
|
+
for (let a = 0;a < e.items.length; a++) {
|
|
1887
|
+
let o = e.items[a];
|
|
1888
|
+
r += this.listitem(o);
|
|
1889
|
+
}
|
|
1890
|
+
let i = t ? "ol" : "ul", s = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
1891
|
+
return "<" + i + s + `>
|
|
1892
|
+
` + r + "</" + i + `>
|
|
1893
|
+
`;
|
|
1894
|
+
}
|
|
1895
|
+
listitem(e) {
|
|
1896
|
+
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
1897
|
+
`;
|
|
1898
|
+
}
|
|
1899
|
+
checkbox({ checked: e }) {
|
|
1900
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
1901
|
+
}
|
|
1902
|
+
paragraph({ tokens: e }) {
|
|
1903
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
1904
|
+
`;
|
|
1905
|
+
}
|
|
1906
|
+
table(e) {
|
|
1907
|
+
let t = "", n = "";
|
|
1908
|
+
for (let i = 0;i < e.header.length; i++)
|
|
1909
|
+
n += this.tablecell(e.header[i]);
|
|
1910
|
+
t += this.tablerow({ text: n });
|
|
1911
|
+
let r = "";
|
|
1912
|
+
for (let i = 0;i < e.rows.length; i++) {
|
|
1913
|
+
let s = e.rows[i];
|
|
1914
|
+
n = "";
|
|
1915
|
+
for (let a = 0;a < s.length; a++)
|
|
1916
|
+
n += this.tablecell(s[a]);
|
|
1917
|
+
r += this.tablerow({ text: n });
|
|
1918
|
+
}
|
|
1919
|
+
return r && (r = `<tbody>${r}</tbody>`), `<table>
|
|
1920
|
+
<thead>
|
|
1921
|
+
` + t + `</thead>
|
|
1922
|
+
` + r + `</table>
|
|
1923
|
+
`;
|
|
1924
|
+
}
|
|
1925
|
+
tablerow({ text: e }) {
|
|
1926
|
+
return `<tr>
|
|
1927
|
+
${e}</tr>
|
|
1928
|
+
`;
|
|
1929
|
+
}
|
|
1930
|
+
tablecell(e) {
|
|
1931
|
+
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
1932
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
1933
|
+
`;
|
|
1934
|
+
}
|
|
1935
|
+
strong({ tokens: e }) {
|
|
1936
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
1937
|
+
}
|
|
1938
|
+
em({ tokens: e }) {
|
|
1939
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
1940
|
+
}
|
|
1941
|
+
codespan({ text: e }) {
|
|
1942
|
+
return `<code>${O(e, true)}</code>`;
|
|
1943
|
+
}
|
|
1944
|
+
br(e) {
|
|
1945
|
+
return "<br>";
|
|
1946
|
+
}
|
|
1947
|
+
del({ tokens: e }) {
|
|
1948
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
1949
|
+
}
|
|
1950
|
+
link({ href: e, title: t, tokens: n }) {
|
|
1951
|
+
let r = this.parser.parseInline(n), i = J(e);
|
|
1952
|
+
if (i === null)
|
|
1953
|
+
return r;
|
|
1954
|
+
e = i;
|
|
1955
|
+
let s = '<a href="' + e + '"';
|
|
1956
|
+
return t && (s += ' title="' + O(t) + '"'), s += ">" + r + "</a>", s;
|
|
1957
|
+
}
|
|
1958
|
+
image({ href: e, title: t, text: n, tokens: r }) {
|
|
1959
|
+
r && (n = this.parser.parseInline(r, this.parser.textRenderer));
|
|
1960
|
+
let i = J(e);
|
|
1961
|
+
if (i === null)
|
|
1962
|
+
return O(n);
|
|
1963
|
+
e = i;
|
|
1964
|
+
let s = `<img src="${e}" alt="${O(n)}"`;
|
|
1965
|
+
return t && (s += ` title="${O(t)}"`), s += ">", s;
|
|
1966
|
+
}
|
|
1967
|
+
text(e) {
|
|
1968
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : O(e.text);
|
|
1969
|
+
}
|
|
1970
|
+
};
|
|
1971
|
+
var L = class {
|
|
1972
|
+
strong({ text: e }) {
|
|
1973
|
+
return e;
|
|
1974
|
+
}
|
|
1975
|
+
em({ text: e }) {
|
|
1976
|
+
return e;
|
|
1977
|
+
}
|
|
1978
|
+
codespan({ text: e }) {
|
|
1979
|
+
return e;
|
|
1980
|
+
}
|
|
1981
|
+
del({ text: e }) {
|
|
1982
|
+
return e;
|
|
1983
|
+
}
|
|
1984
|
+
html({ text: e }) {
|
|
1985
|
+
return e;
|
|
1986
|
+
}
|
|
1987
|
+
text({ text: e }) {
|
|
1988
|
+
return e;
|
|
1989
|
+
}
|
|
1990
|
+
link({ text: e }) {
|
|
1991
|
+
return "" + e;
|
|
1992
|
+
}
|
|
1993
|
+
image({ text: e }) {
|
|
1994
|
+
return "" + e;
|
|
1995
|
+
}
|
|
1996
|
+
br() {
|
|
1997
|
+
return "";
|
|
1998
|
+
}
|
|
1999
|
+
checkbox({ raw: e }) {
|
|
2000
|
+
return e;
|
|
2001
|
+
}
|
|
2002
|
+
};
|
|
2003
|
+
var b = class l2 {
|
|
2004
|
+
options;
|
|
2005
|
+
renderer;
|
|
2006
|
+
textRenderer;
|
|
2007
|
+
constructor(e) {
|
|
2008
|
+
this.options = e || T, this.options.renderer = this.options.renderer || new y, this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L;
|
|
2009
|
+
}
|
|
2010
|
+
static parse(e, t) {
|
|
2011
|
+
return new l2(t).parse(e);
|
|
2012
|
+
}
|
|
2013
|
+
static parseInline(e, t) {
|
|
2014
|
+
return new l2(t).parseInline(e);
|
|
2015
|
+
}
|
|
2016
|
+
parse(e) {
|
|
2017
|
+
this.renderer.parser = this;
|
|
2018
|
+
let t = "";
|
|
2019
|
+
for (let n = 0;n < e.length; n++) {
|
|
2020
|
+
let r = e[n];
|
|
2021
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
2022
|
+
let s = r, a = this.options.extensions.renderers[s.type].call({ parser: this }, s);
|
|
2023
|
+
if (a !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(s.type)) {
|
|
2024
|
+
t += a || "";
|
|
2025
|
+
continue;
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
let i = r;
|
|
2029
|
+
switch (i.type) {
|
|
2030
|
+
case "space": {
|
|
2031
|
+
t += this.renderer.space(i);
|
|
2032
|
+
break;
|
|
2033
|
+
}
|
|
2034
|
+
case "hr": {
|
|
2035
|
+
t += this.renderer.hr(i);
|
|
2036
|
+
break;
|
|
2037
|
+
}
|
|
2038
|
+
case "heading": {
|
|
2039
|
+
t += this.renderer.heading(i);
|
|
2040
|
+
break;
|
|
2041
|
+
}
|
|
2042
|
+
case "code": {
|
|
2043
|
+
t += this.renderer.code(i);
|
|
2044
|
+
break;
|
|
2045
|
+
}
|
|
2046
|
+
case "table": {
|
|
2047
|
+
t += this.renderer.table(i);
|
|
2048
|
+
break;
|
|
2049
|
+
}
|
|
2050
|
+
case "blockquote": {
|
|
2051
|
+
t += this.renderer.blockquote(i);
|
|
2052
|
+
break;
|
|
2053
|
+
}
|
|
2054
|
+
case "list": {
|
|
2055
|
+
t += this.renderer.list(i);
|
|
2056
|
+
break;
|
|
2057
|
+
}
|
|
2058
|
+
case "checkbox": {
|
|
2059
|
+
t += this.renderer.checkbox(i);
|
|
2060
|
+
break;
|
|
2061
|
+
}
|
|
2062
|
+
case "html": {
|
|
2063
|
+
t += this.renderer.html(i);
|
|
2064
|
+
break;
|
|
2065
|
+
}
|
|
2066
|
+
case "def": {
|
|
2067
|
+
t += this.renderer.def(i);
|
|
2068
|
+
break;
|
|
2069
|
+
}
|
|
2070
|
+
case "paragraph": {
|
|
2071
|
+
t += this.renderer.paragraph(i);
|
|
2072
|
+
break;
|
|
2073
|
+
}
|
|
2074
|
+
case "text": {
|
|
2075
|
+
t += this.renderer.text(i);
|
|
2076
|
+
break;
|
|
2077
|
+
}
|
|
2078
|
+
default: {
|
|
2079
|
+
let s = 'Token with "' + i.type + '" type was not found.';
|
|
2080
|
+
if (this.options.silent)
|
|
2081
|
+
return console.error(s), "";
|
|
2082
|
+
throw new Error(s);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
return t;
|
|
2087
|
+
}
|
|
2088
|
+
parseInline(e, t = this.renderer) {
|
|
2089
|
+
this.renderer.parser = this;
|
|
2090
|
+
let n = "";
|
|
2091
|
+
for (let r = 0;r < e.length; r++) {
|
|
2092
|
+
let i = e[r];
|
|
2093
|
+
if (this.options.extensions?.renderers?.[i.type]) {
|
|
2094
|
+
let a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
2095
|
+
if (a !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
|
|
2096
|
+
n += a || "";
|
|
2097
|
+
continue;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
let s = i;
|
|
2101
|
+
switch (s.type) {
|
|
2102
|
+
case "escape": {
|
|
2103
|
+
n += t.text(s);
|
|
2104
|
+
break;
|
|
2105
|
+
}
|
|
2106
|
+
case "html": {
|
|
2107
|
+
n += t.html(s);
|
|
2108
|
+
break;
|
|
2109
|
+
}
|
|
2110
|
+
case "link": {
|
|
2111
|
+
n += t.link(s);
|
|
2112
|
+
break;
|
|
2113
|
+
}
|
|
2114
|
+
case "image": {
|
|
2115
|
+
n += t.image(s);
|
|
2116
|
+
break;
|
|
2117
|
+
}
|
|
2118
|
+
case "checkbox": {
|
|
2119
|
+
n += t.checkbox(s);
|
|
2120
|
+
break;
|
|
2121
|
+
}
|
|
2122
|
+
case "strong": {
|
|
2123
|
+
n += t.strong(s);
|
|
2124
|
+
break;
|
|
2125
|
+
}
|
|
2126
|
+
case "em": {
|
|
2127
|
+
n += t.em(s);
|
|
2128
|
+
break;
|
|
2129
|
+
}
|
|
2130
|
+
case "codespan": {
|
|
2131
|
+
n += t.codespan(s);
|
|
2132
|
+
break;
|
|
2133
|
+
}
|
|
2134
|
+
case "br": {
|
|
2135
|
+
n += t.br(s);
|
|
2136
|
+
break;
|
|
2137
|
+
}
|
|
2138
|
+
case "del": {
|
|
2139
|
+
n += t.del(s);
|
|
2140
|
+
break;
|
|
2141
|
+
}
|
|
2142
|
+
case "text": {
|
|
2143
|
+
n += t.text(s);
|
|
2144
|
+
break;
|
|
2145
|
+
}
|
|
2146
|
+
default: {
|
|
2147
|
+
let a = 'Token with "' + s.type + '" type was not found.';
|
|
2148
|
+
if (this.options.silent)
|
|
2149
|
+
return console.error(a), "";
|
|
2150
|
+
throw new Error(a);
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
return n;
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
var P = class {
|
|
2158
|
+
options;
|
|
2159
|
+
block;
|
|
2160
|
+
constructor(e) {
|
|
2161
|
+
this.options = e || T;
|
|
2162
|
+
}
|
|
2163
|
+
static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
2164
|
+
static passThroughHooksRespectAsync = new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
2165
|
+
preprocess(e) {
|
|
2166
|
+
return e;
|
|
2167
|
+
}
|
|
2168
|
+
postprocess(e) {
|
|
2169
|
+
return e;
|
|
2170
|
+
}
|
|
2171
|
+
processAllTokens(e) {
|
|
2172
|
+
return e;
|
|
2173
|
+
}
|
|
2174
|
+
emStrongMask(e) {
|
|
2175
|
+
return e;
|
|
2176
|
+
}
|
|
2177
|
+
provideLexer(e = this.block) {
|
|
2178
|
+
return e ? x.lex : x.lexInline;
|
|
2179
|
+
}
|
|
2180
|
+
provideParser(e = this.block) {
|
|
2181
|
+
return e ? b.parse : b.parseInline;
|
|
2182
|
+
}
|
|
2183
|
+
};
|
|
2184
|
+
var D = class {
|
|
2185
|
+
defaults = z();
|
|
2186
|
+
options = this.setOptions;
|
|
2187
|
+
parse = this.parseMarkdown(true);
|
|
2188
|
+
parseInline = this.parseMarkdown(false);
|
|
2189
|
+
Parser = b;
|
|
2190
|
+
Renderer = y;
|
|
2191
|
+
TextRenderer = L;
|
|
2192
|
+
Lexer = x;
|
|
2193
|
+
Tokenizer = w;
|
|
2194
|
+
Hooks = P;
|
|
2195
|
+
constructor(...e) {
|
|
2196
|
+
this.use(...e);
|
|
2197
|
+
}
|
|
2198
|
+
walkTokens(e, t) {
|
|
2199
|
+
let n = [];
|
|
2200
|
+
for (let r of e)
|
|
2201
|
+
switch (n = n.concat(t.call(this, r)), r.type) {
|
|
2202
|
+
case "table": {
|
|
2203
|
+
let i = r;
|
|
2204
|
+
for (let s of i.header)
|
|
2205
|
+
n = n.concat(this.walkTokens(s.tokens, t));
|
|
2206
|
+
for (let s of i.rows)
|
|
2207
|
+
for (let a of s)
|
|
2208
|
+
n = n.concat(this.walkTokens(a.tokens, t));
|
|
2209
|
+
break;
|
|
2210
|
+
}
|
|
2211
|
+
case "list": {
|
|
2212
|
+
let i = r;
|
|
2213
|
+
n = n.concat(this.walkTokens(i.items, t));
|
|
2214
|
+
break;
|
|
2215
|
+
}
|
|
2216
|
+
default: {
|
|
2217
|
+
let i = r;
|
|
2218
|
+
this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach((s) => {
|
|
2219
|
+
let a = i[s].flat(1 / 0);
|
|
2220
|
+
n = n.concat(this.walkTokens(a, t));
|
|
2221
|
+
}) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
return n;
|
|
2225
|
+
}
|
|
2226
|
+
use(...e) {
|
|
2227
|
+
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
2228
|
+
return e.forEach((n) => {
|
|
2229
|
+
let r = { ...n };
|
|
2230
|
+
if (r.async = this.defaults.async || r.async || false, n.extensions && (n.extensions.forEach((i) => {
|
|
2231
|
+
if (!i.name)
|
|
2232
|
+
throw new Error("extension name required");
|
|
2233
|
+
if ("renderer" in i) {
|
|
2234
|
+
let s = t.renderers[i.name];
|
|
2235
|
+
s ? t.renderers[i.name] = function(...a) {
|
|
2236
|
+
let o = i.renderer.apply(this, a);
|
|
2237
|
+
return o === false && (o = s.apply(this, a)), o;
|
|
2238
|
+
} : t.renderers[i.name] = i.renderer;
|
|
2239
|
+
}
|
|
2240
|
+
if ("tokenizer" in i) {
|
|
2241
|
+
if (!i.level || i.level !== "block" && i.level !== "inline")
|
|
2242
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
2243
|
+
let s = t[i.level];
|
|
2244
|
+
s ? s.unshift(i.tokenizer) : t[i.level] = [i.tokenizer], i.start && (i.level === "block" ? t.startBlock ? t.startBlock.push(i.start) : t.startBlock = [i.start] : i.level === "inline" && (t.startInline ? t.startInline.push(i.start) : t.startInline = [i.start]));
|
|
2245
|
+
}
|
|
2246
|
+
"childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
|
|
2247
|
+
}), r.extensions = t), n.renderer) {
|
|
2248
|
+
let i = this.defaults.renderer || new y(this.defaults);
|
|
2249
|
+
for (let s in n.renderer) {
|
|
2250
|
+
if (!(s in i))
|
|
2251
|
+
throw new Error(`renderer '${s}' does not exist`);
|
|
2252
|
+
if (["options", "parser"].includes(s))
|
|
2253
|
+
continue;
|
|
2254
|
+
let a = s, o = n.renderer[a], u = i[a];
|
|
2255
|
+
i[a] = (...p) => {
|
|
2256
|
+
let c = o.apply(i, p);
|
|
2257
|
+
return c === false && (c = u.apply(i, p)), c || "";
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
r.renderer = i;
|
|
2261
|
+
}
|
|
2262
|
+
if (n.tokenizer) {
|
|
2263
|
+
let i = this.defaults.tokenizer || new w(this.defaults);
|
|
2264
|
+
for (let s in n.tokenizer) {
|
|
2265
|
+
if (!(s in i))
|
|
2266
|
+
throw new Error(`tokenizer '${s}' does not exist`);
|
|
2267
|
+
if (["options", "rules", "lexer"].includes(s))
|
|
2268
|
+
continue;
|
|
2269
|
+
let a = s, o = n.tokenizer[a], u = i[a];
|
|
2270
|
+
i[a] = (...p) => {
|
|
2271
|
+
let c = o.apply(i, p);
|
|
2272
|
+
return c === false && (c = u.apply(i, p)), c;
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2275
|
+
r.tokenizer = i;
|
|
2276
|
+
}
|
|
2277
|
+
if (n.hooks) {
|
|
2278
|
+
let i = this.defaults.hooks || new P;
|
|
2279
|
+
for (let s in n.hooks) {
|
|
2280
|
+
if (!(s in i))
|
|
2281
|
+
throw new Error(`hook '${s}' does not exist`);
|
|
2282
|
+
if (["options", "block"].includes(s))
|
|
2283
|
+
continue;
|
|
2284
|
+
let a = s, o = n.hooks[a], u = i[a];
|
|
2285
|
+
P.passThroughHooks.has(s) ? i[a] = (p) => {
|
|
2286
|
+
if (this.defaults.async && P.passThroughHooksRespectAsync.has(s))
|
|
2287
|
+
return (async () => {
|
|
2288
|
+
let d = await o.call(i, p);
|
|
2289
|
+
return u.call(i, d);
|
|
2290
|
+
})();
|
|
2291
|
+
let c = o.call(i, p);
|
|
2292
|
+
return u.call(i, c);
|
|
2293
|
+
} : i[a] = (...p) => {
|
|
2294
|
+
if (this.defaults.async)
|
|
2295
|
+
return (async () => {
|
|
2296
|
+
let d = await o.apply(i, p);
|
|
2297
|
+
return d === false && (d = await u.apply(i, p)), d;
|
|
2298
|
+
})();
|
|
2299
|
+
let c = o.apply(i, p);
|
|
2300
|
+
return c === false && (c = u.apply(i, p)), c;
|
|
2301
|
+
};
|
|
2302
|
+
}
|
|
2303
|
+
r.hooks = i;
|
|
2304
|
+
}
|
|
2305
|
+
if (n.walkTokens) {
|
|
2306
|
+
let i = this.defaults.walkTokens, s = n.walkTokens;
|
|
2307
|
+
r.walkTokens = function(a) {
|
|
2308
|
+
let o = [];
|
|
2309
|
+
return o.push(s.call(this, a)), i && (o = o.concat(i.call(this, a))), o;
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
this.defaults = { ...this.defaults, ...r };
|
|
2313
|
+
}), this;
|
|
2314
|
+
}
|
|
2315
|
+
setOptions(e) {
|
|
2316
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
2317
|
+
}
|
|
2318
|
+
lexer(e, t) {
|
|
2319
|
+
return x.lex(e, t ?? this.defaults);
|
|
2320
|
+
}
|
|
2321
|
+
parser(e, t) {
|
|
2322
|
+
return b.parse(e, t ?? this.defaults);
|
|
2323
|
+
}
|
|
2324
|
+
parseMarkdown(e) {
|
|
2325
|
+
return (n, r) => {
|
|
2326
|
+
let i = { ...r }, s = { ...this.defaults, ...i }, a = this.onError(!!s.silent, !!s.async);
|
|
2327
|
+
if (this.defaults.async === true && i.async === false)
|
|
2328
|
+
return a(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."));
|
|
2329
|
+
if (typeof n > "u" || n === null)
|
|
2330
|
+
return a(new Error("marked(): input parameter is undefined or null"));
|
|
2331
|
+
if (typeof n != "string")
|
|
2332
|
+
return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
2333
|
+
if (s.hooks && (s.hooks.options = s, s.hooks.block = e), s.async)
|
|
2334
|
+
return (async () => {
|
|
2335
|
+
let o = s.hooks ? await s.hooks.preprocess(n) : n, p = await (s.hooks ? await s.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(o, s), c = s.hooks ? await s.hooks.processAllTokens(p) : p;
|
|
2336
|
+
s.walkTokens && await Promise.all(this.walkTokens(c, s.walkTokens));
|
|
2337
|
+
let h = await (s.hooks ? await s.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, s);
|
|
2338
|
+
return s.hooks ? await s.hooks.postprocess(h) : h;
|
|
2339
|
+
})().catch(a);
|
|
2340
|
+
try {
|
|
2341
|
+
s.hooks && (n = s.hooks.preprocess(n));
|
|
2342
|
+
let u = (s.hooks ? s.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, s);
|
|
2343
|
+
s.hooks && (u = s.hooks.processAllTokens(u)), s.walkTokens && this.walkTokens(u, s.walkTokens);
|
|
2344
|
+
let c = (s.hooks ? s.hooks.provideParser(e) : e ? b.parse : b.parseInline)(u, s);
|
|
2345
|
+
return s.hooks && (c = s.hooks.postprocess(c)), c;
|
|
2346
|
+
} catch (o) {
|
|
2347
|
+
return a(o);
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
}
|
|
2351
|
+
onError(e, t) {
|
|
2352
|
+
return (n) => {
|
|
2353
|
+
if (n.message += `
|
|
2354
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
2355
|
+
let r = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
|
|
2356
|
+
return t ? Promise.resolve(r) : r;
|
|
2357
|
+
}
|
|
2358
|
+
if (t)
|
|
2359
|
+
return Promise.reject(n);
|
|
2360
|
+
throw n;
|
|
2361
|
+
};
|
|
2362
|
+
}
|
|
2363
|
+
};
|
|
2364
|
+
var M = new D;
|
|
2365
|
+
function g(l3, e) {
|
|
2366
|
+
return M.parse(l3, e);
|
|
2367
|
+
}
|
|
2368
|
+
g.options = g.setOptions = function(l3) {
|
|
2369
|
+
return M.setOptions(l3), g.defaults = M.defaults, G(g.defaults), g;
|
|
2370
|
+
};
|
|
2371
|
+
g.getDefaults = z;
|
|
2372
|
+
g.defaults = T;
|
|
2373
|
+
g.use = function(...l3) {
|
|
2374
|
+
return M.use(...l3), g.defaults = M.defaults, G(g.defaults), g;
|
|
2375
|
+
};
|
|
2376
|
+
g.walkTokens = function(l3, e) {
|
|
2377
|
+
return M.walkTokens(l3, e);
|
|
2378
|
+
};
|
|
2379
|
+
g.parseInline = M.parseInline;
|
|
2380
|
+
g.Parser = b;
|
|
2381
|
+
g.parser = b.parse;
|
|
2382
|
+
g.Renderer = y;
|
|
2383
|
+
g.TextRenderer = L;
|
|
2384
|
+
g.Lexer = x;
|
|
2385
|
+
g.lexer = x.lex;
|
|
2386
|
+
g.Tokenizer = w;
|
|
2387
|
+
g.Hooks = P;
|
|
2388
|
+
g.parse = g;
|
|
2389
|
+
var jt = g.options;
|
|
2390
|
+
var Ft = g.setOptions;
|
|
2391
|
+
var Ut = g.use;
|
|
2392
|
+
var Kt = g.walkTokens;
|
|
2393
|
+
var Wt = g.parseInline;
|
|
2394
|
+
var Jt = b.parse;
|
|
2395
|
+
var Vt = x.lex;
|
|
2396
|
+
|
|
2397
|
+
// src/polly-ui/markdown.tsx
|
|
2398
|
+
import { jsxDEV } from "preact/jsx-dev-runtime";
|
|
2399
|
+
function renderMarkdown(value) {
|
|
2400
|
+
const html2 = g.parse(value, { async: false });
|
|
2401
|
+
const clean = purify.sanitize(html2);
|
|
2402
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
2403
|
+
dangerouslySetInnerHTML: { __html: clean }
|
|
2404
|
+
}, undefined, false, undefined, this);
|
|
2405
|
+
}
|
|
2406
|
+
export {
|
|
2407
|
+
renderMarkdown
|
|
2408
|
+
};
|
|
2409
|
+
|
|
2410
|
+
//# debugId=B95E2395E651F0D964756E2164756E21
|