@clevertask/scribe 0.0.1 → 0.0.2
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/{SlashCommandList-DYKFukY8.js → SlashCommandList-D_Ndw6pj.js} +272 -273
- package/dist/browser-D3_ToIiA.js +2110 -0
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +4 -5
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
- package/dist/components/Scribe/index.js +8 -9
- package/dist/main.d.ts +1 -0
- package/dist/turndown.browser.es-CeowJDZ0.js +1168 -0
- package/dist/utils/html-to-markdown.js +4 -5
- package/dist/utils/markdown-to-html.js +3 -4
- package/package.json +2 -2
- package/dist/marked.esm-DIt7dqAB.js +0 -1574
- package/dist/purify.es-Bzg5nW_L.js +0 -524
- package/dist/turndown.browser.es-DwgPoVx0.js +0 -646
|
@@ -0,0 +1,1168 @@
|
|
|
1
|
+
/*! @license DOMPurify 3.2.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.2.2/LICENSE */
|
|
2
|
+
const {
|
|
3
|
+
entries: Dt,
|
|
4
|
+
setPrototypeOf: Tt,
|
|
5
|
+
isFrozen: sn,
|
|
6
|
+
getPrototypeOf: cn,
|
|
7
|
+
getOwnPropertyDescriptor: fn
|
|
8
|
+
} = Object;
|
|
9
|
+
let {
|
|
10
|
+
freeze: v,
|
|
11
|
+
seal: C,
|
|
12
|
+
create: Lt
|
|
13
|
+
} = Object, {
|
|
14
|
+
apply: Fe,
|
|
15
|
+
construct: He
|
|
16
|
+
} = typeof Reflect < "u" && Reflect;
|
|
17
|
+
v || (v = function(t) {
|
|
18
|
+
return t;
|
|
19
|
+
});
|
|
20
|
+
C || (C = function(t) {
|
|
21
|
+
return t;
|
|
22
|
+
});
|
|
23
|
+
Fe || (Fe = function(t, r, i) {
|
|
24
|
+
return t.apply(r, i);
|
|
25
|
+
});
|
|
26
|
+
He || (He = function(t, r) {
|
|
27
|
+
return new t(...r);
|
|
28
|
+
});
|
|
29
|
+
const ue = L(Array.prototype.forEach), Et = L(Array.prototype.pop), Z = L(Array.prototype.push), pe = L(String.prototype.toLowerCase), Ce = L(String.prototype.toString), At = L(String.prototype.match), Q = L(String.prototype.replace), un = L(String.prototype.indexOf), mn = L(String.prototype.trim), I = L(Object.prototype.hasOwnProperty), N = L(RegExp.prototype.test), J = pn(TypeError);
|
|
30
|
+
function L(e) {
|
|
31
|
+
return function(t) {
|
|
32
|
+
for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), l = 1; l < r; l++)
|
|
33
|
+
i[l - 1] = arguments[l];
|
|
34
|
+
return Fe(e, t, i);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function pn(e) {
|
|
38
|
+
return function() {
|
|
39
|
+
for (var t = arguments.length, r = new Array(t), i = 0; i < t; i++)
|
|
40
|
+
r[i] = arguments[i];
|
|
41
|
+
return He(e, r);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function f(e, t) {
|
|
45
|
+
let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : pe;
|
|
46
|
+
Tt && Tt(e, null);
|
|
47
|
+
let i = t.length;
|
|
48
|
+
for (; i--; ) {
|
|
49
|
+
let l = t[i];
|
|
50
|
+
if (typeof l == "string") {
|
|
51
|
+
const c = r(l);
|
|
52
|
+
c !== l && (sn(t) || (t[i] = c), l = c);
|
|
53
|
+
}
|
|
54
|
+
e[l] = !0;
|
|
55
|
+
}
|
|
56
|
+
return e;
|
|
57
|
+
}
|
|
58
|
+
function dn(e) {
|
|
59
|
+
for (let t = 0; t < e.length; t++)
|
|
60
|
+
I(e, t) || (e[t] = null);
|
|
61
|
+
return e;
|
|
62
|
+
}
|
|
63
|
+
function U(e) {
|
|
64
|
+
const t = Lt(null);
|
|
65
|
+
for (const [r, i] of Dt(e))
|
|
66
|
+
I(e, r) && (Array.isArray(i) ? t[r] = dn(i) : i && typeof i == "object" && i.constructor === Object ? t[r] = U(i) : t[r] = i);
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
69
|
+
function ee(e, t) {
|
|
70
|
+
for (; e !== null; ) {
|
|
71
|
+
const i = fn(e, t);
|
|
72
|
+
if (i) {
|
|
73
|
+
if (i.get)
|
|
74
|
+
return L(i.get);
|
|
75
|
+
if (typeof i.value == "function")
|
|
76
|
+
return L(i.value);
|
|
77
|
+
}
|
|
78
|
+
e = cn(e);
|
|
79
|
+
}
|
|
80
|
+
function r() {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return r;
|
|
84
|
+
}
|
|
85
|
+
const _t = v(["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", "section", "select", "shadow", "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"]), Ie = v(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Me = v(["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"]), hn = v(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), we = v(["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"]), gn = v(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), St = v(["#text"]), Rt = v(["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", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "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", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), ke = v(["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", "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"]), yt = v(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "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"]), me = v(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Tn = C(/\{\{[\w\W]*|[\w\W]*\}\}/gm), En = C(/<%[\w\W]*|[\w\W]*%>/gm), An = C(/\${[\w\W]*}/gm), _n = C(/^data-[\-\w.\u00B7-\uFFFF]/), Sn = C(/^aria-[\-\w]+$/), Ct = C(
|
|
86
|
+
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
87
|
+
// eslint-disable-line no-useless-escape
|
|
88
|
+
), Rn = C(/^(?:\w+script|data):/i), yn = C(
|
|
89
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
90
|
+
// eslint-disable-line no-control-regex
|
|
91
|
+
), It = C(/^html$/i), Nn = C(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
92
|
+
var Nt = /* @__PURE__ */ Object.freeze({
|
|
93
|
+
__proto__: null,
|
|
94
|
+
ARIA_ATTR: Sn,
|
|
95
|
+
ATTR_WHITESPACE: yn,
|
|
96
|
+
CUSTOM_ELEMENT: Nn,
|
|
97
|
+
DATA_ATTR: _n,
|
|
98
|
+
DOCTYPE_NAME: It,
|
|
99
|
+
ERB_EXPR: En,
|
|
100
|
+
IS_ALLOWED_URI: Ct,
|
|
101
|
+
IS_SCRIPT_OR_DATA: Rn,
|
|
102
|
+
MUSTACHE_EXPR: Tn,
|
|
103
|
+
TMPLIT_EXPR: An
|
|
104
|
+
});
|
|
105
|
+
const te = {
|
|
106
|
+
element: 1,
|
|
107
|
+
attribute: 2,
|
|
108
|
+
text: 3,
|
|
109
|
+
cdataSection: 4,
|
|
110
|
+
entityReference: 5,
|
|
111
|
+
// Deprecated
|
|
112
|
+
entityNode: 6,
|
|
113
|
+
// Deprecated
|
|
114
|
+
progressingInstruction: 7,
|
|
115
|
+
comment: 8,
|
|
116
|
+
document: 9,
|
|
117
|
+
documentType: 10,
|
|
118
|
+
documentFragment: 11,
|
|
119
|
+
notation: 12
|
|
120
|
+
// Deprecated
|
|
121
|
+
}, vn = function() {
|
|
122
|
+
return typeof window > "u" ? null : window;
|
|
123
|
+
}, On = function(t, r) {
|
|
124
|
+
if (typeof t != "object" || typeof t.createPolicy != "function")
|
|
125
|
+
return null;
|
|
126
|
+
let i = null;
|
|
127
|
+
const l = "data-tt-policy-suffix";
|
|
128
|
+
r && r.hasAttribute(l) && (i = r.getAttribute(l));
|
|
129
|
+
const c = "dompurify" + (i ? "#" + i : "");
|
|
130
|
+
try {
|
|
131
|
+
return t.createPolicy(c, {
|
|
132
|
+
createHTML(p) {
|
|
133
|
+
return p;
|
|
134
|
+
},
|
|
135
|
+
createScriptURL(p) {
|
|
136
|
+
return p;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
} catch {
|
|
140
|
+
return console.warn("TrustedTypes policy " + c + " could not be created."), null;
|
|
141
|
+
}
|
|
142
|
+
}, vt = function() {
|
|
143
|
+
return {
|
|
144
|
+
afterSanitizeAttributes: [],
|
|
145
|
+
afterSanitizeElements: [],
|
|
146
|
+
afterSanitizeShadowDOM: [],
|
|
147
|
+
beforeSanitizeAttributes: [],
|
|
148
|
+
beforeSanitizeElements: [],
|
|
149
|
+
beforeSanitizeShadowDOM: [],
|
|
150
|
+
uponSanitizeAttribute: [],
|
|
151
|
+
uponSanitizeElement: [],
|
|
152
|
+
uponSanitizeShadowNode: []
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
function Mt() {
|
|
156
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : vn();
|
|
157
|
+
const t = (s) => Mt(s);
|
|
158
|
+
if (t.version = "3.2.2", t.removed = [], !e || !e.document || e.document.nodeType !== te.document)
|
|
159
|
+
return t.isSupported = !1, t;
|
|
160
|
+
let {
|
|
161
|
+
document: r
|
|
162
|
+
} = e;
|
|
163
|
+
const i = r, l = i.currentScript, {
|
|
164
|
+
DocumentFragment: c,
|
|
165
|
+
HTMLTemplateElement: p,
|
|
166
|
+
Node: O,
|
|
167
|
+
Element: m,
|
|
168
|
+
NodeFilter: S,
|
|
169
|
+
NamedNodeMap: F = e.NamedNodeMap || e.MozNamedAttrMap,
|
|
170
|
+
HTMLFormElement: he,
|
|
171
|
+
DOMParser: Bt,
|
|
172
|
+
trustedTypes: ne
|
|
173
|
+
} = e, $ = m.prototype, zt = ee($, "cloneNode"), Wt = ee($, "remove"), Gt = ee($, "nextSibling"), Yt = ee($, "childNodes"), re = ee($, "parentNode");
|
|
174
|
+
if (typeof p == "function") {
|
|
175
|
+
const s = r.createElement("template");
|
|
176
|
+
s.content && s.content.ownerDocument && (r = s.content.ownerDocument);
|
|
177
|
+
}
|
|
178
|
+
let R, V = "";
|
|
179
|
+
const {
|
|
180
|
+
implementation: ge,
|
|
181
|
+
createNodeIterator: $t,
|
|
182
|
+
createDocumentFragment: Vt,
|
|
183
|
+
getElementsByTagName: Xt
|
|
184
|
+
} = r, {
|
|
185
|
+
importNode: jt
|
|
186
|
+
} = i;
|
|
187
|
+
let D = vt();
|
|
188
|
+
t.isSupported = typeof Dt == "function" && typeof re == "function" && ge && ge.createHTMLDocument !== void 0;
|
|
189
|
+
const {
|
|
190
|
+
MUSTACHE_EXPR: Te,
|
|
191
|
+
ERB_EXPR: Ee,
|
|
192
|
+
TMPLIT_EXPR: Ae,
|
|
193
|
+
DATA_ATTR: Kt,
|
|
194
|
+
ARIA_ATTR: qt,
|
|
195
|
+
IS_SCRIPT_OR_DATA: Zt,
|
|
196
|
+
ATTR_WHITESPACE: $e,
|
|
197
|
+
CUSTOM_ELEMENT: Qt
|
|
198
|
+
} = Nt;
|
|
199
|
+
let {
|
|
200
|
+
IS_ALLOWED_URI: Ve
|
|
201
|
+
} = Nt, h = null;
|
|
202
|
+
const Xe = f({}, [..._t, ...Ie, ...Me, ...we, ...St]);
|
|
203
|
+
let T = null;
|
|
204
|
+
const je = f({}, [...Rt, ...ke, ...yt, ...me]);
|
|
205
|
+
let d = Object.seal(Lt(null, {
|
|
206
|
+
tagNameCheck: {
|
|
207
|
+
writable: !0,
|
|
208
|
+
configurable: !1,
|
|
209
|
+
enumerable: !0,
|
|
210
|
+
value: null
|
|
211
|
+
},
|
|
212
|
+
attributeNameCheck: {
|
|
213
|
+
writable: !0,
|
|
214
|
+
configurable: !1,
|
|
215
|
+
enumerable: !0,
|
|
216
|
+
value: null
|
|
217
|
+
},
|
|
218
|
+
allowCustomizedBuiltInElements: {
|
|
219
|
+
writable: !0,
|
|
220
|
+
configurable: !1,
|
|
221
|
+
enumerable: !0,
|
|
222
|
+
value: !1
|
|
223
|
+
}
|
|
224
|
+
})), X = null, _e = null, Ke = !0, Se = !0, qe = !1, Ze = !0, H = !1, Re = !0, x = !1, ye = !1, Ne = !1, B = !1, ie = !1, ae = !1, Qe = !0, Je = !1;
|
|
225
|
+
const Jt = "user-content-";
|
|
226
|
+
let ve = !0, j = !1, z = {}, W = null;
|
|
227
|
+
const et = f({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
|
|
228
|
+
let tt = null;
|
|
229
|
+
const nt = f({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
230
|
+
let Oe = null;
|
|
231
|
+
const rt = f({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), oe = "http://www.w3.org/1998/Math/MathML", le = "http://www.w3.org/2000/svg", k = "http://www.w3.org/1999/xhtml";
|
|
232
|
+
let G = k, be = !1, De = null;
|
|
233
|
+
const en = f({}, [oe, le, k], Ce);
|
|
234
|
+
let se = f({}, ["mi", "mo", "mn", "ms", "mtext"]), ce = f({}, ["annotation-xml"]);
|
|
235
|
+
const tn = f({}, ["title", "style", "font", "a", "script"]);
|
|
236
|
+
let K = null;
|
|
237
|
+
const nn = ["application/xhtml+xml", "text/html"], rn = "text/html";
|
|
238
|
+
let g = null, Y = null;
|
|
239
|
+
const an = r.createElement("form"), it = function(n) {
|
|
240
|
+
return n instanceof RegExp || n instanceof Function;
|
|
241
|
+
}, Le = function() {
|
|
242
|
+
let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
243
|
+
if (!(Y && Y === n)) {
|
|
244
|
+
if ((!n || typeof n != "object") && (n = {}), n = U(n), K = // eslint-disable-next-line unicorn/prefer-includes
|
|
245
|
+
nn.indexOf(n.PARSER_MEDIA_TYPE) === -1 ? rn : n.PARSER_MEDIA_TYPE, g = K === "application/xhtml+xml" ? Ce : pe, h = I(n, "ALLOWED_TAGS") ? f({}, n.ALLOWED_TAGS, g) : Xe, T = I(n, "ALLOWED_ATTR") ? f({}, n.ALLOWED_ATTR, g) : je, De = I(n, "ALLOWED_NAMESPACES") ? f({}, n.ALLOWED_NAMESPACES, Ce) : en, Oe = I(n, "ADD_URI_SAFE_ATTR") ? f(U(rt), n.ADD_URI_SAFE_ATTR, g) : rt, tt = I(n, "ADD_DATA_URI_TAGS") ? f(U(nt), n.ADD_DATA_URI_TAGS, g) : nt, W = I(n, "FORBID_CONTENTS") ? f({}, n.FORBID_CONTENTS, g) : et, X = I(n, "FORBID_TAGS") ? f({}, n.FORBID_TAGS, g) : {}, _e = I(n, "FORBID_ATTR") ? f({}, n.FORBID_ATTR, g) : {}, z = I(n, "USE_PROFILES") ? n.USE_PROFILES : !1, Ke = n.ALLOW_ARIA_ATTR !== !1, Se = n.ALLOW_DATA_ATTR !== !1, qe = n.ALLOW_UNKNOWN_PROTOCOLS || !1, Ze = n.ALLOW_SELF_CLOSE_IN_ATTR !== !1, H = n.SAFE_FOR_TEMPLATES || !1, Re = n.SAFE_FOR_XML !== !1, x = n.WHOLE_DOCUMENT || !1, B = n.RETURN_DOM || !1, ie = n.RETURN_DOM_FRAGMENT || !1, ae = n.RETURN_TRUSTED_TYPE || !1, Ne = n.FORCE_BODY || !1, Qe = n.SANITIZE_DOM !== !1, Je = n.SANITIZE_NAMED_PROPS || !1, ve = n.KEEP_CONTENT !== !1, j = n.IN_PLACE || !1, Ve = n.ALLOWED_URI_REGEXP || Ct, G = n.NAMESPACE || k, se = n.MATHML_TEXT_INTEGRATION_POINTS || se, ce = n.HTML_INTEGRATION_POINTS || ce, d = n.CUSTOM_ELEMENT_HANDLING || {}, n.CUSTOM_ELEMENT_HANDLING && it(n.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (d.tagNameCheck = n.CUSTOM_ELEMENT_HANDLING.tagNameCheck), n.CUSTOM_ELEMENT_HANDLING && it(n.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (d.attributeNameCheck = n.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), n.CUSTOM_ELEMENT_HANDLING && typeof n.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (d.allowCustomizedBuiltInElements = n.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), H && (Se = !1), ie && (B = !0), z && (h = f({}, St), T = [], z.html === !0 && (f(h, _t), f(T, Rt)), z.svg === !0 && (f(h, Ie), f(T, ke), f(T, me)), z.svgFilters === !0 && (f(h, Me), f(T, ke), f(T, me)), z.mathMl === !0 && (f(h, we), f(T, yt), f(T, me))), n.ADD_TAGS && (h === Xe && (h = U(h)), f(h, n.ADD_TAGS, g)), n.ADD_ATTR && (T === je && (T = U(T)), f(T, n.ADD_ATTR, g)), n.ADD_URI_SAFE_ATTR && f(Oe, n.ADD_URI_SAFE_ATTR, g), n.FORBID_CONTENTS && (W === et && (W = U(W)), f(W, n.FORBID_CONTENTS, g)), ve && (h["#text"] = !0), x && f(h, ["html", "head", "body"]), h.table && (f(h, ["tbody"]), delete X.tbody), n.TRUSTED_TYPES_POLICY) {
|
|
246
|
+
if (typeof n.TRUSTED_TYPES_POLICY.createHTML != "function")
|
|
247
|
+
throw J('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
248
|
+
if (typeof n.TRUSTED_TYPES_POLICY.createScriptURL != "function")
|
|
249
|
+
throw J('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
250
|
+
R = n.TRUSTED_TYPES_POLICY, V = R.createHTML("");
|
|
251
|
+
} else
|
|
252
|
+
R === void 0 && (R = On(ne, l)), R !== null && typeof V == "string" && (V = R.createHTML(""));
|
|
253
|
+
v && v(n), Y = n;
|
|
254
|
+
}
|
|
255
|
+
}, at = f({}, [...Ie, ...Me, ...hn]), ot = f({}, [...we, ...gn]), on = function(n) {
|
|
256
|
+
let a = re(n);
|
|
257
|
+
(!a || !a.tagName) && (a = {
|
|
258
|
+
namespaceURI: G,
|
|
259
|
+
tagName: "template"
|
|
260
|
+
});
|
|
261
|
+
const o = pe(n.tagName), u = pe(a.tagName);
|
|
262
|
+
return De[n.namespaceURI] ? n.namespaceURI === le ? a.namespaceURI === k ? o === "svg" : a.namespaceURI === oe ? o === "svg" && (u === "annotation-xml" || se[u]) : !!at[o] : n.namespaceURI === oe ? a.namespaceURI === k ? o === "math" : a.namespaceURI === le ? o === "math" && ce[u] : !!ot[o] : n.namespaceURI === k ? a.namespaceURI === le && !ce[u] || a.namespaceURI === oe && !se[u] ? !1 : !ot[o] && (tn[o] || !at[o]) : !!(K === "application/xhtml+xml" && De[n.namespaceURI]) : !1;
|
|
263
|
+
}, M = function(n) {
|
|
264
|
+
Z(t.removed, {
|
|
265
|
+
element: n
|
|
266
|
+
});
|
|
267
|
+
try {
|
|
268
|
+
re(n).removeChild(n);
|
|
269
|
+
} catch {
|
|
270
|
+
Wt(n);
|
|
271
|
+
}
|
|
272
|
+
}, fe = function(n, a) {
|
|
273
|
+
try {
|
|
274
|
+
Z(t.removed, {
|
|
275
|
+
attribute: a.getAttributeNode(n),
|
|
276
|
+
from: a
|
|
277
|
+
});
|
|
278
|
+
} catch {
|
|
279
|
+
Z(t.removed, {
|
|
280
|
+
attribute: null,
|
|
281
|
+
from: a
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
if (a.removeAttribute(n), n === "is")
|
|
285
|
+
if (B || ie)
|
|
286
|
+
try {
|
|
287
|
+
M(a);
|
|
288
|
+
} catch {
|
|
289
|
+
}
|
|
290
|
+
else
|
|
291
|
+
try {
|
|
292
|
+
a.setAttribute(n, "");
|
|
293
|
+
} catch {
|
|
294
|
+
}
|
|
295
|
+
}, lt = function(n) {
|
|
296
|
+
let a = null, o = null;
|
|
297
|
+
if (Ne)
|
|
298
|
+
n = "<remove></remove>" + n;
|
|
299
|
+
else {
|
|
300
|
+
const E = At(n, /^[\r\n\t ]+/);
|
|
301
|
+
o = E && E[0];
|
|
302
|
+
}
|
|
303
|
+
K === "application/xhtml+xml" && G === k && (n = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + n + "</body></html>");
|
|
304
|
+
const u = R ? R.createHTML(n) : n;
|
|
305
|
+
if (G === k)
|
|
306
|
+
try {
|
|
307
|
+
a = new Bt().parseFromString(u, K);
|
|
308
|
+
} catch {
|
|
309
|
+
}
|
|
310
|
+
if (!a || !a.documentElement) {
|
|
311
|
+
a = ge.createDocument(G, "template", null);
|
|
312
|
+
try {
|
|
313
|
+
a.documentElement.innerHTML = be ? V : u;
|
|
314
|
+
} catch {
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const A = a.body || a.documentElement;
|
|
318
|
+
return n && o && A.insertBefore(r.createTextNode(o), A.childNodes[0] || null), G === k ? Xt.call(a, x ? "html" : "body")[0] : x ? a.documentElement : A;
|
|
319
|
+
}, st = function(n) {
|
|
320
|
+
return $t.call(
|
|
321
|
+
n.ownerDocument || n,
|
|
322
|
+
n,
|
|
323
|
+
// eslint-disable-next-line no-bitwise
|
|
324
|
+
S.SHOW_ELEMENT | S.SHOW_COMMENT | S.SHOW_TEXT | S.SHOW_PROCESSING_INSTRUCTION | S.SHOW_CDATA_SECTION,
|
|
325
|
+
null
|
|
326
|
+
);
|
|
327
|
+
}, ct = function(n) {
|
|
328
|
+
return n instanceof he && (typeof n.nodeName != "string" || typeof n.textContent != "string" || typeof n.removeChild != "function" || !(n.attributes instanceof F) || typeof n.removeAttribute != "function" || typeof n.setAttribute != "function" || typeof n.namespaceURI != "string" || typeof n.insertBefore != "function" || typeof n.hasChildNodes != "function");
|
|
329
|
+
}, ft = function(n) {
|
|
330
|
+
return typeof O == "function" && n instanceof O;
|
|
331
|
+
};
|
|
332
|
+
function P(s, n, a) {
|
|
333
|
+
ue(s, (o) => {
|
|
334
|
+
o.call(t, n, a, Y);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
const ut = function(n) {
|
|
338
|
+
let a = null;
|
|
339
|
+
if (P(D.beforeSanitizeElements, n, null), ct(n))
|
|
340
|
+
return M(n), !0;
|
|
341
|
+
const o = g(n.nodeName);
|
|
342
|
+
if (P(D.uponSanitizeElement, n, {
|
|
343
|
+
tagName: o,
|
|
344
|
+
allowedTags: h
|
|
345
|
+
}), n.hasChildNodes() && !ft(n.firstElementChild) && N(/<[/\w]/g, n.innerHTML) && N(/<[/\w]/g, n.textContent) || n.nodeType === te.progressingInstruction || Re && n.nodeType === te.comment && N(/<[/\w]/g, n.data))
|
|
346
|
+
return M(n), !0;
|
|
347
|
+
if (!h[o] || X[o]) {
|
|
348
|
+
if (!X[o] && pt(o) && (d.tagNameCheck instanceof RegExp && N(d.tagNameCheck, o) || d.tagNameCheck instanceof Function && d.tagNameCheck(o)))
|
|
349
|
+
return !1;
|
|
350
|
+
if (ve && !W[o]) {
|
|
351
|
+
const u = re(n) || n.parentNode, A = Yt(n) || n.childNodes;
|
|
352
|
+
if (A && u) {
|
|
353
|
+
const E = A.length;
|
|
354
|
+
for (let b = E - 1; b >= 0; --b) {
|
|
355
|
+
const w = zt(A[b], !0);
|
|
356
|
+
w.__removalCount = (n.__removalCount || 0) + 1, u.insertBefore(w, Gt(n));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return M(n), !0;
|
|
361
|
+
}
|
|
362
|
+
return n instanceof m && !on(n) || (o === "noscript" || o === "noembed" || o === "noframes") && N(/<\/no(script|embed|frames)/i, n.innerHTML) ? (M(n), !0) : (H && n.nodeType === te.text && (a = n.textContent, ue([Te, Ee, Ae], (u) => {
|
|
363
|
+
a = Q(a, u, " ");
|
|
364
|
+
}), n.textContent !== a && (Z(t.removed, {
|
|
365
|
+
element: n.cloneNode()
|
|
366
|
+
}), n.textContent = a)), P(D.afterSanitizeElements, n, null), !1);
|
|
367
|
+
}, mt = function(n, a, o) {
|
|
368
|
+
if (Qe && (a === "id" || a === "name") && (o in r || o in an))
|
|
369
|
+
return !1;
|
|
370
|
+
if (!(Se && !_e[a] && N(Kt, a))) {
|
|
371
|
+
if (!(Ke && N(qt, a))) {
|
|
372
|
+
if (!T[a] || _e[a]) {
|
|
373
|
+
if (
|
|
374
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
375
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
376
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
377
|
+
!(pt(n) && (d.tagNameCheck instanceof RegExp && N(d.tagNameCheck, n) || d.tagNameCheck instanceof Function && d.tagNameCheck(n)) && (d.attributeNameCheck instanceof RegExp && N(d.attributeNameCheck, a) || d.attributeNameCheck instanceof Function && d.attributeNameCheck(a)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
378
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
379
|
+
a === "is" && d.allowCustomizedBuiltInElements && (d.tagNameCheck instanceof RegExp && N(d.tagNameCheck, o) || d.tagNameCheck instanceof Function && d.tagNameCheck(o)))
|
|
380
|
+
) return !1;
|
|
381
|
+
} else if (!Oe[a]) {
|
|
382
|
+
if (!N(Ve, Q(o, $e, ""))) {
|
|
383
|
+
if (!((a === "src" || a === "xlink:href" || a === "href") && n !== "script" && un(o, "data:") === 0 && tt[n])) {
|
|
384
|
+
if (!(qe && !N(Zt, Q(o, $e, "")))) {
|
|
385
|
+
if (o)
|
|
386
|
+
return !1;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return !0;
|
|
394
|
+
}, pt = function(n) {
|
|
395
|
+
return n !== "annotation-xml" && At(n, Qt);
|
|
396
|
+
}, dt = function(n) {
|
|
397
|
+
P(D.beforeSanitizeAttributes, n, null);
|
|
398
|
+
const {
|
|
399
|
+
attributes: a
|
|
400
|
+
} = n;
|
|
401
|
+
if (!a)
|
|
402
|
+
return;
|
|
403
|
+
const o = {
|
|
404
|
+
attrName: "",
|
|
405
|
+
attrValue: "",
|
|
406
|
+
keepAttr: !0,
|
|
407
|
+
allowedAttributes: T,
|
|
408
|
+
forceKeepAttr: void 0
|
|
409
|
+
};
|
|
410
|
+
let u = a.length;
|
|
411
|
+
for (; u--; ) {
|
|
412
|
+
const A = a[u], {
|
|
413
|
+
name: E,
|
|
414
|
+
namespaceURI: b,
|
|
415
|
+
value: w
|
|
416
|
+
} = A, q = g(E);
|
|
417
|
+
let y = E === "value" ? w : mn(w);
|
|
418
|
+
if (o.attrName = q, o.attrValue = y, o.keepAttr = !0, o.forceKeepAttr = void 0, P(D.uponSanitizeAttribute, n, o), y = o.attrValue, Je && (q === "id" || q === "name") && (fe(E, n), y = Jt + y), Re && N(/((--!?|])>)|<\/(style|title)/i, y)) {
|
|
419
|
+
fe(E, n);
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
if (o.forceKeepAttr || (fe(E, n), !o.keepAttr))
|
|
423
|
+
continue;
|
|
424
|
+
if (!Ze && N(/\/>/i, y)) {
|
|
425
|
+
fe(E, n);
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
H && ue([Te, Ee, Ae], (gt) => {
|
|
429
|
+
y = Q(y, gt, " ");
|
|
430
|
+
});
|
|
431
|
+
const ht = g(n.nodeName);
|
|
432
|
+
if (mt(ht, q, y)) {
|
|
433
|
+
if (R && typeof ne == "object" && typeof ne.getAttributeType == "function" && !b)
|
|
434
|
+
switch (ne.getAttributeType(ht, q)) {
|
|
435
|
+
case "TrustedHTML": {
|
|
436
|
+
y = R.createHTML(y);
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
case "TrustedScriptURL": {
|
|
440
|
+
y = R.createScriptURL(y);
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
try {
|
|
445
|
+
b ? n.setAttributeNS(b, E, y) : n.setAttribute(E, y), ct(n) ? M(n) : Et(t.removed);
|
|
446
|
+
} catch {
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
P(D.afterSanitizeAttributes, n, null);
|
|
451
|
+
}, ln = function s(n) {
|
|
452
|
+
let a = null;
|
|
453
|
+
const o = st(n);
|
|
454
|
+
for (P(D.beforeSanitizeShadowDOM, n, null); a = o.nextNode(); )
|
|
455
|
+
P(D.uponSanitizeShadowNode, a, null), !ut(a) && (a.content instanceof c && s(a.content), dt(a));
|
|
456
|
+
P(D.afterSanitizeShadowDOM, n, null);
|
|
457
|
+
};
|
|
458
|
+
return t.sanitize = function(s) {
|
|
459
|
+
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = null, o = null, u = null, A = null;
|
|
460
|
+
if (be = !s, be && (s = "<!-->"), typeof s != "string" && !ft(s))
|
|
461
|
+
if (typeof s.toString == "function") {
|
|
462
|
+
if (s = s.toString(), typeof s != "string")
|
|
463
|
+
throw J("dirty is not a string, aborting");
|
|
464
|
+
} else
|
|
465
|
+
throw J("toString is not a function");
|
|
466
|
+
if (!t.isSupported)
|
|
467
|
+
return s;
|
|
468
|
+
if (ye || Le(n), t.removed = [], typeof s == "string" && (j = !1), j) {
|
|
469
|
+
if (s.nodeName) {
|
|
470
|
+
const w = g(s.nodeName);
|
|
471
|
+
if (!h[w] || X[w])
|
|
472
|
+
throw J("root node is forbidden and cannot be sanitized in-place");
|
|
473
|
+
}
|
|
474
|
+
} else if (s instanceof O)
|
|
475
|
+
a = lt("<!---->"), o = a.ownerDocument.importNode(s, !0), o.nodeType === te.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? a = o : a.appendChild(o);
|
|
476
|
+
else {
|
|
477
|
+
if (!B && !H && !x && // eslint-disable-next-line unicorn/prefer-includes
|
|
478
|
+
s.indexOf("<") === -1)
|
|
479
|
+
return R && ae ? R.createHTML(s) : s;
|
|
480
|
+
if (a = lt(s), !a)
|
|
481
|
+
return B ? null : ae ? V : "";
|
|
482
|
+
}
|
|
483
|
+
a && Ne && M(a.firstChild);
|
|
484
|
+
const E = st(j ? s : a);
|
|
485
|
+
for (; u = E.nextNode(); )
|
|
486
|
+
ut(u) || (u.content instanceof c && ln(u.content), dt(u));
|
|
487
|
+
if (j)
|
|
488
|
+
return s;
|
|
489
|
+
if (B) {
|
|
490
|
+
if (ie)
|
|
491
|
+
for (A = Vt.call(a.ownerDocument); a.firstChild; )
|
|
492
|
+
A.appendChild(a.firstChild);
|
|
493
|
+
else
|
|
494
|
+
A = a;
|
|
495
|
+
return (T.shadowroot || T.shadowrootmode) && (A = jt.call(i, A, !0)), A;
|
|
496
|
+
}
|
|
497
|
+
let b = x ? a.outerHTML : a.innerHTML;
|
|
498
|
+
return x && h["!doctype"] && a.ownerDocument && a.ownerDocument.doctype && a.ownerDocument.doctype.name && N(It, a.ownerDocument.doctype.name) && (b = "<!DOCTYPE " + a.ownerDocument.doctype.name + `>
|
|
499
|
+
` + b), H && ue([Te, Ee, Ae], (w) => {
|
|
500
|
+
b = Q(b, w, " ");
|
|
501
|
+
}), R && ae ? R.createHTML(b) : b;
|
|
502
|
+
}, t.setConfig = function() {
|
|
503
|
+
let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
504
|
+
Le(s), ye = !0;
|
|
505
|
+
}, t.clearConfig = function() {
|
|
506
|
+
Y = null, ye = !1;
|
|
507
|
+
}, t.isValidAttribute = function(s, n, a) {
|
|
508
|
+
Y || Le({});
|
|
509
|
+
const o = g(s), u = g(n);
|
|
510
|
+
return mt(o, u, a);
|
|
511
|
+
}, t.addHook = function(s, n) {
|
|
512
|
+
typeof n == "function" && Z(D[s], n);
|
|
513
|
+
}, t.removeHook = function(s) {
|
|
514
|
+
return Et(D[s]);
|
|
515
|
+
}, t.removeHooks = function(s) {
|
|
516
|
+
D[s] = [];
|
|
517
|
+
}, t.removeAllHooks = function() {
|
|
518
|
+
D = vt();
|
|
519
|
+
}, t;
|
|
520
|
+
}
|
|
521
|
+
var Qn = Mt();
|
|
522
|
+
function bn(e) {
|
|
523
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
524
|
+
var r = arguments[t];
|
|
525
|
+
for (var i in r)
|
|
526
|
+
r.hasOwnProperty(i) && (e[i] = r[i]);
|
|
527
|
+
}
|
|
528
|
+
return e;
|
|
529
|
+
}
|
|
530
|
+
function Be(e, t) {
|
|
531
|
+
return Array(t + 1).join(e);
|
|
532
|
+
}
|
|
533
|
+
function Dn(e) {
|
|
534
|
+
return e.replace(/^\n*/, "");
|
|
535
|
+
}
|
|
536
|
+
function Ln(e) {
|
|
537
|
+
for (var t = e.length; t > 0 && e[t - 1] === `
|
|
538
|
+
`; ) t--;
|
|
539
|
+
return e.substring(0, t);
|
|
540
|
+
}
|
|
541
|
+
var Cn = [
|
|
542
|
+
"ADDRESS",
|
|
543
|
+
"ARTICLE",
|
|
544
|
+
"ASIDE",
|
|
545
|
+
"AUDIO",
|
|
546
|
+
"BLOCKQUOTE",
|
|
547
|
+
"BODY",
|
|
548
|
+
"CANVAS",
|
|
549
|
+
"CENTER",
|
|
550
|
+
"DD",
|
|
551
|
+
"DIR",
|
|
552
|
+
"DIV",
|
|
553
|
+
"DL",
|
|
554
|
+
"DT",
|
|
555
|
+
"FIELDSET",
|
|
556
|
+
"FIGCAPTION",
|
|
557
|
+
"FIGURE",
|
|
558
|
+
"FOOTER",
|
|
559
|
+
"FORM",
|
|
560
|
+
"FRAMESET",
|
|
561
|
+
"H1",
|
|
562
|
+
"H2",
|
|
563
|
+
"H3",
|
|
564
|
+
"H4",
|
|
565
|
+
"H5",
|
|
566
|
+
"H6",
|
|
567
|
+
"HEADER",
|
|
568
|
+
"HGROUP",
|
|
569
|
+
"HR",
|
|
570
|
+
"HTML",
|
|
571
|
+
"ISINDEX",
|
|
572
|
+
"LI",
|
|
573
|
+
"MAIN",
|
|
574
|
+
"MENU",
|
|
575
|
+
"NAV",
|
|
576
|
+
"NOFRAMES",
|
|
577
|
+
"NOSCRIPT",
|
|
578
|
+
"OL",
|
|
579
|
+
"OUTPUT",
|
|
580
|
+
"P",
|
|
581
|
+
"PRE",
|
|
582
|
+
"SECTION",
|
|
583
|
+
"TABLE",
|
|
584
|
+
"TBODY",
|
|
585
|
+
"TD",
|
|
586
|
+
"TFOOT",
|
|
587
|
+
"TH",
|
|
588
|
+
"THEAD",
|
|
589
|
+
"TR",
|
|
590
|
+
"UL"
|
|
591
|
+
];
|
|
592
|
+
function We(e) {
|
|
593
|
+
return Ge(e, Cn);
|
|
594
|
+
}
|
|
595
|
+
var wt = [
|
|
596
|
+
"AREA",
|
|
597
|
+
"BASE",
|
|
598
|
+
"BR",
|
|
599
|
+
"COL",
|
|
600
|
+
"COMMAND",
|
|
601
|
+
"EMBED",
|
|
602
|
+
"HR",
|
|
603
|
+
"IMG",
|
|
604
|
+
"INPUT",
|
|
605
|
+
"KEYGEN",
|
|
606
|
+
"LINK",
|
|
607
|
+
"META",
|
|
608
|
+
"PARAM",
|
|
609
|
+
"SOURCE",
|
|
610
|
+
"TRACK",
|
|
611
|
+
"WBR"
|
|
612
|
+
];
|
|
613
|
+
function kt(e) {
|
|
614
|
+
return Ge(e, wt);
|
|
615
|
+
}
|
|
616
|
+
function In(e) {
|
|
617
|
+
return xt(e, wt);
|
|
618
|
+
}
|
|
619
|
+
var Pt = [
|
|
620
|
+
"A",
|
|
621
|
+
"TABLE",
|
|
622
|
+
"THEAD",
|
|
623
|
+
"TBODY",
|
|
624
|
+
"TFOOT",
|
|
625
|
+
"TH",
|
|
626
|
+
"TD",
|
|
627
|
+
"IFRAME",
|
|
628
|
+
"SCRIPT",
|
|
629
|
+
"AUDIO",
|
|
630
|
+
"VIDEO"
|
|
631
|
+
];
|
|
632
|
+
function Mn(e) {
|
|
633
|
+
return Ge(e, Pt);
|
|
634
|
+
}
|
|
635
|
+
function wn(e) {
|
|
636
|
+
return xt(e, Pt);
|
|
637
|
+
}
|
|
638
|
+
function Ge(e, t) {
|
|
639
|
+
return t.indexOf(e.nodeName) >= 0;
|
|
640
|
+
}
|
|
641
|
+
function xt(e, t) {
|
|
642
|
+
return e.getElementsByTagName && t.some(function(r) {
|
|
643
|
+
return e.getElementsByTagName(r).length;
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
var _ = {};
|
|
647
|
+
_.paragraph = {
|
|
648
|
+
filter: "p",
|
|
649
|
+
replacement: function(e) {
|
|
650
|
+
return `
|
|
651
|
+
|
|
652
|
+
` + e + `
|
|
653
|
+
|
|
654
|
+
`;
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
_.lineBreak = {
|
|
658
|
+
filter: "br",
|
|
659
|
+
replacement: function(e, t, r) {
|
|
660
|
+
return r.br + `
|
|
661
|
+
`;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
_.heading = {
|
|
665
|
+
filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
|
|
666
|
+
replacement: function(e, t, r) {
|
|
667
|
+
var i = Number(t.nodeName.charAt(1));
|
|
668
|
+
if (r.headingStyle === "setext" && i < 3) {
|
|
669
|
+
var l = Be(i === 1 ? "=" : "-", e.length);
|
|
670
|
+
return `
|
|
671
|
+
|
|
672
|
+
` + e + `
|
|
673
|
+
` + l + `
|
|
674
|
+
|
|
675
|
+
`;
|
|
676
|
+
} else
|
|
677
|
+
return `
|
|
678
|
+
|
|
679
|
+
` + Be("#", i) + " " + e + `
|
|
680
|
+
|
|
681
|
+
`;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
_.blockquote = {
|
|
685
|
+
filter: "blockquote",
|
|
686
|
+
replacement: function(e) {
|
|
687
|
+
return e = e.replace(/^\n+|\n+$/g, ""), e = e.replace(/^/gm, "> "), `
|
|
688
|
+
|
|
689
|
+
` + e + `
|
|
690
|
+
|
|
691
|
+
`;
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
_.list = {
|
|
695
|
+
filter: ["ul", "ol"],
|
|
696
|
+
replacement: function(e, t) {
|
|
697
|
+
var r = t.parentNode;
|
|
698
|
+
return r.nodeName === "LI" && r.lastElementChild === t ? `
|
|
699
|
+
` + e : `
|
|
700
|
+
|
|
701
|
+
` + e + `
|
|
702
|
+
|
|
703
|
+
`;
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
_.listItem = {
|
|
707
|
+
filter: "li",
|
|
708
|
+
replacement: function(e, t, r) {
|
|
709
|
+
e = e.replace(/^\n+/, "").replace(/\n+$/, `
|
|
710
|
+
`).replace(/\n/gm, `
|
|
711
|
+
`);
|
|
712
|
+
var i = r.bulletListMarker + " ", l = t.parentNode;
|
|
713
|
+
if (l.nodeName === "OL") {
|
|
714
|
+
var c = l.getAttribute("start"), p = Array.prototype.indexOf.call(l.children, t);
|
|
715
|
+
i = (c ? Number(c) + p : p + 1) + ". ";
|
|
716
|
+
}
|
|
717
|
+
return i + e + (t.nextSibling && !/\n$/.test(e) ? `
|
|
718
|
+
` : "");
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
_.indentedCodeBlock = {
|
|
722
|
+
filter: function(e, t) {
|
|
723
|
+
return t.codeBlockStyle === "indented" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
|
|
724
|
+
},
|
|
725
|
+
replacement: function(e, t, r) {
|
|
726
|
+
return `
|
|
727
|
+
|
|
728
|
+
` + t.firstChild.textContent.replace(/\n/g, `
|
|
729
|
+
`) + `
|
|
730
|
+
|
|
731
|
+
`;
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
_.fencedCodeBlock = {
|
|
735
|
+
filter: function(e, t) {
|
|
736
|
+
return t.codeBlockStyle === "fenced" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
|
|
737
|
+
},
|
|
738
|
+
replacement: function(e, t, r) {
|
|
739
|
+
for (var i = t.firstChild.getAttribute("class") || "", l = (i.match(/language-(\S+)/) || [null, ""])[1], c = t.firstChild.textContent, p = r.fence.charAt(0), O = 3, m = new RegExp("^" + p + "{3,}", "gm"), S; S = m.exec(c); )
|
|
740
|
+
S[0].length >= O && (O = S[0].length + 1);
|
|
741
|
+
var F = Be(p, O);
|
|
742
|
+
return `
|
|
743
|
+
|
|
744
|
+
` + F + l + `
|
|
745
|
+
` + c.replace(/\n$/, "") + `
|
|
746
|
+
` + F + `
|
|
747
|
+
|
|
748
|
+
`;
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
_.horizontalRule = {
|
|
752
|
+
filter: "hr",
|
|
753
|
+
replacement: function(e, t, r) {
|
|
754
|
+
return `
|
|
755
|
+
|
|
756
|
+
` + r.hr + `
|
|
757
|
+
|
|
758
|
+
`;
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
_.inlineLink = {
|
|
762
|
+
filter: function(e, t) {
|
|
763
|
+
return t.linkStyle === "inlined" && e.nodeName === "A" && e.getAttribute("href");
|
|
764
|
+
},
|
|
765
|
+
replacement: function(e, t) {
|
|
766
|
+
var r = t.getAttribute("href");
|
|
767
|
+
r && (r = r.replace(/([()])/g, "\\$1"));
|
|
768
|
+
var i = de(t.getAttribute("title"));
|
|
769
|
+
return i && (i = ' "' + i.replace(/"/g, '\\"') + '"'), "[" + e + "](" + r + i + ")";
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
_.referenceLink = {
|
|
773
|
+
filter: function(e, t) {
|
|
774
|
+
return t.linkStyle === "referenced" && e.nodeName === "A" && e.getAttribute("href");
|
|
775
|
+
},
|
|
776
|
+
replacement: function(e, t, r) {
|
|
777
|
+
var i = t.getAttribute("href"), l = de(t.getAttribute("title"));
|
|
778
|
+
l && (l = ' "' + l + '"');
|
|
779
|
+
var c, p;
|
|
780
|
+
switch (r.linkReferenceStyle) {
|
|
781
|
+
case "collapsed":
|
|
782
|
+
c = "[" + e + "][]", p = "[" + e + "]: " + i + l;
|
|
783
|
+
break;
|
|
784
|
+
case "shortcut":
|
|
785
|
+
c = "[" + e + "]", p = "[" + e + "]: " + i + l;
|
|
786
|
+
break;
|
|
787
|
+
default:
|
|
788
|
+
var O = this.references.length + 1;
|
|
789
|
+
c = "[" + e + "][" + O + "]", p = "[" + O + "]: " + i + l;
|
|
790
|
+
}
|
|
791
|
+
return this.references.push(p), c;
|
|
792
|
+
},
|
|
793
|
+
references: [],
|
|
794
|
+
append: function(e) {
|
|
795
|
+
var t = "";
|
|
796
|
+
return this.references.length && (t = `
|
|
797
|
+
|
|
798
|
+
` + this.references.join(`
|
|
799
|
+
`) + `
|
|
800
|
+
|
|
801
|
+
`, this.references = []), t;
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
_.emphasis = {
|
|
805
|
+
filter: ["em", "i"],
|
|
806
|
+
replacement: function(e, t, r) {
|
|
807
|
+
return e.trim() ? r.emDelimiter + e + r.emDelimiter : "";
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
_.strong = {
|
|
811
|
+
filter: ["strong", "b"],
|
|
812
|
+
replacement: function(e, t, r) {
|
|
813
|
+
return e.trim() ? r.strongDelimiter + e + r.strongDelimiter : "";
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
_.code = {
|
|
817
|
+
filter: function(e) {
|
|
818
|
+
var t = e.previousSibling || e.nextSibling, r = e.parentNode.nodeName === "PRE" && !t;
|
|
819
|
+
return e.nodeName === "CODE" && !r;
|
|
820
|
+
},
|
|
821
|
+
replacement: function(e) {
|
|
822
|
+
if (!e) return "";
|
|
823
|
+
e = e.replace(/\r?\n|\r/g, " ");
|
|
824
|
+
for (var t = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "", r = "`", i = e.match(/`+/gm) || []; i.indexOf(r) !== -1; ) r = r + "`";
|
|
825
|
+
return r + t + e + t + r;
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
_.image = {
|
|
829
|
+
filter: "img",
|
|
830
|
+
replacement: function(e, t) {
|
|
831
|
+
var r = de(t.getAttribute("alt")), i = t.getAttribute("src") || "", l = de(t.getAttribute("title")), c = l ? ' "' + l + '"' : "";
|
|
832
|
+
return i ? "" : "";
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
function de(e) {
|
|
836
|
+
return e ? e.replace(/(\n+\s*)+/g, `
|
|
837
|
+
`) : "";
|
|
838
|
+
}
|
|
839
|
+
function Ut(e) {
|
|
840
|
+
this.options = e, this._keep = [], this._remove = [], this.blankRule = {
|
|
841
|
+
replacement: e.blankReplacement
|
|
842
|
+
}, this.keepReplacement = e.keepReplacement, this.defaultRule = {
|
|
843
|
+
replacement: e.defaultReplacement
|
|
844
|
+
}, this.array = [];
|
|
845
|
+
for (var t in e.rules) this.array.push(e.rules[t]);
|
|
846
|
+
}
|
|
847
|
+
Ut.prototype = {
|
|
848
|
+
add: function(e, t) {
|
|
849
|
+
this.array.unshift(t);
|
|
850
|
+
},
|
|
851
|
+
keep: function(e) {
|
|
852
|
+
this._keep.unshift({
|
|
853
|
+
filter: e,
|
|
854
|
+
replacement: this.keepReplacement
|
|
855
|
+
});
|
|
856
|
+
},
|
|
857
|
+
remove: function(e) {
|
|
858
|
+
this._remove.unshift({
|
|
859
|
+
filter: e,
|
|
860
|
+
replacement: function() {
|
|
861
|
+
return "";
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
},
|
|
865
|
+
forNode: function(e) {
|
|
866
|
+
if (e.isBlank) return this.blankRule;
|
|
867
|
+
var t;
|
|
868
|
+
return (t = Pe(this.array, e, this.options)) || (t = Pe(this._keep, e, this.options)) || (t = Pe(this._remove, e, this.options)) ? t : this.defaultRule;
|
|
869
|
+
},
|
|
870
|
+
forEach: function(e) {
|
|
871
|
+
for (var t = 0; t < this.array.length; t++) e(this.array[t], t);
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
function Pe(e, t, r) {
|
|
875
|
+
for (var i = 0; i < e.length; i++) {
|
|
876
|
+
var l = e[i];
|
|
877
|
+
if (kn(l, t, r)) return l;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
function kn(e, t, r) {
|
|
881
|
+
var i = e.filter;
|
|
882
|
+
if (typeof i == "string") {
|
|
883
|
+
if (i === t.nodeName.toLowerCase()) return !0;
|
|
884
|
+
} else if (Array.isArray(i)) {
|
|
885
|
+
if (i.indexOf(t.nodeName.toLowerCase()) > -1) return !0;
|
|
886
|
+
} else if (typeof i == "function") {
|
|
887
|
+
if (i.call(e, t, r)) return !0;
|
|
888
|
+
} else
|
|
889
|
+
throw new TypeError("`filter` needs to be a string, array, or function");
|
|
890
|
+
}
|
|
891
|
+
function Pn(e) {
|
|
892
|
+
var t = e.element, r = e.isBlock, i = e.isVoid, l = e.isPre || function(he) {
|
|
893
|
+
return he.nodeName === "PRE";
|
|
894
|
+
};
|
|
895
|
+
if (!(!t.firstChild || l(t))) {
|
|
896
|
+
for (var c = null, p = !1, O = null, m = Ot(O, t, l); m !== t; ) {
|
|
897
|
+
if (m.nodeType === 3 || m.nodeType === 4) {
|
|
898
|
+
var S = m.data.replace(/[ \r\n\t]+/g, " ");
|
|
899
|
+
if ((!c || / $/.test(c.data)) && !p && S[0] === " " && (S = S.substr(1)), !S) {
|
|
900
|
+
m = xe(m);
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
903
|
+
m.data = S, c = m;
|
|
904
|
+
} else if (m.nodeType === 1)
|
|
905
|
+
r(m) || m.nodeName === "BR" ? (c && (c.data = c.data.replace(/ $/, "")), c = null, p = !1) : i(m) || l(m) ? (c = null, p = !0) : c && (p = !1);
|
|
906
|
+
else {
|
|
907
|
+
m = xe(m);
|
|
908
|
+
continue;
|
|
909
|
+
}
|
|
910
|
+
var F = Ot(O, m, l);
|
|
911
|
+
O = m, m = F;
|
|
912
|
+
}
|
|
913
|
+
c && (c.data = c.data.replace(/ $/, ""), c.data || xe(c));
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
function xe(e) {
|
|
917
|
+
var t = e.nextSibling || e.parentNode;
|
|
918
|
+
return e.parentNode.removeChild(e), t;
|
|
919
|
+
}
|
|
920
|
+
function Ot(e, t, r) {
|
|
921
|
+
return e && e.parentNode === t || r(t) ? t.nextSibling || t.parentNode : t.firstChild || t.nextSibling || t.parentNode;
|
|
922
|
+
}
|
|
923
|
+
var Ye = typeof window < "u" ? window : {};
|
|
924
|
+
function xn() {
|
|
925
|
+
var e = Ye.DOMParser, t = !1;
|
|
926
|
+
try {
|
|
927
|
+
new e().parseFromString("", "text/html") && (t = !0);
|
|
928
|
+
} catch {
|
|
929
|
+
}
|
|
930
|
+
return t;
|
|
931
|
+
}
|
|
932
|
+
function Un() {
|
|
933
|
+
var e = function() {
|
|
934
|
+
};
|
|
935
|
+
return Fn() ? e.prototype.parseFromString = function(t) {
|
|
936
|
+
var r = new window.ActiveXObject("htmlfile");
|
|
937
|
+
return r.designMode = "on", r.open(), r.write(t), r.close(), r;
|
|
938
|
+
} : e.prototype.parseFromString = function(t) {
|
|
939
|
+
var r = document.implementation.createHTMLDocument("");
|
|
940
|
+
return r.open(), r.write(t), r.close(), r;
|
|
941
|
+
}, e;
|
|
942
|
+
}
|
|
943
|
+
function Fn() {
|
|
944
|
+
var e = !1;
|
|
945
|
+
try {
|
|
946
|
+
document.implementation.createHTMLDocument("").open();
|
|
947
|
+
} catch {
|
|
948
|
+
Ye.ActiveXObject && (e = !0);
|
|
949
|
+
}
|
|
950
|
+
return e;
|
|
951
|
+
}
|
|
952
|
+
var Hn = xn() ? Ye.DOMParser : Un();
|
|
953
|
+
function Bn(e, t) {
|
|
954
|
+
var r;
|
|
955
|
+
if (typeof e == "string") {
|
|
956
|
+
var i = zn().parseFromString(
|
|
957
|
+
// DOM parsers arrange elements in the <head> and <body>.
|
|
958
|
+
// Wrapping in a custom element ensures elements are reliably arranged in
|
|
959
|
+
// a single element.
|
|
960
|
+
'<x-turndown id="turndown-root">' + e + "</x-turndown>",
|
|
961
|
+
"text/html"
|
|
962
|
+
);
|
|
963
|
+
r = i.getElementById("turndown-root");
|
|
964
|
+
} else
|
|
965
|
+
r = e.cloneNode(!0);
|
|
966
|
+
return Pn({
|
|
967
|
+
element: r,
|
|
968
|
+
isBlock: We,
|
|
969
|
+
isVoid: kt,
|
|
970
|
+
isPre: t.preformattedCode ? Wn : null
|
|
971
|
+
}), r;
|
|
972
|
+
}
|
|
973
|
+
var Ue;
|
|
974
|
+
function zn() {
|
|
975
|
+
return Ue = Ue || new Hn(), Ue;
|
|
976
|
+
}
|
|
977
|
+
function Wn(e) {
|
|
978
|
+
return e.nodeName === "PRE" || e.nodeName === "CODE";
|
|
979
|
+
}
|
|
980
|
+
function Gn(e, t) {
|
|
981
|
+
return e.isBlock = We(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = Yn(e), e.flankingWhitespace = $n(e, t), e;
|
|
982
|
+
}
|
|
983
|
+
function Yn(e) {
|
|
984
|
+
return !kt(e) && !Mn(e) && /^\s*$/i.test(e.textContent) && !In(e) && !wn(e);
|
|
985
|
+
}
|
|
986
|
+
function $n(e, t) {
|
|
987
|
+
if (e.isBlock || t.preformattedCode && e.isCode)
|
|
988
|
+
return { leading: "", trailing: "" };
|
|
989
|
+
var r = Vn(e.textContent);
|
|
990
|
+
return r.leadingAscii && bt("left", e, t) && (r.leading = r.leadingNonAscii), r.trailingAscii && bt("right", e, t) && (r.trailing = r.trailingNonAscii), { leading: r.leading, trailing: r.trailing };
|
|
991
|
+
}
|
|
992
|
+
function Vn(e) {
|
|
993
|
+
var t = e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
|
|
994
|
+
return {
|
|
995
|
+
leading: t[1],
|
|
996
|
+
// whole string for whitespace-only strings
|
|
997
|
+
leadingAscii: t[2],
|
|
998
|
+
leadingNonAscii: t[3],
|
|
999
|
+
trailing: t[4],
|
|
1000
|
+
// empty for whitespace-only strings
|
|
1001
|
+
trailingNonAscii: t[5],
|
|
1002
|
+
trailingAscii: t[6]
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
function bt(e, t, r) {
|
|
1006
|
+
var i, l, c;
|
|
1007
|
+
return e === "left" ? (i = t.previousSibling, l = / $/) : (i = t.nextSibling, l = /^ /), i && (i.nodeType === 3 ? c = l.test(i.nodeValue) : r.preformattedCode && i.nodeName === "CODE" ? c = !1 : i.nodeType === 1 && !We(i) && (c = l.test(i.textContent))), c;
|
|
1008
|
+
}
|
|
1009
|
+
var Xn = Array.prototype.reduce, jn = [
|
|
1010
|
+
[/\\/g, "\\\\"],
|
|
1011
|
+
[/\*/g, "\\*"],
|
|
1012
|
+
[/^-/g, "\\-"],
|
|
1013
|
+
[/^\+ /g, "\\+ "],
|
|
1014
|
+
[/^(=+)/g, "\\$1"],
|
|
1015
|
+
[/^(#{1,6}) /g, "\\$1 "],
|
|
1016
|
+
[/`/g, "\\`"],
|
|
1017
|
+
[/^~~~/g, "\\~~~"],
|
|
1018
|
+
[/\[/g, "\\["],
|
|
1019
|
+
[/\]/g, "\\]"],
|
|
1020
|
+
[/^>/g, "\\>"],
|
|
1021
|
+
[/_/g, "\\_"],
|
|
1022
|
+
[/^(\d+)\. /g, "$1\\. "]
|
|
1023
|
+
];
|
|
1024
|
+
function ze(e) {
|
|
1025
|
+
if (!(this instanceof ze)) return new ze(e);
|
|
1026
|
+
var t = {
|
|
1027
|
+
rules: _,
|
|
1028
|
+
headingStyle: "setext",
|
|
1029
|
+
hr: "* * *",
|
|
1030
|
+
bulletListMarker: "*",
|
|
1031
|
+
codeBlockStyle: "indented",
|
|
1032
|
+
fence: "```",
|
|
1033
|
+
emDelimiter: "_",
|
|
1034
|
+
strongDelimiter: "**",
|
|
1035
|
+
linkStyle: "inlined",
|
|
1036
|
+
linkReferenceStyle: "full",
|
|
1037
|
+
br: " ",
|
|
1038
|
+
preformattedCode: !1,
|
|
1039
|
+
blankReplacement: function(r, i) {
|
|
1040
|
+
return i.isBlock ? `
|
|
1041
|
+
|
|
1042
|
+
` : "";
|
|
1043
|
+
},
|
|
1044
|
+
keepReplacement: function(r, i) {
|
|
1045
|
+
return i.isBlock ? `
|
|
1046
|
+
|
|
1047
|
+
` + i.outerHTML + `
|
|
1048
|
+
|
|
1049
|
+
` : i.outerHTML;
|
|
1050
|
+
},
|
|
1051
|
+
defaultReplacement: function(r, i) {
|
|
1052
|
+
return i.isBlock ? `
|
|
1053
|
+
|
|
1054
|
+
` + r + `
|
|
1055
|
+
|
|
1056
|
+
` : r;
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
this.options = bn({}, t, e), this.rules = new Ut(this.options);
|
|
1060
|
+
}
|
|
1061
|
+
ze.prototype = {
|
|
1062
|
+
/**
|
|
1063
|
+
* The entry point for converting a string or DOM node to Markdown
|
|
1064
|
+
* @public
|
|
1065
|
+
* @param {String|HTMLElement} input The string or DOM node to convert
|
|
1066
|
+
* @returns A Markdown representation of the input
|
|
1067
|
+
* @type String
|
|
1068
|
+
*/
|
|
1069
|
+
turndown: function(e) {
|
|
1070
|
+
if (!Zn(e))
|
|
1071
|
+
throw new TypeError(
|
|
1072
|
+
e + " is not a string, or an element/document/fragment node."
|
|
1073
|
+
);
|
|
1074
|
+
if (e === "") return "";
|
|
1075
|
+
var t = Ft.call(this, new Bn(e, this.options));
|
|
1076
|
+
return Kn.call(this, t);
|
|
1077
|
+
},
|
|
1078
|
+
/**
|
|
1079
|
+
* Add one or more plugins
|
|
1080
|
+
* @public
|
|
1081
|
+
* @param {Function|Array} plugin The plugin or array of plugins to add
|
|
1082
|
+
* @returns The Turndown instance for chaining
|
|
1083
|
+
* @type Object
|
|
1084
|
+
*/
|
|
1085
|
+
use: function(e) {
|
|
1086
|
+
if (Array.isArray(e))
|
|
1087
|
+
for (var t = 0; t < e.length; t++) this.use(e[t]);
|
|
1088
|
+
else if (typeof e == "function")
|
|
1089
|
+
e(this);
|
|
1090
|
+
else
|
|
1091
|
+
throw new TypeError("plugin must be a Function or an Array of Functions");
|
|
1092
|
+
return this;
|
|
1093
|
+
},
|
|
1094
|
+
/**
|
|
1095
|
+
* Adds a rule
|
|
1096
|
+
* @public
|
|
1097
|
+
* @param {String} key The unique key of the rule
|
|
1098
|
+
* @param {Object} rule The rule
|
|
1099
|
+
* @returns The Turndown instance for chaining
|
|
1100
|
+
* @type Object
|
|
1101
|
+
*/
|
|
1102
|
+
addRule: function(e, t) {
|
|
1103
|
+
return this.rules.add(e, t), this;
|
|
1104
|
+
},
|
|
1105
|
+
/**
|
|
1106
|
+
* Keep a node (as HTML) that matches the filter
|
|
1107
|
+
* @public
|
|
1108
|
+
* @param {String|Array|Function} filter The unique key of the rule
|
|
1109
|
+
* @returns The Turndown instance for chaining
|
|
1110
|
+
* @type Object
|
|
1111
|
+
*/
|
|
1112
|
+
keep: function(e) {
|
|
1113
|
+
return this.rules.keep(e), this;
|
|
1114
|
+
},
|
|
1115
|
+
/**
|
|
1116
|
+
* Remove a node that matches the filter
|
|
1117
|
+
* @public
|
|
1118
|
+
* @param {String|Array|Function} filter The unique key of the rule
|
|
1119
|
+
* @returns The Turndown instance for chaining
|
|
1120
|
+
* @type Object
|
|
1121
|
+
*/
|
|
1122
|
+
remove: function(e) {
|
|
1123
|
+
return this.rules.remove(e), this;
|
|
1124
|
+
},
|
|
1125
|
+
/**
|
|
1126
|
+
* Escapes Markdown syntax
|
|
1127
|
+
* @public
|
|
1128
|
+
* @param {String} string The string to escape
|
|
1129
|
+
* @returns A string with Markdown syntax escaped
|
|
1130
|
+
* @type String
|
|
1131
|
+
*/
|
|
1132
|
+
escape: function(e) {
|
|
1133
|
+
return jn.reduce(function(t, r) {
|
|
1134
|
+
return t.replace(r[0], r[1]);
|
|
1135
|
+
}, e);
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
function Ft(e) {
|
|
1139
|
+
var t = this;
|
|
1140
|
+
return Xn.call(e.childNodes, function(r, i) {
|
|
1141
|
+
i = new Gn(i, t.options);
|
|
1142
|
+
var l = "";
|
|
1143
|
+
return i.nodeType === 3 ? l = i.isCode ? i.nodeValue : t.escape(i.nodeValue) : i.nodeType === 1 && (l = qn.call(t, i)), Ht(r, l);
|
|
1144
|
+
}, "");
|
|
1145
|
+
}
|
|
1146
|
+
function Kn(e) {
|
|
1147
|
+
var t = this;
|
|
1148
|
+
return this.rules.forEach(function(r) {
|
|
1149
|
+
typeof r.append == "function" && (e = Ht(e, r.append(t.options)));
|
|
1150
|
+
}), e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
|
|
1151
|
+
}
|
|
1152
|
+
function qn(e) {
|
|
1153
|
+
var t = this.rules.forNode(e), r = Ft.call(this, e), i = e.flankingWhitespace;
|
|
1154
|
+
return (i.leading || i.trailing) && (r = r.trim()), i.leading + t.replacement(r, e, this.options) + i.trailing;
|
|
1155
|
+
}
|
|
1156
|
+
function Ht(e, t) {
|
|
1157
|
+
var r = Ln(e), i = Dn(t), l = Math.max(e.length - r.length, t.length - i.length), c = `
|
|
1158
|
+
|
|
1159
|
+
`.substring(0, l);
|
|
1160
|
+
return r + c + i;
|
|
1161
|
+
}
|
|
1162
|
+
function Zn(e) {
|
|
1163
|
+
return e != null && (typeof e == "string" || e.nodeType && (e.nodeType === 1 || e.nodeType === 9 || e.nodeType === 11));
|
|
1164
|
+
}
|
|
1165
|
+
export {
|
|
1166
|
+
ze as T,
|
|
1167
|
+
Qn as p
|
|
1168
|
+
};
|