@fairfox/polly 0.38.2 → 0.40.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/cli/polly.js.map +1 -1
- package/dist/src/background/index.js +1 -2
- package/dist/src/background/index.js.map +6 -6
- package/dist/src/background/message-router.js +1 -2
- package/dist/src/background/message-router.js.map +6 -6
- package/dist/src/client/index.js +46 -27
- package/dist/src/client/index.js.map +5 -5
- package/dist/src/client/wrapper.d.ts +8 -0
- package/dist/src/elysia/index.js +10 -31
- package/dist/src/elysia/index.js.map +5 -5
- package/dist/src/elysia/route-match.d.ts +9 -0
- package/dist/src/elysia/types.d.ts +4 -5
- package/dist/src/index.js +1 -2
- package/dist/src/index.js.map +7 -7
- package/dist/src/mesh-node.js.map +1 -1
- package/dist/src/mesh.js.map +7 -7
- package/dist/src/peer.js.map +3 -3
- package/dist/src/polly-ui/index.js.map +3 -3
- package/dist/src/polly-ui/markdown.js +583 -517
- package/dist/src/polly-ui/markdown.js.map +6 -6
- package/dist/src/shared/adapters/index.js.map +3 -3
- package/dist/src/shared/lib/context-helpers.js +1 -2
- package/dist/src/shared/lib/context-helpers.js.map +6 -6
- package/dist/src/shared/lib/mesh-signaling-client.d.ts +1 -1
- package/dist/src/shared/lib/message-bus.js +1 -2
- package/dist/src/shared/lib/message-bus.js.map +6 -6
- package/dist/src/shared/lib/peer-relay-adapter.d.ts +3 -2
- package/dist/src/shared/lib/resource.js.map +3 -3
- package/dist/src/shared/lib/state.js.map +3 -3
- package/dist/src/shared/state/app-state.js.map +4 -4
- package/dist/src/shared/types/messages.d.ts +0 -9
- package/dist/src/shared/types/messages.js.map +1 -1
- package/dist/tools/test/src/adapters/index.js.map +1 -1
- package/dist/tools/test/src/index.js.map +1 -1
- package/dist/tools/test/src/visual/index.js +64 -38
- package/dist/tools/test/src/visual/index.js.map +4 -4
- package/dist/tools/verify/Dockerfile +1 -1
- package/dist/tools/verify/specs/Dockerfile +1 -1
- package/dist/tools/verify/src/cli.js.map +3 -3
- package/dist/tools/visualize/src/cli.js.map +3 -3
- package/package.json +33 -28
- package/dist/src/utils/function-serialization.d.ts +0 -14
|
@@ -69,8 +69,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
69
69
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
// node_modules/.bun/dompurify@3.4.
|
|
73
|
-
/*! @license DOMPurify 3.4.
|
|
72
|
+
// node_modules/.bun/dompurify@3.4.2/node_modules/dompurify/dist/purify.es.mjs
|
|
73
|
+
/*! @license DOMPurify 3.4.2 | (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.2/LICENSE */
|
|
74
74
|
var {
|
|
75
75
|
entries,
|
|
76
76
|
setPrototypeOf,
|
|
@@ -118,13 +118,19 @@ var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
|
118
118
|
var arrayPop = unapply(Array.prototype.pop);
|
|
119
119
|
var arrayPush = unapply(Array.prototype.push);
|
|
120
120
|
var arraySplice = unapply(Array.prototype.splice);
|
|
121
|
+
var arrayIsArray = Array.isArray;
|
|
121
122
|
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
122
123
|
var stringToString = unapply(String.prototype.toString);
|
|
123
124
|
var stringMatch = unapply(String.prototype.match);
|
|
124
125
|
var stringReplace = unapply(String.prototype.replace);
|
|
125
126
|
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
126
127
|
var stringTrim = unapply(String.prototype.trim);
|
|
128
|
+
var numberToString = unapply(Number.prototype.toString);
|
|
129
|
+
var booleanToString = unapply(Boolean.prototype.toString);
|
|
130
|
+
var bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
|
|
131
|
+
var symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
|
|
127
132
|
var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
133
|
+
var objectToString = unapply(Object.prototype.toString);
|
|
128
134
|
var regExpTest = unapply(RegExp.prototype.test);
|
|
129
135
|
var typeErrorCreate = unconstruct(TypeError);
|
|
130
136
|
function unapply(func) {
|
|
@@ -151,6 +157,9 @@ function addToSet(set, array) {
|
|
|
151
157
|
if (setPrototypeOf) {
|
|
152
158
|
setPrototypeOf(set, null);
|
|
153
159
|
}
|
|
160
|
+
if (!arrayIsArray(array)) {
|
|
161
|
+
return set;
|
|
162
|
+
}
|
|
154
163
|
let l = array.length;
|
|
155
164
|
while (l--) {
|
|
156
165
|
let element = array[l];
|
|
@@ -181,7 +190,7 @@ function clone(object) {
|
|
|
181
190
|
for (const [property, value] of entries(object)) {
|
|
182
191
|
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
183
192
|
if (isPropertyExist) {
|
|
184
|
-
if (
|
|
193
|
+
if (arrayIsArray(value)) {
|
|
185
194
|
newObject[property] = cleanArray(value);
|
|
186
195
|
} else if (value && typeof value === "object" && value.constructor === Object) {
|
|
187
196
|
newObject[property] = clone(value);
|
|
@@ -192,6 +201,44 @@ function clone(object) {
|
|
|
192
201
|
}
|
|
193
202
|
return newObject;
|
|
194
203
|
}
|
|
204
|
+
function stringifyValue(value) {
|
|
205
|
+
switch (typeof value) {
|
|
206
|
+
case "string": {
|
|
207
|
+
return value;
|
|
208
|
+
}
|
|
209
|
+
case "number": {
|
|
210
|
+
return numberToString(value);
|
|
211
|
+
}
|
|
212
|
+
case "boolean": {
|
|
213
|
+
return booleanToString(value);
|
|
214
|
+
}
|
|
215
|
+
case "bigint": {
|
|
216
|
+
return bigintToString ? bigintToString(value) : "0";
|
|
217
|
+
}
|
|
218
|
+
case "symbol": {
|
|
219
|
+
return symbolToString ? symbolToString(value) : "Symbol()";
|
|
220
|
+
}
|
|
221
|
+
case "undefined": {
|
|
222
|
+
return objectToString(value);
|
|
223
|
+
}
|
|
224
|
+
case "function":
|
|
225
|
+
case "object": {
|
|
226
|
+
if (value === null) {
|
|
227
|
+
return objectToString(value);
|
|
228
|
+
}
|
|
229
|
+
const valueAsRecord = value;
|
|
230
|
+
const valueToString = lookupGetter(valueAsRecord, "toString");
|
|
231
|
+
if (typeof valueToString === "function") {
|
|
232
|
+
const stringified = valueToString(valueAsRecord);
|
|
233
|
+
return typeof stringified === "string" ? stringified : objectToString(stringified);
|
|
234
|
+
}
|
|
235
|
+
return objectToString(value);
|
|
236
|
+
}
|
|
237
|
+
default: {
|
|
238
|
+
return objectToString(value);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
195
242
|
function lookupGetter(object, prop) {
|
|
196
243
|
while (object !== null) {
|
|
197
244
|
const desc = getOwnPropertyDescriptor(object, prop);
|
|
@@ -210,6 +257,14 @@ function lookupGetter(object, prop) {
|
|
|
210
257
|
}
|
|
211
258
|
return fallbackValue;
|
|
212
259
|
}
|
|
260
|
+
function isRegex(value) {
|
|
261
|
+
try {
|
|
262
|
+
regExpTest(value, "");
|
|
263
|
+
return true;
|
|
264
|
+
} catch (_unused) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
213
268
|
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
269
|
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
270
|
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"]);
|
|
@@ -217,7 +272,7 @@ var svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "fo
|
|
|
217
272
|
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
273
|
var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
219
274
|
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"
|
|
275
|
+
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"]);
|
|
221
276
|
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
277
|
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
278
|
var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
@@ -294,7 +349,7 @@ var _createHooksMap = function _createHooksMap2() {
|
|
|
294
349
|
function createDOMPurify() {
|
|
295
350
|
let window2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
296
351
|
const DOMPurify = (root) => createDOMPurify(root);
|
|
297
|
-
DOMPurify.version = "3.4.
|
|
352
|
+
DOMPurify.version = "3.4.2";
|
|
298
353
|
DOMPurify.removed = [];
|
|
299
354
|
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
300
355
|
DOMPurify.isSupported = false;
|
|
@@ -448,15 +503,15 @@ function createDOMPurify() {
|
|
|
448
503
|
cfg = clone(cfg);
|
|
449
504
|
PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
450
505
|
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;
|
|
506
|
+
ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
507
|
+
ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
508
|
+
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
509
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
510
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
|
511
|
+
FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
512
|
+
FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
|
|
513
|
+
FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
|
|
514
|
+
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
460
515
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
461
516
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
462
517
|
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
|
@@ -472,19 +527,20 @@ function createDOMPurify() {
|
|
|
472
527
|
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
|
473
528
|
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
|
474
529
|
IN_PLACE = cfg.IN_PLACE || false;
|
|
475
|
-
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP
|
|
476
|
-
NAMESPACE = cfg.NAMESPACE
|
|
477
|
-
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS
|
|
478
|
-
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
530
|
+
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
531
|
+
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
532
|
+
MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
|
|
533
|
+
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, ["annotation-xml"]);
|
|
534
|
+
const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
|
|
535
|
+
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
536
|
+
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
537
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
|
|
482
538
|
}
|
|
483
|
-
if (
|
|
484
|
-
CUSTOM_ELEMENT_HANDLING.attributeNameCheck =
|
|
539
|
+
if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
|
|
540
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
|
|
485
541
|
}
|
|
486
|
-
if (
|
|
487
|
-
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements =
|
|
542
|
+
if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
|
|
543
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
|
|
488
544
|
}
|
|
489
545
|
if (SAFE_FOR_TEMPLATES) {
|
|
490
546
|
ALLOW_DATA_ATTR = false;
|
|
@@ -517,36 +573,36 @@ function createDOMPurify() {
|
|
|
517
573
|
}
|
|
518
574
|
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
519
575
|
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
520
|
-
if (cfg
|
|
576
|
+
if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
|
|
521
577
|
if (typeof cfg.ADD_TAGS === "function") {
|
|
522
578
|
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
523
|
-
} else {
|
|
579
|
+
} else if (arrayIsArray(cfg.ADD_TAGS)) {
|
|
524
580
|
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
525
581
|
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
526
582
|
}
|
|
527
583
|
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
528
584
|
}
|
|
529
585
|
}
|
|
530
|
-
if (cfg
|
|
586
|
+
if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
|
|
531
587
|
if (typeof cfg.ADD_ATTR === "function") {
|
|
532
588
|
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
533
|
-
} else {
|
|
589
|
+
} else if (arrayIsArray(cfg.ADD_ATTR)) {
|
|
534
590
|
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
535
591
|
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
536
592
|
}
|
|
537
593
|
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
538
594
|
}
|
|
539
595
|
}
|
|
540
|
-
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
596
|
+
if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
|
|
541
597
|
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
542
598
|
}
|
|
543
|
-
if (cfg.FORBID_CONTENTS) {
|
|
599
|
+
if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
|
|
544
600
|
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
545
601
|
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
546
602
|
}
|
|
547
603
|
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
548
604
|
}
|
|
549
|
-
if (cfg.ADD_FORBID_CONTENTS) {
|
|
605
|
+
if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
|
|
550
606
|
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
551
607
|
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
552
608
|
}
|
|
@@ -757,7 +813,6 @@ function createDOMPurify() {
|
|
|
757
813
|
const childCount = childNodes.length;
|
|
758
814
|
for (let i = childCount - 1;i >= 0; --i) {
|
|
759
815
|
const childClone = cloneNode(childNodes[i], true);
|
|
760
|
-
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
761
816
|
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
762
817
|
}
|
|
763
818
|
}
|
|
@@ -795,13 +850,12 @@ function createDOMPurify() {
|
|
|
795
850
|
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && ((value in document) || (value in formElement))) {
|
|
796
851
|
return false;
|
|
797
852
|
}
|
|
853
|
+
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
798
854
|
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName))
|
|
799
855
|
;
|
|
800
856
|
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName))
|
|
801
857
|
;
|
|
802
|
-
else if (
|
|
803
|
-
;
|
|
804
|
-
else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
858
|
+
else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
|
|
805
859
|
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
860
|
;
|
|
807
861
|
else {
|
|
@@ -821,8 +875,9 @@ function createDOMPurify() {
|
|
|
821
875
|
;
|
|
822
876
|
return true;
|
|
823
877
|
};
|
|
878
|
+
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]);
|
|
824
879
|
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
825
|
-
return tagName
|
|
880
|
+
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT2, tagName);
|
|
826
881
|
};
|
|
827
882
|
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
|
828
883
|
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
@@ -856,7 +911,7 @@ function createDOMPurify() {
|
|
|
856
911
|
hookEvent.forceKeepAttr = undefined;
|
|
857
912
|
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
858
913
|
value = hookEvent.attrValue;
|
|
859
|
-
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
|
|
914
|
+
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
860
915
|
_removeAttribute(name, currentNode);
|
|
861
916
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
862
917
|
}
|
|
@@ -949,13 +1004,9 @@ function createDOMPurify() {
|
|
|
949
1004
|
dirty = "<!-->";
|
|
950
1005
|
}
|
|
951
1006
|
if (typeof dirty !== "string" && !_isNode(dirty)) {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
throw typeErrorCreate("dirty is not a string, aborting");
|
|
956
|
-
}
|
|
957
|
-
} else {
|
|
958
|
-
throw typeErrorCreate("toString is not a function");
|
|
1007
|
+
dirty = stringifyValue(dirty);
|
|
1008
|
+
if (typeof dirty !== "string") {
|
|
1009
|
+
throw typeErrorCreate("dirty is not a string, aborting");
|
|
959
1010
|
}
|
|
960
1011
|
}
|
|
961
1012
|
if (!DOMPurify.isSupported) {
|
|
@@ -969,8 +1020,9 @@ function createDOMPurify() {
|
|
|
969
1020
|
IN_PLACE = false;
|
|
970
1021
|
}
|
|
971
1022
|
if (IN_PLACE) {
|
|
972
|
-
|
|
973
|
-
|
|
1023
|
+
const nn = dirty.nodeName;
|
|
1024
|
+
if (typeof nn === "string") {
|
|
1025
|
+
const tagName = transformCaseFunc(nn);
|
|
974
1026
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
975
1027
|
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
976
1028
|
}
|
|
@@ -1082,7 +1134,7 @@ function createDOMPurify() {
|
|
|
1082
1134
|
}
|
|
1083
1135
|
var purify = createDOMPurify();
|
|
1084
1136
|
|
|
1085
|
-
// node_modules/.bun/marked@18.0.
|
|
1137
|
+
// node_modules/.bun/marked@18.0.3/node_modules/marked/lib/marked.esm.js
|
|
1086
1138
|
function z() {
|
|
1087
1139
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
1088
1140
|
}
|
|
@@ -1091,10 +1143,10 @@ function G(l) {
|
|
|
1091
1143
|
T = l;
|
|
1092
1144
|
}
|
|
1093
1145
|
var _ = { exec: () => null };
|
|
1094
|
-
function
|
|
1095
|
-
let t = typeof l == "string" ? l : l.source, n = { replace: (
|
|
1096
|
-
let
|
|
1097
|
-
return
|
|
1146
|
+
function d(l, e = "") {
|
|
1147
|
+
let t = typeof l == "string" ? l : l.source, n = { replace: (s, r) => {
|
|
1148
|
+
let i = typeof r == "string" ? r : r.source;
|
|
1149
|
+
return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
|
|
1098
1150
|
}, getRegex: () => new RegExp(t, e) };
|
|
1099
1151
|
return n;
|
|
1100
1152
|
}
|
|
@@ -1109,65 +1161,65 @@ var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[
|
|
|
1109
1161
|
var Te = /^(?:[ \t]*(?:\n|$))+/;
|
|
1110
1162
|
var Oe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
1111
1163
|
var we = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
1112
|
-
var
|
|
1164
|
+
var I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
1113
1165
|
var ye = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
1114
1166
|
var Q = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
1115
1167
|
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 =
|
|
1117
|
-
var Pe =
|
|
1168
|
+
var oe = d(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();
|
|
1169
|
+
var Pe = d(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
1170
|
var j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
1119
1171
|
var Se = /^[^\n]+/;
|
|
1120
1172
|
var F = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
1121
|
-
var $e =
|
|
1122
|
-
var Le =
|
|
1173
|
+
var $e = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", F).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
1174
|
+
var Le = d(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Q).getRegex();
|
|
1123
1175
|
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
1176
|
var U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
1125
|
-
var _e =
|
|
1126
|
-
var ae =
|
|
1127
|
-
var Me =
|
|
1128
|
-
var K = { blockquote: Me, code: Oe, def: $e, fences: we, heading: ye, hr:
|
|
1129
|
-
var re =
|
|
1130
|
-
var ze = { ...K, lheading: Pe, table: re, paragraph:
|
|
1131
|
-
var Ee = { ...K, html:
|
|
1177
|
+
var _e = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \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();
|
|
1178
|
+
var ae = d(j).replace("hr", I).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();
|
|
1179
|
+
var Me = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex();
|
|
1180
|
+
var K = { blockquote: Me, code: Oe, def: $e, fences: we, heading: ye, hr: I, html: _e, lheading: oe, list: Le, newline: Te, paragraph: ae, table: _, text: Se };
|
|
1181
|
+
var re = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).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();
|
|
1182
|
+
var ze = { ...K, lheading: Pe, table: re, paragraph: d(j).replace("hr", I).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() };
|
|
1183
|
+
var Ee = { ...K, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(j).replace("hr", I).replace("heading", ` *#{1,6} *[^
|
|
1132
1184
|
]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
1133
|
-
var
|
|
1134
|
-
var
|
|
1185
|
+
var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
1186
|
+
var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
1135
1187
|
var le = /^( {2,}|\\)\n(?!\s*$)/;
|
|
1136
|
-
var
|
|
1188
|
+
var Ie = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
1137
1189
|
var E = /[\p{P}\p{S}]/u;
|
|
1138
1190
|
var H = /[\s\p{P}\p{S}]/u;
|
|
1139
1191
|
var W = /[^\s\p{P}\p{S}]/u;
|
|
1140
|
-
var Be =
|
|
1192
|
+
var Be = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, H).getRegex();
|
|
1141
1193
|
var ue = /(?!~)[\p{P}\p{S}]/u;
|
|
1142
1194
|
var De = /(?!~)[\s\p{P}\p{S}]/u;
|
|
1143
1195
|
var qe = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
1144
|
-
var ve =
|
|
1196
|
+
var ve = d(/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
1197
|
var pe = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
1146
|
-
var He =
|
|
1147
|
-
var Ze =
|
|
1198
|
+
var He = d(pe, "u").replace(/punct/g, E).getRegex();
|
|
1199
|
+
var Ze = d(pe, "u").replace(/punct/g, ue).getRegex();
|
|
1148
1200
|
var ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
1149
|
-
var Ge =
|
|
1150
|
-
var Ne =
|
|
1151
|
-
var Qe =
|
|
1152
|
-
var je =
|
|
1201
|
+
var Ge = d(ce, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1202
|
+
var Ne = d(ce, "gu").replace(/notPunctSpace/g, qe).replace(/punctSpace/g, De).replace(/punct/g, ue).getRegex();
|
|
1203
|
+
var Qe = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1204
|
+
var je = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, E).getRegex();
|
|
1153
1205
|
var Fe = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
1154
|
-
var Ue =
|
|
1155
|
-
var Ke =
|
|
1156
|
-
var We =
|
|
1157
|
-
var Xe =
|
|
1158
|
-
var Je =
|
|
1206
|
+
var Ue = d(Fe, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
|
|
1207
|
+
var Ke = d(/\\(punct)/, "gu").replace(/punct/g, E).getRegex();
|
|
1208
|
+
var We = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
1209
|
+
var Xe = d(U).replace("(?:-->|$)", "-->").getRegex();
|
|
1210
|
+
var Je = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Xe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
1159
1211
|
var q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
|
1160
|
-
var Ve =
|
|
1161
|
-
var he =
|
|
1162
|
-
var ke =
|
|
1163
|
-
var Ye =
|
|
1212
|
+
var Ve = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
1213
|
+
var he = d(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", F).getRegex();
|
|
1214
|
+
var ke = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex();
|
|
1215
|
+
var Ye = d("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
|
|
1164
1216
|
var se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
1165
|
-
var X = { _backpedal: _, anyPunctuation: Ke, autolink: We, blockSkip: ve, br: le, code:
|
|
1166
|
-
var et = { ...X, link:
|
|
1167
|
-
var N = { ...X, emStrongRDelimAst: Ne, emStrongLDelim: Ze, delLDelim: je, delRDelim: Ue, url:
|
|
1168
|
-
var tt = { ...N, br:
|
|
1217
|
+
var X = { _backpedal: _, anyPunctuation: Ke, autolink: We, blockSkip: ve, br: le, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: He, emStrongRDelimAst: Ge, emStrongRDelimUnd: Qe, escape: Ae, link: Ve, nolink: ke, punctuation: Be, reflink: he, reflinkSearch: Ye, tag: Je, text: Ie, url: _ };
|
|
1218
|
+
var et = { ...X, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
|
|
1219
|
+
var N = { ...X, emStrongRDelimAst: Ne, emStrongLDelim: Ze, delLDelim: je, delRDelim: Ue, url: d(/^((?: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: d(/^([`~]+|[^`~])(?:(?= {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() };
|
|
1220
|
+
var tt = { ...N, br: d(le).replace("{2,}", "*").getRegex(), text: d(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
1169
1221
|
var B = { normal: K, gfm: ze, pedantic: Ee };
|
|
1170
|
-
var
|
|
1222
|
+
var A = { normal: X, gfm: N, breaks: tt, pedantic: et };
|
|
1171
1223
|
var nt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
1172
1224
|
var de = (l) => nt[l];
|
|
1173
1225
|
function O(l, e) {
|
|
@@ -1187,42 +1239,42 @@ function J(l) {
|
|
|
1187
1239
|
return l;
|
|
1188
1240
|
}
|
|
1189
1241
|
function V(l, e) {
|
|
1190
|
-
let t = l.replace(m.findPipe, (
|
|
1191
|
-
let
|
|
1192
|
-
for (;--
|
|
1193
|
-
|
|
1194
|
-
return
|
|
1195
|
-
}), n = t.split(m.splitPipe),
|
|
1242
|
+
let t = l.replace(m.findPipe, (r, i, o) => {
|
|
1243
|
+
let u = false, a = i;
|
|
1244
|
+
for (;--a >= 0 && o[a] === "\\"; )
|
|
1245
|
+
u = !u;
|
|
1246
|
+
return u ? "|" : " |";
|
|
1247
|
+
}), n = t.split(m.splitPipe), s = 0;
|
|
1196
1248
|
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
|
|
1197
1249
|
if (n.length > e)
|
|
1198
1250
|
n.splice(e);
|
|
1199
1251
|
else
|
|
1200
1252
|
for (;n.length < e; )
|
|
1201
1253
|
n.push("");
|
|
1202
|
-
for (;
|
|
1203
|
-
n[
|
|
1254
|
+
for (;s < n.length; s++)
|
|
1255
|
+
n[s] = n[s].trim().replace(m.slashPipe, "|");
|
|
1204
1256
|
return n;
|
|
1205
1257
|
}
|
|
1206
1258
|
function $(l, e, t) {
|
|
1207
1259
|
let n = l.length;
|
|
1208
1260
|
if (n === 0)
|
|
1209
1261
|
return "";
|
|
1210
|
-
let
|
|
1211
|
-
for (;
|
|
1212
|
-
let
|
|
1213
|
-
if (
|
|
1214
|
-
|
|
1215
|
-
else if (
|
|
1216
|
-
|
|
1262
|
+
let s = 0;
|
|
1263
|
+
for (;s < n; ) {
|
|
1264
|
+
let r = l.charAt(n - s - 1);
|
|
1265
|
+
if (r === e && !t)
|
|
1266
|
+
s++;
|
|
1267
|
+
else if (r !== e && t)
|
|
1268
|
+
s++;
|
|
1217
1269
|
else
|
|
1218
1270
|
break;
|
|
1219
1271
|
}
|
|
1220
|
-
return l.slice(0, n -
|
|
1272
|
+
return l.slice(0, n - s);
|
|
1221
1273
|
}
|
|
1222
1274
|
function Y(l) {
|
|
1223
1275
|
let e = l.split(`
|
|
1224
1276
|
`), t = e.length - 1;
|
|
1225
|
-
for (;t >= 0 &&
|
|
1277
|
+
for (;t >= 0 && m.blankLine.test(e[t]); )
|
|
1226
1278
|
t--;
|
|
1227
1279
|
return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
|
|
1228
1280
|
`);
|
|
@@ -1242,32 +1294,32 @@ function ge(l, e) {
|
|
|
1242
1294
|
}
|
|
1243
1295
|
function fe(l, e = 0) {
|
|
1244
1296
|
let t = e, n = "";
|
|
1245
|
-
for (let
|
|
1246
|
-
if (
|
|
1247
|
-
let
|
|
1248
|
-
n += " ".repeat(
|
|
1297
|
+
for (let s of l)
|
|
1298
|
+
if (s === "\t") {
|
|
1299
|
+
let r = 4 - t % 4;
|
|
1300
|
+
n += " ".repeat(r), t += r;
|
|
1249
1301
|
} else
|
|
1250
|
-
n +=
|
|
1302
|
+
n += s, t++;
|
|
1251
1303
|
return n;
|
|
1252
1304
|
}
|
|
1253
|
-
function me(l, e, t, n,
|
|
1254
|
-
let
|
|
1305
|
+
function me(l, e, t, n, s) {
|
|
1306
|
+
let r = e.href, i = e.title || null, o = l[1].replace(s.other.outputLinkReplace, "$1");
|
|
1255
1307
|
n.state.inLink = true;
|
|
1256
|
-
let
|
|
1257
|
-
return n.state.inLink = false,
|
|
1308
|
+
let u = { type: l[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
|
|
1309
|
+
return n.state.inLink = false, u;
|
|
1258
1310
|
}
|
|
1259
1311
|
function rt(l, e, t) {
|
|
1260
1312
|
let n = l.match(t.other.indentCodeCompensation);
|
|
1261
1313
|
if (n === null)
|
|
1262
1314
|
return e;
|
|
1263
|
-
let
|
|
1315
|
+
let s = n[1];
|
|
1264
1316
|
return e.split(`
|
|
1265
|
-
`).map((
|
|
1266
|
-
let
|
|
1267
|
-
if (
|
|
1268
|
-
return
|
|
1269
|
-
let [
|
|
1270
|
-
return
|
|
1317
|
+
`).map((r) => {
|
|
1318
|
+
let i = r.match(t.other.beginningSpace);
|
|
1319
|
+
if (i === null)
|
|
1320
|
+
return r;
|
|
1321
|
+
let [o] = i;
|
|
1322
|
+
return o.length >= s.length ? r.slice(s.length) : r;
|
|
1271
1323
|
}).join(`
|
|
1272
1324
|
`);
|
|
1273
1325
|
}
|
|
@@ -1286,15 +1338,15 @@ var w = class {
|
|
|
1286
1338
|
code(e) {
|
|
1287
1339
|
let t = this.rules.block.code.exec(e);
|
|
1288
1340
|
if (t) {
|
|
1289
|
-
let n = this.options.pedantic ? t[0] : Y(t[0]),
|
|
1290
|
-
return { type: "code", raw: n, codeBlockStyle: "indented", text:
|
|
1341
|
+
let n = this.options.pedantic ? t[0] : Y(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
1342
|
+
return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
|
|
1291
1343
|
}
|
|
1292
1344
|
}
|
|
1293
1345
|
fences(e) {
|
|
1294
1346
|
let t = this.rules.block.fences.exec(e);
|
|
1295
1347
|
if (t) {
|
|
1296
|
-
let n = t[0],
|
|
1297
|
-
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text:
|
|
1348
|
+
let n = t[0], s = rt(n, t[3] || "", this.rules);
|
|
1349
|
+
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
1298
1350
|
}
|
|
1299
1351
|
}
|
|
1300
1352
|
heading(e) {
|
|
@@ -1302,8 +1354,8 @@ var w = class {
|
|
|
1302
1354
|
if (t) {
|
|
1303
1355
|
let n = t[2].trim();
|
|
1304
1356
|
if (this.rules.other.endingHash.test(n)) {
|
|
1305
|
-
let
|
|
1306
|
-
(this.options.pedantic || !
|
|
1357
|
+
let s = $(n, "#");
|
|
1358
|
+
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
|
|
1307
1359
|
}
|
|
1308
1360
|
return { type: "heading", raw: $(t[0], `
|
|
1309
1361
|
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
@@ -1320,118 +1372,119 @@ var w = class {
|
|
|
1320
1372
|
if (t) {
|
|
1321
1373
|
let n = $(t[0], `
|
|
1322
1374
|
`).split(`
|
|
1323
|
-
`),
|
|
1375
|
+
`), s = "", r = "", i = [];
|
|
1324
1376
|
for (;n.length > 0; ) {
|
|
1325
|
-
let
|
|
1326
|
-
for (
|
|
1327
|
-
if (this.rules.other.blockquoteStart.test(n[
|
|
1328
|
-
|
|
1329
|
-
else if (!
|
|
1330
|
-
|
|
1377
|
+
let o = false, u = [], a;
|
|
1378
|
+
for (a = 0;a < n.length; a++)
|
|
1379
|
+
if (this.rules.other.blockquoteStart.test(n[a]))
|
|
1380
|
+
u.push(n[a]), o = true;
|
|
1381
|
+
else if (!o)
|
|
1382
|
+
u.push(n[a]);
|
|
1331
1383
|
else
|
|
1332
1384
|
break;
|
|
1333
|
-
n = n.slice(
|
|
1334
|
-
let
|
|
1335
|
-
`),
|
|
1385
|
+
n = n.slice(a);
|
|
1386
|
+
let c = u.join(`
|
|
1387
|
+
`), p = c.replace(this.rules.other.blockquoteSetextReplace, `
|
|
1336
1388
|
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1337
|
-
|
|
1338
|
-
${
|
|
1339
|
-
${
|
|
1340
|
-
let
|
|
1341
|
-
if (this.lexer.state.top = true, this.lexer.blockTokens(
|
|
1389
|
+
s = s ? `${s}
|
|
1390
|
+
${c}` : c, r = r ? `${r}
|
|
1391
|
+
${p}` : p;
|
|
1392
|
+
let k = this.lexer.state.top;
|
|
1393
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(p, i, true), this.lexer.state.top = k, n.length === 0)
|
|
1342
1394
|
break;
|
|
1343
|
-
let h =
|
|
1395
|
+
let h = i.at(-1);
|
|
1344
1396
|
if (h?.type === "code")
|
|
1345
1397
|
break;
|
|
1346
1398
|
if (h?.type === "blockquote") {
|
|
1347
1399
|
let R = h, f = R.raw + `
|
|
1348
1400
|
` + n.join(`
|
|
1349
1401
|
`), S = this.blockquote(f);
|
|
1350
|
-
|
|
1402
|
+
i[i.length - 1] = S, s = s.substring(0, s.length - R.raw.length) + S.raw, r = r.substring(0, r.length - R.text.length) + S.text;
|
|
1351
1403
|
break;
|
|
1352
1404
|
} else if (h?.type === "list") {
|
|
1353
1405
|
let R = h, f = R.raw + `
|
|
1354
1406
|
` + n.join(`
|
|
1355
1407
|
`), S = this.list(f);
|
|
1356
|
-
|
|
1408
|
+
i[i.length - 1] = S, s = s.substring(0, s.length - h.raw.length) + S.raw, r = r.substring(0, r.length - R.raw.length) + S.raw, n = f.substring(i.at(-1).raw.length).split(`
|
|
1357
1409
|
`);
|
|
1358
1410
|
continue;
|
|
1359
1411
|
}
|
|
1360
1412
|
}
|
|
1361
|
-
return { type: "blockquote", raw:
|
|
1413
|
+
return { type: "blockquote", raw: s, tokens: i, text: r };
|
|
1362
1414
|
}
|
|
1363
1415
|
}
|
|
1364
1416
|
list(e) {
|
|
1365
1417
|
let t = this.rules.block.list.exec(e);
|
|
1366
1418
|
if (t) {
|
|
1367
|
-
let n = t[1].trim(),
|
|
1368
|
-
n =
|
|
1369
|
-
let
|
|
1419
|
+
let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
|
|
1420
|
+
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
1421
|
+
let i = this.rules.other.listItemRegex(n), o = false;
|
|
1370
1422
|
for (;e; ) {
|
|
1371
|
-
let
|
|
1372
|
-
if (!(t =
|
|
1423
|
+
let a = false, c = "", p = "";
|
|
1424
|
+
if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
|
|
1373
1425
|
break;
|
|
1374
|
-
|
|
1375
|
-
let
|
|
1426
|
+
c = t[0], e = e.substring(c.length);
|
|
1427
|
+
let k = fe(t[2].split(`
|
|
1376
1428
|
`, 1)[0], t[1].length), h = e.split(`
|
|
1377
|
-
`, 1)[0], R = !
|
|
1378
|
-
if (this.options.pedantic ? (f = 2,
|
|
1379
|
-
`, e = e.substring(h.length + 1),
|
|
1429
|
+
`, 1)[0], R = !k.trim(), f = 0;
|
|
1430
|
+
if (this.options.pedantic ? (f = 2, p = k.trimStart()) : R ? f = t[1].length + 1 : (f = k.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, p = k.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (c += h + `
|
|
1431
|
+
`, e = e.substring(h.length + 1), a = true), !a) {
|
|
1380
1432
|
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
1433
|
for (;e; ) {
|
|
1382
1434
|
let Z = e.split(`
|
|
1383
|
-
`, 1)[0],
|
|
1384
|
-
if (h = Z, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "),
|
|
1435
|
+
`, 1)[0], C;
|
|
1436
|
+
if (h = Z, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), C = h) : C = 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
1437
|
break;
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1388
|
-
` +
|
|
1438
|
+
if (C.search(this.rules.other.nonSpaceChar) >= f || !h.trim())
|
|
1439
|
+
p += `
|
|
1440
|
+
` + C.slice(f);
|
|
1389
1441
|
else {
|
|
1390
|
-
if (R ||
|
|
1442
|
+
if (R || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(k) || ne.test(k) || ee.test(k))
|
|
1391
1443
|
break;
|
|
1392
|
-
|
|
1444
|
+
p += `
|
|
1393
1445
|
` + h;
|
|
1394
1446
|
}
|
|
1395
|
-
R = !h.trim(),
|
|
1396
|
-
`, e = e.substring(Z.length + 1),
|
|
1447
|
+
R = !h.trim(), c += Z + `
|
|
1448
|
+
`, e = e.substring(Z.length + 1), k = C.slice(f);
|
|
1397
1449
|
}
|
|
1398
1450
|
}
|
|
1399
|
-
|
|
1451
|
+
r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(c) && (o = true)), r.items.push({ type: "list_item", raw: c, task: !!this.options.gfm && this.rules.other.listIsTask.test(p), loose: false, text: p, tokens: [] }), r.raw += c;
|
|
1400
1452
|
}
|
|
1401
|
-
let
|
|
1402
|
-
if (
|
|
1403
|
-
|
|
1453
|
+
let u = r.items.at(-1);
|
|
1454
|
+
if (u)
|
|
1455
|
+
u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
|
|
1404
1456
|
else
|
|
1405
1457
|
return;
|
|
1406
|
-
|
|
1407
|
-
for (let
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
let p = this.rules.other.listTaskCheckbox.exec(
|
|
1458
|
+
r.raw = r.raw.trimEnd();
|
|
1459
|
+
for (let a of r.items) {
|
|
1460
|
+
this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
|
|
1461
|
+
let c = a.tokens[0];
|
|
1462
|
+
if (a.task && (c?.type === "text" || c?.type === "paragraph")) {
|
|
1463
|
+
a.text = a.text.replace(this.rules.other.listReplaceTask, ""), c.raw = c.raw.replace(this.rules.other.listReplaceTask, ""), c.text = c.text.replace(this.rules.other.listReplaceTask, "");
|
|
1464
|
+
for (let k = this.lexer.inlineQueue.length - 1;k >= 0; k--)
|
|
1465
|
+
if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
|
|
1466
|
+
this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1469
|
+
let p = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
1418
1470
|
if (p) {
|
|
1419
|
-
let
|
|
1420
|
-
|
|
1471
|
+
let k = { type: "checkbox", raw: p[0] + " ", checked: p[0] !== "[ ]" };
|
|
1472
|
+
a.checked = k.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = k.raw + a.tokens[0].raw, a.tokens[0].text = k.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(k)) : a.tokens.unshift({ type: "paragraph", raw: k.raw, text: k.raw, tokens: [k] }) : a.tokens.unshift(k);
|
|
1421
1473
|
}
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1474
|
+
} else
|
|
1475
|
+
a.task && (a.task = false);
|
|
1476
|
+
if (!r.loose) {
|
|
1477
|
+
let p = a.tokens.filter((h) => h.type === "space"), k = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
|
|
1478
|
+
r.loose = k;
|
|
1426
1479
|
}
|
|
1427
1480
|
}
|
|
1428
|
-
if (
|
|
1429
|
-
for (let
|
|
1430
|
-
|
|
1431
|
-
for (let
|
|
1432
|
-
|
|
1481
|
+
if (r.loose)
|
|
1482
|
+
for (let a of r.items) {
|
|
1483
|
+
a.loose = true;
|
|
1484
|
+
for (let c of a.tokens)
|
|
1485
|
+
c.type === "text" && (c.type = "paragraph");
|
|
1433
1486
|
}
|
|
1434
|
-
return
|
|
1487
|
+
return r;
|
|
1435
1488
|
}
|
|
1436
1489
|
}
|
|
1437
1490
|
html(e) {
|
|
@@ -1444,26 +1497,26 @@ ${c}` : c;
|
|
|
1444
1497
|
def(e) {
|
|
1445
1498
|
let t = this.rules.block.def.exec(e);
|
|
1446
1499
|
if (t) {
|
|
1447
|
-
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "),
|
|
1500
|
+
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
1448
1501
|
return { type: "def", tag: n, raw: $(t[0], `
|
|
1449
|
-
`), href:
|
|
1502
|
+
`), href: s, title: r };
|
|
1450
1503
|
}
|
|
1451
1504
|
}
|
|
1452
1505
|
table(e) {
|
|
1453
1506
|
let t = this.rules.block.table.exec(e);
|
|
1454
1507
|
if (!t || !this.rules.other.tableDelimiter.test(t[2]))
|
|
1455
1508
|
return;
|
|
1456
|
-
let n = V(t[1]),
|
|
1457
|
-
`) : [],
|
|
1509
|
+
let n = V(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
1510
|
+
`) : [], i = { type: "table", raw: $(t[0], `
|
|
1458
1511
|
`), header: [], align: [], rows: [] };
|
|
1459
|
-
if (n.length ===
|
|
1460
|
-
for (let
|
|
1461
|
-
this.rules.other.tableAlignRight.test(
|
|
1462
|
-
for (let
|
|
1463
|
-
|
|
1464
|
-
for (let
|
|
1465
|
-
|
|
1466
|
-
return
|
|
1512
|
+
if (n.length === s.length) {
|
|
1513
|
+
for (let o of s)
|
|
1514
|
+
this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
|
|
1515
|
+
for (let o = 0;o < n.length; o++)
|
|
1516
|
+
i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
|
|
1517
|
+
for (let o of r)
|
|
1518
|
+
i.rows.push(V(o, i.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: i.align[a] })));
|
|
1519
|
+
return i;
|
|
1467
1520
|
}
|
|
1468
1521
|
}
|
|
1469
1522
|
lheading(e) {
|
|
@@ -1504,59 +1557,59 @@ ${c}` : c;
|
|
|
1504
1557
|
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
1505
1558
|
if (!this.rules.other.endAngleBracket.test(n))
|
|
1506
1559
|
return;
|
|
1507
|
-
let
|
|
1508
|
-
if ((n.length -
|
|
1560
|
+
let i = $(n.slice(0, -1), "\\");
|
|
1561
|
+
if ((n.length - i.length) % 2 === 0)
|
|
1509
1562
|
return;
|
|
1510
1563
|
} else {
|
|
1511
|
-
let
|
|
1512
|
-
if (
|
|
1564
|
+
let i = ge(t[2], "()");
|
|
1565
|
+
if (i === -2)
|
|
1513
1566
|
return;
|
|
1514
|
-
if (
|
|
1515
|
-
let
|
|
1516
|
-
t[2] = t[2].substring(0,
|
|
1567
|
+
if (i > -1) {
|
|
1568
|
+
let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
1569
|
+
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
|
|
1517
1570
|
}
|
|
1518
1571
|
}
|
|
1519
|
-
let
|
|
1572
|
+
let s = t[2], r = "";
|
|
1520
1573
|
if (this.options.pedantic) {
|
|
1521
|
-
let
|
|
1522
|
-
|
|
1574
|
+
let i = this.rules.other.pedanticHrefTitle.exec(s);
|
|
1575
|
+
i && (s = i[1], r = i[3]);
|
|
1523
1576
|
} else
|
|
1524
|
-
|
|
1525
|
-
return
|
|
1577
|
+
r = t[3] ? t[3].slice(1, -1) : "";
|
|
1578
|
+
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), me(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
|
|
1526
1579
|
}
|
|
1527
1580
|
}
|
|
1528
1581
|
reflink(e, t) {
|
|
1529
1582
|
let n;
|
|
1530
1583
|
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
1531
|
-
let
|
|
1532
|
-
if (!
|
|
1533
|
-
let
|
|
1534
|
-
return { type: "text", raw:
|
|
1584
|
+
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
|
|
1585
|
+
if (!r) {
|
|
1586
|
+
let i = n[0].charAt(0);
|
|
1587
|
+
return { type: "text", raw: i, text: i };
|
|
1535
1588
|
}
|
|
1536
|
-
return me(n,
|
|
1589
|
+
return me(n, r, n[0], this.lexer, this.rules);
|
|
1537
1590
|
}
|
|
1538
1591
|
}
|
|
1539
1592
|
emStrong(e, t, n = "") {
|
|
1540
|
-
let
|
|
1541
|
-
if (!
|
|
1593
|
+
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
1594
|
+
if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric))
|
|
1542
1595
|
return;
|
|
1543
|
-
if (!(
|
|
1544
|
-
let
|
|
1545
|
-
for (
|
|
1546
|
-
if (
|
|
1596
|
+
if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
1597
|
+
let i = [...s[0]].length - 1, o, u, a = i, c = 0, p = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
1598
|
+
for (p.lastIndex = 0, t = t.slice(-1 * e.length + i);(s = p.exec(t)) !== null; ) {
|
|
1599
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o)
|
|
1547
1600
|
continue;
|
|
1548
|
-
if (
|
|
1549
|
-
|
|
1601
|
+
if (u = [...o].length, s[3] || s[4]) {
|
|
1602
|
+
a += u;
|
|
1550
1603
|
continue;
|
|
1551
|
-
} else if ((
|
|
1552
|
-
|
|
1604
|
+
} else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
|
|
1605
|
+
c += u;
|
|
1553
1606
|
continue;
|
|
1554
1607
|
}
|
|
1555
|
-
if (
|
|
1608
|
+
if (a -= u, a > 0)
|
|
1556
1609
|
continue;
|
|
1557
|
-
|
|
1558
|
-
let
|
|
1559
|
-
if (Math.min(
|
|
1610
|
+
u = Math.min(u, u + a + c);
|
|
1611
|
+
let k = [...s[0]][0].length, h = e.slice(0, i + s.index + k + u);
|
|
1612
|
+
if (Math.min(i, u) % 2) {
|
|
1560
1613
|
let f = h.slice(1, -1);
|
|
1561
1614
|
return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
|
|
1562
1615
|
}
|
|
@@ -1568,8 +1621,8 @@ ${c}` : c;
|
|
|
1568
1621
|
codespan(e) {
|
|
1569
1622
|
let t = this.rules.inline.code.exec(e);
|
|
1570
1623
|
if (t) {
|
|
1571
|
-
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "),
|
|
1572
|
-
return
|
|
1624
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
1625
|
+
return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
1573
1626
|
}
|
|
1574
1627
|
}
|
|
1575
1628
|
br(e) {
|
|
@@ -1578,47 +1631,47 @@ ${c}` : c;
|
|
|
1578
1631
|
return { type: "br", raw: t[0] };
|
|
1579
1632
|
}
|
|
1580
1633
|
del(e, t, n = "") {
|
|
1581
|
-
let
|
|
1582
|
-
if (!
|
|
1634
|
+
let s = this.rules.inline.delLDelim.exec(e);
|
|
1635
|
+
if (!s)
|
|
1583
1636
|
return;
|
|
1584
|
-
if (!(
|
|
1585
|
-
let
|
|
1586
|
-
for (
|
|
1587
|
-
if (
|
|
1637
|
+
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
1638
|
+
let i = [...s[0]].length - 1, o, u, a = i, c = this.rules.inline.delRDelim;
|
|
1639
|
+
for (c.lastIndex = 0, t = t.slice(-1 * e.length + i);(s = c.exec(t)) !== null; ) {
|
|
1640
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i))
|
|
1588
1641
|
continue;
|
|
1589
|
-
if (
|
|
1590
|
-
|
|
1642
|
+
if (s[3] || s[4]) {
|
|
1643
|
+
a += u;
|
|
1591
1644
|
continue;
|
|
1592
1645
|
}
|
|
1593
|
-
if (
|
|
1646
|
+
if (a -= u, a > 0)
|
|
1594
1647
|
continue;
|
|
1595
|
-
|
|
1596
|
-
let
|
|
1597
|
-
return { type: "del", raw:
|
|
1648
|
+
u = Math.min(u, u + a);
|
|
1649
|
+
let p = [...s[0]][0].length, k = e.slice(0, i + s.index + p + u), h = k.slice(i, -i);
|
|
1650
|
+
return { type: "del", raw: k, text: h, tokens: this.lexer.inlineTokens(h) };
|
|
1598
1651
|
}
|
|
1599
1652
|
}
|
|
1600
1653
|
}
|
|
1601
1654
|
autolink(e) {
|
|
1602
1655
|
let t = this.rules.inline.autolink.exec(e);
|
|
1603
1656
|
if (t) {
|
|
1604
|
-
let n,
|
|
1605
|
-
return t[2] === "@" ? (n = t[1],
|
|
1657
|
+
let n, s;
|
|
1658
|
+
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
1606
1659
|
}
|
|
1607
1660
|
}
|
|
1608
1661
|
url(e) {
|
|
1609
1662
|
let t;
|
|
1610
1663
|
if (t = this.rules.inline.url.exec(e)) {
|
|
1611
|
-
let n,
|
|
1664
|
+
let n, s;
|
|
1612
1665
|
if (t[2] === "@")
|
|
1613
|
-
n = t[0],
|
|
1666
|
+
n = t[0], s = "mailto:" + n;
|
|
1614
1667
|
else {
|
|
1615
|
-
let
|
|
1668
|
+
let r;
|
|
1616
1669
|
do
|
|
1617
|
-
|
|
1618
|
-
while (
|
|
1619
|
-
n = t[0], t[1] === "www." ?
|
|
1670
|
+
r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
1671
|
+
while (r !== t[0]);
|
|
1672
|
+
n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
|
|
1620
1673
|
}
|
|
1621
|
-
return { type: "link", raw: t[0], text: n, href:
|
|
1674
|
+
return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
1622
1675
|
}
|
|
1623
1676
|
}
|
|
1624
1677
|
inlineText(e) {
|
|
@@ -1637,11 +1690,11 @@ var x = class l {
|
|
|
1637
1690
|
tokenizer;
|
|
1638
1691
|
constructor(e) {
|
|
1639
1692
|
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:
|
|
1641
|
-
this.options.pedantic ? (t.block = B.pedantic, t.inline =
|
|
1693
|
+
let t = { other: m, block: B.normal, inline: A.normal };
|
|
1694
|
+
this.options.pedantic ? (t.block = B.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = B.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t;
|
|
1642
1695
|
}
|
|
1643
1696
|
static get rules() {
|
|
1644
|
-
return { block: B, inline:
|
|
1697
|
+
return { block: B, inline: A };
|
|
1645
1698
|
}
|
|
1646
1699
|
static lex(e, t) {
|
|
1647
1700
|
return new l(t).lex(e);
|
|
@@ -1659,24 +1712,32 @@ var x = class l {
|
|
|
1659
1712
|
return this.inlineQueue = [], this.tokens;
|
|
1660
1713
|
}
|
|
1661
1714
|
blockTokens(e, t = [], n = false) {
|
|
1662
|
-
|
|
1715
|
+
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
|
|
1716
|
+
let s = 1 / 0;
|
|
1717
|
+
for (;e; ) {
|
|
1718
|
+
if (e.length < s)
|
|
1719
|
+
s = e.length;
|
|
1720
|
+
else {
|
|
1721
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1722
|
+
break;
|
|
1723
|
+
}
|
|
1663
1724
|
let r;
|
|
1664
|
-
if (this.options.extensions?.block?.some((
|
|
1725
|
+
if (this.options.extensions?.block?.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false))
|
|
1665
1726
|
continue;
|
|
1666
1727
|
if (r = this.tokenizer.space(e)) {
|
|
1667
1728
|
e = e.substring(r.raw.length);
|
|
1668
|
-
let
|
|
1669
|
-
r.raw.length === 1 &&
|
|
1729
|
+
let o = t.at(-1);
|
|
1730
|
+
r.raw.length === 1 && o !== undefined ? o.raw += `
|
|
1670
1731
|
` : t.push(r);
|
|
1671
1732
|
continue;
|
|
1672
1733
|
}
|
|
1673
1734
|
if (r = this.tokenizer.code(e)) {
|
|
1674
1735
|
e = e.substring(r.raw.length);
|
|
1675
|
-
let
|
|
1676
|
-
|
|
1736
|
+
let o = t.at(-1);
|
|
1737
|
+
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
1677
1738
|
`) ? "" : `
|
|
1678
|
-
`) + r.raw,
|
|
1679
|
-
` + r.text, this.inlineQueue.at(-1).src =
|
|
1739
|
+
`) + r.raw, o.text += `
|
|
1740
|
+
` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
1680
1741
|
continue;
|
|
1681
1742
|
}
|
|
1682
1743
|
if (r = this.tokenizer.fences(e)) {
|
|
@@ -1705,11 +1766,11 @@ var x = class l {
|
|
|
1705
1766
|
}
|
|
1706
1767
|
if (r = this.tokenizer.def(e)) {
|
|
1707
1768
|
e = e.substring(r.raw.length);
|
|
1708
|
-
let
|
|
1709
|
-
|
|
1769
|
+
let o = t.at(-1);
|
|
1770
|
+
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
1710
1771
|
`) ? "" : `
|
|
1711
|
-
`) + r.raw,
|
|
1712
|
-
` + r.raw, this.inlineQueue.at(-1).src =
|
|
1772
|
+
`) + r.raw, o.text += `
|
|
1773
|
+
` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
|
|
1713
1774
|
continue;
|
|
1714
1775
|
}
|
|
1715
1776
|
if (r = this.tokenizer.table(e)) {
|
|
@@ -1722,35 +1783,31 @@ var x = class l {
|
|
|
1722
1783
|
}
|
|
1723
1784
|
let i = e;
|
|
1724
1785
|
if (this.options.extensions?.startBlock) {
|
|
1725
|
-
let
|
|
1726
|
-
this.options.extensions.startBlock.forEach((
|
|
1727
|
-
|
|
1728
|
-
}),
|
|
1786
|
+
let o = 1 / 0, u = e.slice(1), a;
|
|
1787
|
+
this.options.extensions.startBlock.forEach((c) => {
|
|
1788
|
+
a = c.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
|
|
1789
|
+
}), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
|
|
1729
1790
|
}
|
|
1730
1791
|
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
1731
|
-
let
|
|
1732
|
-
n &&
|
|
1792
|
+
let o = t.at(-1);
|
|
1793
|
+
n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
|
|
1733
1794
|
`) ? "" : `
|
|
1734
|
-
`) + r.raw,
|
|
1735
|
-
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src =
|
|
1795
|
+
`) + r.raw, o.text += `
|
|
1796
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
|
|
1736
1797
|
continue;
|
|
1737
1798
|
}
|
|
1738
1799
|
if (r = this.tokenizer.text(e)) {
|
|
1739
1800
|
e = e.substring(r.raw.length);
|
|
1740
|
-
let
|
|
1741
|
-
|
|
1801
|
+
let o = t.at(-1);
|
|
1802
|
+
o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
1742
1803
|
`) ? "" : `
|
|
1743
|
-
`) + r.raw,
|
|
1744
|
-
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src =
|
|
1804
|
+
`) + r.raw, o.text += `
|
|
1805
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
1745
1806
|
continue;
|
|
1746
1807
|
}
|
|
1747
1808
|
if (e) {
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
console.error(s);
|
|
1751
|
-
break;
|
|
1752
|
-
} else
|
|
1753
|
-
throw new Error(s);
|
|
1809
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1810
|
+
break;
|
|
1754
1811
|
}
|
|
1755
1812
|
}
|
|
1756
1813
|
return this.state.top = true, t;
|
|
@@ -1760,91 +1817,100 @@ var x = class l {
|
|
|
1760
1817
|
}
|
|
1761
1818
|
inlineTokens(e, t = []) {
|
|
1762
1819
|
this.tokenizer.lexer = this;
|
|
1763
|
-
let n = e,
|
|
1820
|
+
let n = e, s = null;
|
|
1764
1821
|
if (this.tokens.links) {
|
|
1765
|
-
let
|
|
1766
|
-
if (
|
|
1767
|
-
for (;(
|
|
1768
|
-
|
|
1769
|
-
}
|
|
1770
|
-
for (;(
|
|
1771
|
-
n = n.slice(0,
|
|
1772
|
-
let
|
|
1773
|
-
for (;(
|
|
1774
|
-
|
|
1822
|
+
let a = Object.keys(this.tokens.links);
|
|
1823
|
+
if (a.length > 0)
|
|
1824
|
+
for (;(s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null; )
|
|
1825
|
+
a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
1826
|
+
}
|
|
1827
|
+
for (;(s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null; )
|
|
1828
|
+
n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1829
|
+
let r;
|
|
1830
|
+
for (;(s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null; )
|
|
1831
|
+
r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1775
1832
|
n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
1776
|
-
let
|
|
1833
|
+
let i = false, o = "", u = 1 / 0;
|
|
1777
1834
|
for (;e; ) {
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1835
|
+
if (e.length < u)
|
|
1836
|
+
u = e.length;
|
|
1837
|
+
else {
|
|
1838
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1839
|
+
break;
|
|
1840
|
+
}
|
|
1841
|
+
i || (o = ""), i = false;
|
|
1842
|
+
let a;
|
|
1843
|
+
if (this.options.extensions?.inline?.some((p) => (a = p.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false))
|
|
1781
1844
|
continue;
|
|
1782
|
-
if (
|
|
1783
|
-
e = e.substring(
|
|
1845
|
+
if (a = this.tokenizer.escape(e)) {
|
|
1846
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1784
1847
|
continue;
|
|
1785
1848
|
}
|
|
1786
|
-
if (
|
|
1787
|
-
e = e.substring(
|
|
1849
|
+
if (a = this.tokenizer.tag(e)) {
|
|
1850
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1788
1851
|
continue;
|
|
1789
1852
|
}
|
|
1790
|
-
if (
|
|
1791
|
-
e = e.substring(
|
|
1853
|
+
if (a = this.tokenizer.link(e)) {
|
|
1854
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1792
1855
|
continue;
|
|
1793
1856
|
}
|
|
1794
|
-
if (
|
|
1795
|
-
e = e.substring(
|
|
1857
|
+
if (a = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
1858
|
+
e = e.substring(a.raw.length);
|
|
1796
1859
|
let p = t.at(-1);
|
|
1797
|
-
|
|
1860
|
+
a.type === "text" && p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
|
|
1798
1861
|
continue;
|
|
1799
1862
|
}
|
|
1800
|
-
if (
|
|
1801
|
-
e = e.substring(
|
|
1863
|
+
if (a = this.tokenizer.emStrong(e, n, o)) {
|
|
1864
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1802
1865
|
continue;
|
|
1803
1866
|
}
|
|
1804
|
-
if (
|
|
1805
|
-
e = e.substring(
|
|
1867
|
+
if (a = this.tokenizer.codespan(e)) {
|
|
1868
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1806
1869
|
continue;
|
|
1807
1870
|
}
|
|
1808
|
-
if (
|
|
1809
|
-
e = e.substring(
|
|
1871
|
+
if (a = this.tokenizer.br(e)) {
|
|
1872
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1810
1873
|
continue;
|
|
1811
1874
|
}
|
|
1812
|
-
if (
|
|
1813
|
-
e = e.substring(
|
|
1875
|
+
if (a = this.tokenizer.del(e, n, o)) {
|
|
1876
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1814
1877
|
continue;
|
|
1815
1878
|
}
|
|
1816
|
-
if (
|
|
1817
|
-
e = e.substring(
|
|
1879
|
+
if (a = this.tokenizer.autolink(e)) {
|
|
1880
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1818
1881
|
continue;
|
|
1819
1882
|
}
|
|
1820
|
-
if (!this.state.inLink && (
|
|
1821
|
-
e = e.substring(
|
|
1883
|
+
if (!this.state.inLink && (a = this.tokenizer.url(e))) {
|
|
1884
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1822
1885
|
continue;
|
|
1823
1886
|
}
|
|
1824
|
-
let
|
|
1887
|
+
let c = e;
|
|
1825
1888
|
if (this.options.extensions?.startInline) {
|
|
1826
|
-
let p = 1 / 0,
|
|
1827
|
-
this.options.extensions.startInline.forEach((
|
|
1828
|
-
|
|
1829
|
-
}), p < 1 / 0 && p >= 0 && (
|
|
1889
|
+
let p = 1 / 0, k = e.slice(1), h;
|
|
1890
|
+
this.options.extensions.startInline.forEach((R) => {
|
|
1891
|
+
h = R.call({ lexer: this }, k), typeof h == "number" && h >= 0 && (p = Math.min(p, h));
|
|
1892
|
+
}), p < 1 / 0 && p >= 0 && (c = e.substring(0, p + 1));
|
|
1830
1893
|
}
|
|
1831
|
-
if (
|
|
1832
|
-
e = e.substring(
|
|
1894
|
+
if (a = this.tokenizer.inlineText(c)) {
|
|
1895
|
+
e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = true;
|
|
1833
1896
|
let p = t.at(-1);
|
|
1834
|
-
p?.type === "text" ? (p.raw +=
|
|
1897
|
+
p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
|
|
1835
1898
|
continue;
|
|
1836
1899
|
}
|
|
1837
1900
|
if (e) {
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
console.error(p);
|
|
1841
|
-
break;
|
|
1842
|
-
} else
|
|
1843
|
-
throw new Error(p);
|
|
1901
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1902
|
+
break;
|
|
1844
1903
|
}
|
|
1845
1904
|
}
|
|
1846
1905
|
return t;
|
|
1847
1906
|
}
|
|
1907
|
+
infiniteLoopError(e) {
|
|
1908
|
+
let t = "Infinite loop on byte: " + e;
|
|
1909
|
+
if (this.options.silent)
|
|
1910
|
+
console.error(t);
|
|
1911
|
+
else
|
|
1912
|
+
throw new Error(t);
|
|
1913
|
+
}
|
|
1848
1914
|
};
|
|
1849
1915
|
var y = class {
|
|
1850
1916
|
options;
|
|
@@ -1856,10 +1922,10 @@ var y = class {
|
|
|
1856
1922
|
return "";
|
|
1857
1923
|
}
|
|
1858
1924
|
code({ text: e, lang: t, escaped: n }) {
|
|
1859
|
-
let
|
|
1925
|
+
let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
|
|
1860
1926
|
`;
|
|
1861
|
-
return
|
|
1862
|
-
` : "<pre><code>" + (n ?
|
|
1927
|
+
return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
|
|
1928
|
+
` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
|
|
1863
1929
|
`;
|
|
1864
1930
|
}
|
|
1865
1931
|
blockquote({ tokens: e }) {
|
|
@@ -1882,14 +1948,14 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
1882
1948
|
`;
|
|
1883
1949
|
}
|
|
1884
1950
|
list(e) {
|
|
1885
|
-
let { ordered: t, start: n } = e,
|
|
1886
|
-
for (let
|
|
1887
|
-
let
|
|
1888
|
-
|
|
1889
|
-
}
|
|
1890
|
-
let
|
|
1891
|
-
return "<" +
|
|
1892
|
-
` +
|
|
1951
|
+
let { ordered: t, start: n } = e, s = "";
|
|
1952
|
+
for (let o = 0;o < e.items.length; o++) {
|
|
1953
|
+
let u = e.items[o];
|
|
1954
|
+
s += this.listitem(u);
|
|
1955
|
+
}
|
|
1956
|
+
let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
1957
|
+
return "<" + r + i + `>
|
|
1958
|
+
` + s + "</" + r + `>
|
|
1893
1959
|
`;
|
|
1894
1960
|
}
|
|
1895
1961
|
listitem(e) {
|
|
@@ -1905,21 +1971,21 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
1905
1971
|
}
|
|
1906
1972
|
table(e) {
|
|
1907
1973
|
let t = "", n = "";
|
|
1908
|
-
for (let
|
|
1909
|
-
n += this.tablecell(e.header[
|
|
1974
|
+
for (let r = 0;r < e.header.length; r++)
|
|
1975
|
+
n += this.tablecell(e.header[r]);
|
|
1910
1976
|
t += this.tablerow({ text: n });
|
|
1911
|
-
let
|
|
1912
|
-
for (let
|
|
1913
|
-
let
|
|
1977
|
+
let s = "";
|
|
1978
|
+
for (let r = 0;r < e.rows.length; r++) {
|
|
1979
|
+
let i = e.rows[r];
|
|
1914
1980
|
n = "";
|
|
1915
|
-
for (let
|
|
1916
|
-
n += this.tablecell(
|
|
1917
|
-
|
|
1981
|
+
for (let o = 0;o < i.length; o++)
|
|
1982
|
+
n += this.tablecell(i[o]);
|
|
1983
|
+
s += this.tablerow({ text: n });
|
|
1918
1984
|
}
|
|
1919
|
-
return
|
|
1985
|
+
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
1920
1986
|
<thead>
|
|
1921
1987
|
` + t + `</thead>
|
|
1922
|
-
` +
|
|
1988
|
+
` + s + `</table>
|
|
1923
1989
|
`;
|
|
1924
1990
|
}
|
|
1925
1991
|
tablerow({ text: e }) {
|
|
@@ -1948,21 +2014,21 @@ ${e}</tr>
|
|
|
1948
2014
|
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
1949
2015
|
}
|
|
1950
2016
|
link({ href: e, title: t, tokens: n }) {
|
|
1951
|
-
let
|
|
1952
|
-
if (
|
|
1953
|
-
return
|
|
1954
|
-
e =
|
|
1955
|
-
let
|
|
1956
|
-
return t && (
|
|
1957
|
-
}
|
|
1958
|
-
image({ href: e, title: t, text: n, tokens:
|
|
1959
|
-
|
|
1960
|
-
let
|
|
1961
|
-
if (
|
|
2017
|
+
let s = this.parser.parseInline(n), r = J(e);
|
|
2018
|
+
if (r === null)
|
|
2019
|
+
return s;
|
|
2020
|
+
e = r;
|
|
2021
|
+
let i = '<a href="' + e + '"';
|
|
2022
|
+
return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i;
|
|
2023
|
+
}
|
|
2024
|
+
image({ href: e, title: t, text: n, tokens: s }) {
|
|
2025
|
+
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
2026
|
+
let r = J(e);
|
|
2027
|
+
if (r === null)
|
|
1962
2028
|
return O(n);
|
|
1963
|
-
e =
|
|
1964
|
-
let
|
|
1965
|
-
return t && (
|
|
2029
|
+
e = r;
|
|
2030
|
+
let i = `<img src="${e}" alt="${O(n)}"`;
|
|
2031
|
+
return t && (i += ` title="${O(t)}"`), i += ">", i;
|
|
1966
2032
|
}
|
|
1967
2033
|
text(e) {
|
|
1968
2034
|
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : O(e.text);
|
|
@@ -2017,69 +2083,69 @@ var b = class l2 {
|
|
|
2017
2083
|
this.renderer.parser = this;
|
|
2018
2084
|
let t = "";
|
|
2019
2085
|
for (let n = 0;n < e.length; n++) {
|
|
2020
|
-
let
|
|
2021
|
-
if (this.options.extensions?.renderers?.[
|
|
2022
|
-
let
|
|
2023
|
-
if (
|
|
2024
|
-
t +=
|
|
2086
|
+
let s = e[n];
|
|
2087
|
+
if (this.options.extensions?.renderers?.[s.type]) {
|
|
2088
|
+
let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
2089
|
+
if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
2090
|
+
t += o || "";
|
|
2025
2091
|
continue;
|
|
2026
2092
|
}
|
|
2027
2093
|
}
|
|
2028
|
-
let
|
|
2029
|
-
switch (
|
|
2094
|
+
let r = s;
|
|
2095
|
+
switch (r.type) {
|
|
2030
2096
|
case "space": {
|
|
2031
|
-
t += this.renderer.space(
|
|
2097
|
+
t += this.renderer.space(r);
|
|
2032
2098
|
break;
|
|
2033
2099
|
}
|
|
2034
2100
|
case "hr": {
|
|
2035
|
-
t += this.renderer.hr(
|
|
2101
|
+
t += this.renderer.hr(r);
|
|
2036
2102
|
break;
|
|
2037
2103
|
}
|
|
2038
2104
|
case "heading": {
|
|
2039
|
-
t += this.renderer.heading(
|
|
2105
|
+
t += this.renderer.heading(r);
|
|
2040
2106
|
break;
|
|
2041
2107
|
}
|
|
2042
2108
|
case "code": {
|
|
2043
|
-
t += this.renderer.code(
|
|
2109
|
+
t += this.renderer.code(r);
|
|
2044
2110
|
break;
|
|
2045
2111
|
}
|
|
2046
2112
|
case "table": {
|
|
2047
|
-
t += this.renderer.table(
|
|
2113
|
+
t += this.renderer.table(r);
|
|
2048
2114
|
break;
|
|
2049
2115
|
}
|
|
2050
2116
|
case "blockquote": {
|
|
2051
|
-
t += this.renderer.blockquote(
|
|
2117
|
+
t += this.renderer.blockquote(r);
|
|
2052
2118
|
break;
|
|
2053
2119
|
}
|
|
2054
2120
|
case "list": {
|
|
2055
|
-
t += this.renderer.list(
|
|
2121
|
+
t += this.renderer.list(r);
|
|
2056
2122
|
break;
|
|
2057
2123
|
}
|
|
2058
2124
|
case "checkbox": {
|
|
2059
|
-
t += this.renderer.checkbox(
|
|
2125
|
+
t += this.renderer.checkbox(r);
|
|
2060
2126
|
break;
|
|
2061
2127
|
}
|
|
2062
2128
|
case "html": {
|
|
2063
|
-
t += this.renderer.html(
|
|
2129
|
+
t += this.renderer.html(r);
|
|
2064
2130
|
break;
|
|
2065
2131
|
}
|
|
2066
2132
|
case "def": {
|
|
2067
|
-
t += this.renderer.def(
|
|
2133
|
+
t += this.renderer.def(r);
|
|
2068
2134
|
break;
|
|
2069
2135
|
}
|
|
2070
2136
|
case "paragraph": {
|
|
2071
|
-
t += this.renderer.paragraph(
|
|
2137
|
+
t += this.renderer.paragraph(r);
|
|
2072
2138
|
break;
|
|
2073
2139
|
}
|
|
2074
2140
|
case "text": {
|
|
2075
|
-
t += this.renderer.text(
|
|
2141
|
+
t += this.renderer.text(r);
|
|
2076
2142
|
break;
|
|
2077
2143
|
}
|
|
2078
2144
|
default: {
|
|
2079
|
-
let
|
|
2145
|
+
let i = 'Token with "' + r.type + '" type was not found.';
|
|
2080
2146
|
if (this.options.silent)
|
|
2081
|
-
return console.error(
|
|
2082
|
-
throw new Error(
|
|
2147
|
+
return console.error(i), "";
|
|
2148
|
+
throw new Error(i);
|
|
2083
2149
|
}
|
|
2084
2150
|
}
|
|
2085
2151
|
}
|
|
@@ -2088,66 +2154,66 @@ var b = class l2 {
|
|
|
2088
2154
|
parseInline(e, t = this.renderer) {
|
|
2089
2155
|
this.renderer.parser = this;
|
|
2090
2156
|
let n = "";
|
|
2091
|
-
for (let
|
|
2092
|
-
let
|
|
2093
|
-
if (this.options.extensions?.renderers?.[
|
|
2094
|
-
let
|
|
2095
|
-
if (
|
|
2096
|
-
n +=
|
|
2157
|
+
for (let s = 0;s < e.length; s++) {
|
|
2158
|
+
let r = e[s];
|
|
2159
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
2160
|
+
let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
2161
|
+
if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
2162
|
+
n += o || "";
|
|
2097
2163
|
continue;
|
|
2098
2164
|
}
|
|
2099
2165
|
}
|
|
2100
|
-
let
|
|
2101
|
-
switch (
|
|
2166
|
+
let i = r;
|
|
2167
|
+
switch (i.type) {
|
|
2102
2168
|
case "escape": {
|
|
2103
|
-
n += t.text(
|
|
2169
|
+
n += t.text(i);
|
|
2104
2170
|
break;
|
|
2105
2171
|
}
|
|
2106
2172
|
case "html": {
|
|
2107
|
-
n += t.html(
|
|
2173
|
+
n += t.html(i);
|
|
2108
2174
|
break;
|
|
2109
2175
|
}
|
|
2110
2176
|
case "link": {
|
|
2111
|
-
n += t.link(
|
|
2177
|
+
n += t.link(i);
|
|
2112
2178
|
break;
|
|
2113
2179
|
}
|
|
2114
2180
|
case "image": {
|
|
2115
|
-
n += t.image(
|
|
2181
|
+
n += t.image(i);
|
|
2116
2182
|
break;
|
|
2117
2183
|
}
|
|
2118
2184
|
case "checkbox": {
|
|
2119
|
-
n += t.checkbox(
|
|
2185
|
+
n += t.checkbox(i);
|
|
2120
2186
|
break;
|
|
2121
2187
|
}
|
|
2122
2188
|
case "strong": {
|
|
2123
|
-
n += t.strong(
|
|
2189
|
+
n += t.strong(i);
|
|
2124
2190
|
break;
|
|
2125
2191
|
}
|
|
2126
2192
|
case "em": {
|
|
2127
|
-
n += t.em(
|
|
2193
|
+
n += t.em(i);
|
|
2128
2194
|
break;
|
|
2129
2195
|
}
|
|
2130
2196
|
case "codespan": {
|
|
2131
|
-
n += t.codespan(
|
|
2197
|
+
n += t.codespan(i);
|
|
2132
2198
|
break;
|
|
2133
2199
|
}
|
|
2134
2200
|
case "br": {
|
|
2135
|
-
n += t.br(
|
|
2201
|
+
n += t.br(i);
|
|
2136
2202
|
break;
|
|
2137
2203
|
}
|
|
2138
2204
|
case "del": {
|
|
2139
|
-
n += t.del(
|
|
2205
|
+
n += t.del(i);
|
|
2140
2206
|
break;
|
|
2141
2207
|
}
|
|
2142
2208
|
case "text": {
|
|
2143
|
-
n += t.text(
|
|
2209
|
+
n += t.text(i);
|
|
2144
2210
|
break;
|
|
2145
2211
|
}
|
|
2146
2212
|
default: {
|
|
2147
|
-
let
|
|
2213
|
+
let o = 'Token with "' + i.type + '" type was not found.';
|
|
2148
2214
|
if (this.options.silent)
|
|
2149
|
-
return console.error(
|
|
2150
|
-
throw new Error(
|
|
2215
|
+
return console.error(o), "";
|
|
2216
|
+
throw new Error(o);
|
|
2151
2217
|
}
|
|
2152
2218
|
}
|
|
2153
2219
|
}
|
|
@@ -2197,28 +2263,28 @@ var D = class {
|
|
|
2197
2263
|
}
|
|
2198
2264
|
walkTokens(e, t) {
|
|
2199
2265
|
let n = [];
|
|
2200
|
-
for (let
|
|
2201
|
-
switch (n = n.concat(t.call(this,
|
|
2266
|
+
for (let s of e)
|
|
2267
|
+
switch (n = n.concat(t.call(this, s)), s.type) {
|
|
2202
2268
|
case "table": {
|
|
2203
|
-
let
|
|
2204
|
-
for (let
|
|
2205
|
-
n = n.concat(this.walkTokens(
|
|
2206
|
-
for (let
|
|
2207
|
-
for (let
|
|
2208
|
-
n = n.concat(this.walkTokens(
|
|
2269
|
+
let r = s;
|
|
2270
|
+
for (let i of r.header)
|
|
2271
|
+
n = n.concat(this.walkTokens(i.tokens, t));
|
|
2272
|
+
for (let i of r.rows)
|
|
2273
|
+
for (let o of i)
|
|
2274
|
+
n = n.concat(this.walkTokens(o.tokens, t));
|
|
2209
2275
|
break;
|
|
2210
2276
|
}
|
|
2211
2277
|
case "list": {
|
|
2212
|
-
let
|
|
2213
|
-
n = n.concat(this.walkTokens(
|
|
2278
|
+
let r = s;
|
|
2279
|
+
n = n.concat(this.walkTokens(r.items, t));
|
|
2214
2280
|
break;
|
|
2215
2281
|
}
|
|
2216
2282
|
default: {
|
|
2217
|
-
let
|
|
2218
|
-
this.defaults.extensions?.childTokens?.[
|
|
2219
|
-
let
|
|
2220
|
-
n = n.concat(this.walkTokens(
|
|
2221
|
-
}) :
|
|
2283
|
+
let r = s;
|
|
2284
|
+
this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
|
|
2285
|
+
let o = r[i].flat(1 / 0);
|
|
2286
|
+
n = n.concat(this.walkTokens(o, t));
|
|
2287
|
+
}) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
|
|
2222
2288
|
}
|
|
2223
2289
|
}
|
|
2224
2290
|
return n;
|
|
@@ -2226,90 +2292,90 @@ var D = class {
|
|
|
2226
2292
|
use(...e) {
|
|
2227
2293
|
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
2228
2294
|
return e.forEach((n) => {
|
|
2229
|
-
let
|
|
2230
|
-
if (
|
|
2231
|
-
if (!
|
|
2295
|
+
let s = { ...n };
|
|
2296
|
+
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
2297
|
+
if (!r.name)
|
|
2232
2298
|
throw new Error("extension name required");
|
|
2233
|
-
if ("renderer" in
|
|
2234
|
-
let
|
|
2235
|
-
|
|
2236
|
-
let
|
|
2237
|
-
return
|
|
2238
|
-
} : t.renderers[
|
|
2299
|
+
if ("renderer" in r) {
|
|
2300
|
+
let i = t.renderers[r.name];
|
|
2301
|
+
i ? t.renderers[r.name] = function(...o) {
|
|
2302
|
+
let u = r.renderer.apply(this, o);
|
|
2303
|
+
return u === false && (u = i.apply(this, o)), u;
|
|
2304
|
+
} : t.renderers[r.name] = r.renderer;
|
|
2239
2305
|
}
|
|
2240
|
-
if ("tokenizer" in
|
|
2241
|
-
if (!
|
|
2306
|
+
if ("tokenizer" in r) {
|
|
2307
|
+
if (!r.level || r.level !== "block" && r.level !== "inline")
|
|
2242
2308
|
throw new Error("extension level must be 'block' or 'inline'");
|
|
2243
|
-
let
|
|
2244
|
-
|
|
2309
|
+
let i = t[r.level];
|
|
2310
|
+
i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
|
|
2245
2311
|
}
|
|
2246
|
-
"childTokens" in
|
|
2247
|
-
}),
|
|
2248
|
-
let
|
|
2249
|
-
for (let
|
|
2250
|
-
if (!(
|
|
2251
|
-
throw new Error(`renderer '${
|
|
2252
|
-
if (["options", "parser"].includes(
|
|
2312
|
+
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
2313
|
+
}), s.extensions = t), n.renderer) {
|
|
2314
|
+
let r = this.defaults.renderer || new y(this.defaults);
|
|
2315
|
+
for (let i in n.renderer) {
|
|
2316
|
+
if (!(i in r))
|
|
2317
|
+
throw new Error(`renderer '${i}' does not exist`);
|
|
2318
|
+
if (["options", "parser"].includes(i))
|
|
2253
2319
|
continue;
|
|
2254
|
-
let
|
|
2255
|
-
|
|
2256
|
-
let
|
|
2257
|
-
return
|
|
2320
|
+
let o = i, u = n.renderer[o], a = r[o];
|
|
2321
|
+
r[o] = (...c) => {
|
|
2322
|
+
let p = u.apply(r, c);
|
|
2323
|
+
return p === false && (p = a.apply(r, c)), p || "";
|
|
2258
2324
|
};
|
|
2259
2325
|
}
|
|
2260
|
-
|
|
2326
|
+
s.renderer = r;
|
|
2261
2327
|
}
|
|
2262
2328
|
if (n.tokenizer) {
|
|
2263
|
-
let
|
|
2264
|
-
for (let
|
|
2265
|
-
if (!(
|
|
2266
|
-
throw new Error(`tokenizer '${
|
|
2267
|
-
if (["options", "rules", "lexer"].includes(
|
|
2329
|
+
let r = this.defaults.tokenizer || new w(this.defaults);
|
|
2330
|
+
for (let i in n.tokenizer) {
|
|
2331
|
+
if (!(i in r))
|
|
2332
|
+
throw new Error(`tokenizer '${i}' does not exist`);
|
|
2333
|
+
if (["options", "rules", "lexer"].includes(i))
|
|
2268
2334
|
continue;
|
|
2269
|
-
let
|
|
2270
|
-
|
|
2271
|
-
let
|
|
2272
|
-
return
|
|
2335
|
+
let o = i, u = n.tokenizer[o], a = r[o];
|
|
2336
|
+
r[o] = (...c) => {
|
|
2337
|
+
let p = u.apply(r, c);
|
|
2338
|
+
return p === false && (p = a.apply(r, c)), p;
|
|
2273
2339
|
};
|
|
2274
2340
|
}
|
|
2275
|
-
|
|
2341
|
+
s.tokenizer = r;
|
|
2276
2342
|
}
|
|
2277
2343
|
if (n.hooks) {
|
|
2278
|
-
let
|
|
2279
|
-
for (let
|
|
2280
|
-
if (!(
|
|
2281
|
-
throw new Error(`hook '${
|
|
2282
|
-
if (["options", "block"].includes(
|
|
2344
|
+
let r = this.defaults.hooks || new P;
|
|
2345
|
+
for (let i in n.hooks) {
|
|
2346
|
+
if (!(i in r))
|
|
2347
|
+
throw new Error(`hook '${i}' does not exist`);
|
|
2348
|
+
if (["options", "block"].includes(i))
|
|
2283
2349
|
continue;
|
|
2284
|
-
let
|
|
2285
|
-
P.passThroughHooks.has(
|
|
2286
|
-
if (this.defaults.async && P.passThroughHooksRespectAsync.has(
|
|
2350
|
+
let o = i, u = n.hooks[o], a = r[o];
|
|
2351
|
+
P.passThroughHooks.has(i) ? r[o] = (c) => {
|
|
2352
|
+
if (this.defaults.async && P.passThroughHooksRespectAsync.has(i))
|
|
2287
2353
|
return (async () => {
|
|
2288
|
-
let
|
|
2289
|
-
return
|
|
2354
|
+
let k = await u.call(r, c);
|
|
2355
|
+
return a.call(r, k);
|
|
2290
2356
|
})();
|
|
2291
|
-
let
|
|
2292
|
-
return
|
|
2293
|
-
} :
|
|
2357
|
+
let p = u.call(r, c);
|
|
2358
|
+
return a.call(r, p);
|
|
2359
|
+
} : r[o] = (...c) => {
|
|
2294
2360
|
if (this.defaults.async)
|
|
2295
2361
|
return (async () => {
|
|
2296
|
-
let
|
|
2297
|
-
return
|
|
2362
|
+
let k = await u.apply(r, c);
|
|
2363
|
+
return k === false && (k = await a.apply(r, c)), k;
|
|
2298
2364
|
})();
|
|
2299
|
-
let
|
|
2300
|
-
return
|
|
2365
|
+
let p = u.apply(r, c);
|
|
2366
|
+
return p === false && (p = a.apply(r, c)), p;
|
|
2301
2367
|
};
|
|
2302
2368
|
}
|
|
2303
|
-
|
|
2369
|
+
s.hooks = r;
|
|
2304
2370
|
}
|
|
2305
2371
|
if (n.walkTokens) {
|
|
2306
|
-
let
|
|
2307
|
-
|
|
2308
|
-
let
|
|
2309
|
-
return
|
|
2372
|
+
let r = this.defaults.walkTokens, i = n.walkTokens;
|
|
2373
|
+
s.walkTokens = function(o) {
|
|
2374
|
+
let u = [];
|
|
2375
|
+
return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
|
|
2310
2376
|
};
|
|
2311
2377
|
}
|
|
2312
|
-
this.defaults = { ...this.defaults, ...
|
|
2378
|
+
this.defaults = { ...this.defaults, ...s };
|
|
2313
2379
|
}), this;
|
|
2314
2380
|
}
|
|
2315
2381
|
setOptions(e) {
|
|
@@ -2322,29 +2388,29 @@ var D = class {
|
|
|
2322
2388
|
return b.parse(e, t ?? this.defaults);
|
|
2323
2389
|
}
|
|
2324
2390
|
parseMarkdown(e) {
|
|
2325
|
-
return (n,
|
|
2326
|
-
let
|
|
2327
|
-
if (this.defaults.async === true &&
|
|
2328
|
-
return
|
|
2391
|
+
return (n, s) => {
|
|
2392
|
+
let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
|
|
2393
|
+
if (this.defaults.async === true && r.async === false)
|
|
2394
|
+
return o(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
2395
|
if (typeof n > "u" || n === null)
|
|
2330
|
-
return
|
|
2396
|
+
return o(new Error("marked(): input parameter is undefined or null"));
|
|
2331
2397
|
if (typeof n != "string")
|
|
2332
|
-
return
|
|
2333
|
-
if (
|
|
2398
|
+
return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
2399
|
+
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async)
|
|
2334
2400
|
return (async () => {
|
|
2335
|
-
let
|
|
2336
|
-
|
|
2337
|
-
let h = await (
|
|
2338
|
-
return
|
|
2339
|
-
})().catch(
|
|
2401
|
+
let u = i.hooks ? await i.hooks.preprocess(n) : n, c = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), p = i.hooks ? await i.hooks.processAllTokens(c) : c;
|
|
2402
|
+
i.walkTokens && await Promise.all(this.walkTokens(p, i.walkTokens));
|
|
2403
|
+
let h = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p, i);
|
|
2404
|
+
return i.hooks ? await i.hooks.postprocess(h) : h;
|
|
2405
|
+
})().catch(o);
|
|
2340
2406
|
try {
|
|
2341
|
-
|
|
2342
|
-
let
|
|
2343
|
-
|
|
2344
|
-
let
|
|
2345
|
-
return
|
|
2346
|
-
} catch (
|
|
2347
|
-
return
|
|
2407
|
+
i.hooks && (n = i.hooks.preprocess(n));
|
|
2408
|
+
let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
|
|
2409
|
+
i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
|
|
2410
|
+
let p = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
|
|
2411
|
+
return i.hooks && (p = i.hooks.postprocess(p)), p;
|
|
2412
|
+
} catch (u) {
|
|
2413
|
+
return o(u);
|
|
2348
2414
|
}
|
|
2349
2415
|
};
|
|
2350
2416
|
}
|
|
@@ -2352,8 +2418,8 @@ var D = class {
|
|
|
2352
2418
|
return (n) => {
|
|
2353
2419
|
if (n.message += `
|
|
2354
2420
|
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
2355
|
-
let
|
|
2356
|
-
return t ? Promise.resolve(
|
|
2421
|
+
let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
|
|
2422
|
+
return t ? Promise.resolve(s) : s;
|
|
2357
2423
|
}
|
|
2358
2424
|
if (t)
|
|
2359
2425
|
return Promise.reject(n);
|
|
@@ -2407,4 +2473,4 @@ export {
|
|
|
2407
2473
|
renderMarkdown
|
|
2408
2474
|
};
|
|
2409
2475
|
|
|
2410
|
-
//# debugId=
|
|
2476
|
+
//# debugId=EF7E49219AD0330B64756E2164756E21
|