@clevertask/scribe 0.1.0 → 0.1.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.
Files changed (37) hide show
  1. package/README.md +60 -16
  2. package/dist/{BarMenu-BDtEfu-R.js → BarMenu-DaKIz3zZ.js} +1 -1
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.js +2 -2
  5. package/dist/components/Menu/BubbleMenu.js +78 -74
  6. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  7. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  8. package/dist/components/Scribe/extension/extension-link.js +1 -1
  9. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  10. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  11. package/dist/components/Scribe/extension/index.d.ts +17 -2
  12. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  13. package/dist/components/Scribe/extension/index.js +2655 -2580
  14. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +1616 -1618
  15. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  16. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  17. package/dist/components/Scribe/extension/tableOfContents.d.ts +49 -0
  18. package/dist/components/Scribe/extension/tableOfContents.d.ts.map +1 -0
  19. package/dist/components/Scribe/extension/tableOfContents.js +181 -0
  20. package/dist/components/Scribe/index.d.ts +12 -0
  21. package/dist/components/Scribe/index.d.ts.map +1 -1
  22. package/dist/components/Scribe/index.js +108 -65
  23. package/dist/{extension-link-D3eyOFkn.js → extension-link-Ch_T7WWG.js} +1 -1
  24. package/dist/{index-hHvpW2H6.js → index-BiBV5TQx.js} +1287 -1250
  25. package/dist/{index-FY_iYS6i.js → index-CqzMmrnw.js} +1 -1
  26. package/dist/{index-PJNQPLn5.js → index-DxF-1P4n.js} +196 -203
  27. package/dist/index-V-gN11Y9.js +249 -0
  28. package/dist/main.js +1 -1
  29. package/dist/{markdown-to-html-BwS08CTi.js → markdown-to-html-pL7ckd-m.js} +14 -14
  30. package/dist/purify.es-exIQuqhb.js +595 -0
  31. package/dist/utils/create-scribe-editor.js +3 -3
  32. package/dist/utils/html-to-markdown.js +226 -306
  33. package/dist/utils/index.js +1 -1
  34. package/dist/utils/markdown-to-html.js +2 -2
  35. package/package.json +30 -30
  36. package/dist/index-DZylq4Bc.js +0 -232
  37. package/dist/purify.es-BPDBzHtc.js +0 -552
@@ -1,131 +1,58 @@
1
- import { p as L } from "../purify.es-BPDBzHtc.js";
2
- function M(e) {
3
- for (var r = 1; r < arguments.length; r++) {
4
- var t = arguments[r];
5
- for (var n in t)
6
- t.hasOwnProperty(n) && (e[n] = t[n]);
1
+ import { p as $ } from "../purify.es-exIQuqhb.js";
2
+ function H(e) {
3
+ for (var t = 1; t < arguments.length; t++) {
4
+ var r = arguments[t];
5
+ for (var n in r)
6
+ Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
7
7
  }
8
8
  return e;
9
9
  }
10
- function v(e, r) {
11
- return Array(r + 1).join(e);
10
+ function v(e, t) {
11
+ return Array(t + 1).join(e);
12
12
  }
13
- function T(e) {
13
+ function C(e) {
14
14
  return e.replace(/^\n*/, "");
15
15
  }
16
- function R(e) {
17
- for (var r = e.length; r > 0 && e[r - 1] === `
18
- `; ) r--;
19
- return e.substring(0, r);
16
+ function b(e) {
17
+ for (var t = e.length; t > 0 && e[t - 1] === `
18
+ `; ) t--;
19
+ return e.substring(0, t);
20
20
  }
21
- function C(e) {
22
- return R(T(e));
23
- }
24
- var I = [
25
- "ADDRESS",
26
- "ARTICLE",
27
- "ASIDE",
28
- "AUDIO",
29
- "BLOCKQUOTE",
30
- "BODY",
31
- "CANVAS",
32
- "CENTER",
33
- "DD",
34
- "DIR",
35
- "DIV",
36
- "DL",
37
- "DT",
38
- "FIELDSET",
39
- "FIGCAPTION",
40
- "FIGURE",
41
- "FOOTER",
42
- "FORM",
43
- "FRAMESET",
44
- "H1",
45
- "H2",
46
- "H3",
47
- "H4",
48
- "H5",
49
- "H6",
50
- "HEADER",
51
- "HGROUP",
52
- "HR",
53
- "HTML",
54
- "ISINDEX",
55
- "LI",
56
- "MAIN",
57
- "MENU",
58
- "NAV",
59
- "NOFRAMES",
60
- "NOSCRIPT",
61
- "OL",
62
- "OUTPUT",
63
- "P",
64
- "PRE",
65
- "SECTION",
66
- "TABLE",
67
- "TBODY",
68
- "TD",
69
- "TFOOT",
70
- "TH",
71
- "THEAD",
72
- "TR",
73
- "UL"
74
- ];
75
- function A(e) {
76
- return N(e, I);
77
- }
78
- var b = [
79
- "AREA",
80
- "BASE",
81
- "BR",
82
- "COL",
83
- "COMMAND",
84
- "EMBED",
85
- "HR",
86
- "IMG",
87
- "INPUT",
88
- "KEYGEN",
89
- "LINK",
90
- "META",
91
- "PARAM",
92
- "SOURCE",
93
- "TRACK",
94
- "WBR"
95
- ];
96
21
  function S(e) {
97
- return N(e, b);
98
- }
99
- function $(e) {
100
- return O(e, b);
101
- }
102
- var w = [
103
- "A",
104
- "TABLE",
105
- "THEAD",
106
- "TBODY",
107
- "TFOOT",
108
- "TH",
109
- "TD",
110
- "IFRAME",
111
- "SCRIPT",
112
- "AUDIO",
113
- "VIDEO"
114
- ];
115
- function H(e) {
116
- return N(e, w);
22
+ return b(C(e));
23
+ }
24
+ var F = ["ADDRESS", "ARTICLE", "ASIDE", "AUDIO", "BLOCKQUOTE", "BODY", "CANVAS", "CENTER", "DD", "DIR", "DIV", "DL", "DT", "FIELDSET", "FIGCAPTION", "FIGURE", "FOOTER", "FORM", "FRAMESET", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "HGROUP", "HR", "HTML", "ISINDEX", "LI", "MAIN", "MENU", "NAV", "NOFRAMES", "NOSCRIPT", "OL", "OUTPUT", "P", "PRE", "SECTION", "TABLE", "TBODY", "TD", "TFOOT", "TH", "THEAD", "TR", "UL"];
25
+ function A(e) {
26
+ return y(e, F);
117
27
  }
118
- function F(e) {
119
- return O(e, w);
28
+ var w = ["AREA", "BASE", "BR", "COL", "COMMAND", "EMBED", "HR", "IMG", "INPUT", "KEYGEN", "LINK", "META", "PARAM", "SOURCE", "TRACK", "WBR"];
29
+ function O(e) {
30
+ return y(e, w);
120
31
  }
121
- function N(e, r) {
122
- return r.indexOf(e.nodeName) >= 0;
32
+ function V(e) {
33
+ return B(e, w);
123
34
  }
124
- function O(e, r) {
125
- return e.getElementsByTagName && r.some(function(t) {
126
- return e.getElementsByTagName(t).length;
35
+ var D = ["A", "TABLE", "THEAD", "TBODY", "TFOOT", "TH", "TD", "IFRAME", "SCRIPT", "AUDIO", "VIDEO"];
36
+ function U(e) {
37
+ return y(e, D);
38
+ }
39
+ function W(e) {
40
+ return B(e, D);
41
+ }
42
+ function y(e, t) {
43
+ return t.indexOf(e.nodeName) >= 0;
44
+ }
45
+ function B(e, t) {
46
+ return e.getElementsByTagName && t.some(function(r) {
47
+ return e.getElementsByTagName(r).length;
127
48
  });
128
49
  }
50
+ var _ = [[/\\/g, "\\\\"], [/\*/g, "\\*"], [/^-/g, "\\-"], [/^\+ /g, "\\+ "], [/^(=+)/g, "\\$1"], [/^(#{1,6}) /g, "\\$1 "], [/`/g, "\\`"], [/^~~~/g, "\\~~~"], [/\[/g, "\\["], [/\]/g, "\\]"], [/^>/g, "\\>"], [/_/g, "\\_"], [/^(\d+)\. /g, "$1\\. "]];
51
+ function x(e) {
52
+ return _.reduce(function(t, r) {
53
+ return t.replace(r[0], r[1]);
54
+ }, e);
55
+ }
129
56
  var o = {};
130
57
  o.paragraph = {
131
58
  filter: "p",
@@ -139,16 +66,16 @@ o.paragraph = {
139
66
  };
140
67
  o.lineBreak = {
141
68
  filter: "br",
142
- replacement: function(e, r, t) {
143
- return t.br + `
69
+ replacement: function(e, t, r) {
70
+ return r.br + `
144
71
  `;
145
72
  }
146
73
  };
147
74
  o.heading = {
148
75
  filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
149
- replacement: function(e, r, t) {
150
- var n = Number(r.nodeName.charAt(1));
151
- if (t.headingStyle === "setext" && n < 3) {
76
+ replacement: function(e, t, r) {
77
+ var n = Number(t.nodeName.charAt(1));
78
+ if (r.headingStyle === "setext" && n < 3) {
152
79
  var i = v(n === 1 ? "=" : "-", e.length);
153
80
  return `
154
81
 
@@ -167,7 +94,7 @@ o.heading = {
167
94
  o.blockquote = {
168
95
  filter: "blockquote",
169
96
  replacement: function(e) {
170
- return e = C(e).replace(/^/gm, "> "), `
97
+ return e = S(e).replace(/^/gm, "> "), `
171
98
 
172
99
  ` + e + `
173
100
 
@@ -176,9 +103,9 @@ o.blockquote = {
176
103
  };
177
104
  o.list = {
178
105
  filter: ["ul", "ol"],
179
- replacement: function(e, r) {
180
- var t = r.parentNode;
181
- return t.nodeName === "LI" && t.lastElementChild === r ? `
106
+ replacement: function(e, t) {
107
+ var r = t.parentNode;
108
+ return r.nodeName === "LI" && r.lastElementChild === t ? `
182
109
  ` + e : `
183
110
 
184
111
  ` + e + `
@@ -188,79 +115,77 @@ o.list = {
188
115
  };
189
116
  o.listItem = {
190
117
  filter: "li",
191
- replacement: function(e, r, t) {
192
- var n = t.bulletListMarker + " ", i = r.parentNode;
118
+ replacement: function(e, t, r) {
119
+ var n = r.bulletListMarker + " ", i = t.parentNode;
193
120
  if (i.nodeName === "OL") {
194
- var a = i.getAttribute("start"), s = Array.prototype.indexOf.call(i.children, r);
121
+ var a = i.getAttribute("start"), s = Array.prototype.indexOf.call(i.children, t);
195
122
  n = (a ? Number(a) + s : s + 1) + ". ";
196
123
  }
197
124
  var u = /\n$/.test(e);
198
- return e = C(e) + (u ? `
125
+ return e = S(e) + (u ? `
199
126
  ` : ""), e = e.replace(/\n/gm, `
200
- ` + " ".repeat(n.length)), n + e + (r.nextSibling ? `
127
+ ` + " ".repeat(n.length)), n + e + (t.nextSibling ? `
201
128
  ` : "");
202
129
  }
203
130
  };
204
131
  o.indentedCodeBlock = {
205
- filter: function(e, r) {
206
- return r.codeBlockStyle === "indented" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
132
+ filter: function(e, t) {
133
+ return t.codeBlockStyle === "indented" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
207
134
  },
208
- replacement: function(e, r, t) {
135
+ replacement: function(e, t, r) {
209
136
  return `
210
137
 
211
- ` + r.firstChild.textContent.replace(/\n/g, `
138
+ ` + t.firstChild.textContent.replace(/\n/g, `
212
139
  `) + `
213
140
 
214
141
  `;
215
142
  }
216
143
  };
217
144
  o.fencedCodeBlock = {
218
- filter: function(e, r) {
219
- return r.codeBlockStyle === "fenced" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
145
+ filter: function(e, t) {
146
+ return t.codeBlockStyle === "fenced" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
220
147
  },
221
- replacement: function(e, r, t) {
222
- for (var n = r.firstChild.getAttribute("class") || "", i = (n.match(/language-(\S+)/) || [null, ""])[1], a = r.firstChild.textContent, s = t.fence.charAt(0), u = 3, l = new RegExp("^" + s + "{3,}", "gm"), f; f = l.exec(a); )
223
- f[0].length >= u && (u = f[0].length + 1);
224
- var c = v(s, u);
148
+ replacement: function(e, t, r) {
149
+ for (var n = t.firstChild.getAttribute("class") || "", i = (n.match(/language-(\S+)/) || [null, ""])[1], a = t.firstChild.textContent, s = r.fence.charAt(0), u = 3, l = new RegExp("^" + s + "{3,}", "gm"), c; c = l.exec(a); )
150
+ c[0].length >= u && (u = c[0].length + 1);
151
+ var f = v(s, u);
225
152
  return `
226
153
 
227
- ` + c + i + `
154
+ ` + f + i + `
228
155
  ` + a.replace(/\n$/, "") + `
229
- ` + c + `
156
+ ` + f + `
230
157
 
231
158
  `;
232
159
  }
233
160
  };
234
161
  o.horizontalRule = {
235
162
  filter: "hr",
236
- replacement: function(e, r, t) {
163
+ replacement: function(e, t, r) {
237
164
  return `
238
165
 
239
- ` + t.hr + `
166
+ ` + r.hr + `
240
167
 
241
168
  `;
242
169
  }
243
170
  };
244
171
  o.inlineLink = {
245
- filter: function(e, r) {
246
- return r.linkStyle === "inlined" && e.nodeName === "A" && e.getAttribute("href");
172
+ filter: function(e, t) {
173
+ return t.linkStyle === "inlined" && e.nodeName === "A" && e.getAttribute("href");
247
174
  },
248
- replacement: function(e, r) {
249
- var t = r.getAttribute("href");
250
- t && (t = t.replace(/([()])/g, "\\$1"));
251
- var n = h(r.getAttribute("title"));
252
- return n && (n = ' "' + n.replace(/"/g, '\\"') + '"'), "[" + e + "](" + t + n + ")";
175
+ replacement: function(e, t) {
176
+ var r = N(t.getAttribute("href")), n = k(h(t.getAttribute("title"))), i = n ? ' "' + n + '"' : "";
177
+ return "[" + e + "](" + r + i + ")";
253
178
  }
254
179
  };
255
180
  o.referenceLink = {
256
- filter: function(e, r) {
257
- return r.linkStyle === "referenced" && e.nodeName === "A" && e.getAttribute("href");
181
+ filter: function(e, t) {
182
+ return t.linkStyle === "referenced" && e.nodeName === "A" && e.getAttribute("href");
258
183
  },
259
- replacement: function(e, r, t) {
260
- var n = r.getAttribute("href"), i = h(r.getAttribute("title"));
261
- i && (i = ' "' + i + '"');
184
+ replacement: function(e, t, r) {
185
+ var n = N(t.getAttribute("href")), i = h(t.getAttribute("title"));
186
+ i && (i = ' "' + k(i) + '"');
262
187
  var a, s;
263
- switch (t.linkReferenceStyle) {
188
+ switch (r.linkReferenceStyle) {
264
189
  case "collapsed":
265
190
  a = "[" + e + "][]", s = "[" + e + "]: " + n + i;
266
191
  break;
@@ -275,61 +200,68 @@ o.referenceLink = {
275
200
  },
276
201
  references: [],
277
202
  append: function(e) {
278
- var r = "";
279
- return this.references.length && (r = `
203
+ var t = "";
204
+ return this.references.length && (t = `
280
205
 
281
206
  ` + this.references.join(`
282
207
  `) + `
283
208
 
284
- `, this.references = []), r;
209
+ `, this.references = []), t;
285
210
  }
286
211
  };
287
212
  o.emphasis = {
288
213
  filter: ["em", "i"],
289
- replacement: function(e, r, t) {
290
- return e.trim() ? t.emDelimiter + e + t.emDelimiter : "";
214
+ replacement: function(e, t, r) {
215
+ return e.trim() ? r.emDelimiter + e + r.emDelimiter : "";
291
216
  }
292
217
  };
293
218
  o.strong = {
294
219
  filter: ["strong", "b"],
295
- replacement: function(e, r, t) {
296
- return e.trim() ? t.strongDelimiter + e + t.strongDelimiter : "";
220
+ replacement: function(e, t, r) {
221
+ return e.trim() ? r.strongDelimiter + e + r.strongDelimiter : "";
297
222
  }
298
223
  };
299
224
  o.code = {
300
225
  filter: function(e) {
301
- var r = e.previousSibling || e.nextSibling, t = e.parentNode.nodeName === "PRE" && !r;
302
- return e.nodeName === "CODE" && !t;
226
+ var t = e.previousSibling || e.nextSibling, r = e.parentNode.nodeName === "PRE" && !t;
227
+ return e.nodeName === "CODE" && !r;
303
228
  },
304
229
  replacement: function(e) {
305
230
  if (!e) return "";
306
231
  e = e.replace(/\r?\n|\r/g, " ");
307
- for (var r = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "", t = "`", n = e.match(/`+/gm) || []; n.indexOf(t) !== -1; ) t = t + "`";
308
- return t + r + e + r + t;
232
+ for (var t = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "", r = "`", n = e.match(/`+/gm) || []; n.indexOf(r) !== -1; ) r = r + "`";
233
+ return r + t + e + t + r;
309
234
  }
310
235
  };
311
236
  o.image = {
312
237
  filter: "img",
313
- replacement: function(e, r) {
314
- var t = h(r.getAttribute("alt")), n = r.getAttribute("src") || "", i = h(r.getAttribute("title")), a = i ? ' "' + i + '"' : "";
315
- return n ? "![" + t + "](" + n + a + ")" : "";
238
+ replacement: function(e, t) {
239
+ var r = x(h(t.getAttribute("alt"))), n = N(t.getAttribute("src") || ""), i = h(t.getAttribute("title")), a = i ? ' "' + k(i) + '"' : "";
240
+ return n ? "![" + r + "](" + n + a + ")" : "";
316
241
  }
317
242
  };
318
243
  function h(e) {
319
244
  return e ? e.replace(/(\n+\s*)+/g, `
320
245
  `) : "";
321
246
  }
322
- function B(e) {
247
+ function N(e) {
248
+ var t = e.replace(/([<>()])/g, "\\$1");
249
+ return t.indexOf(" ") >= 0 ? "<" + t + ">" : t;
250
+ }
251
+ function k(e) {
252
+ return e.replace(/"/g, '\\"');
253
+ }
254
+ function L(e) {
323
255
  this.options = e, this._keep = [], this._remove = [], this.blankRule = {
324
256
  replacement: e.blankReplacement
325
257
  }, this.keepReplacement = e.keepReplacement, this.defaultRule = {
326
258
  replacement: e.defaultReplacement
327
259
  }, this.array = [];
328
- for (var r in e.rules) this.array.push(e.rules[r]);
260
+ for (var t in e.rules) this.array.push(e.rules[t]);
329
261
  }
330
- B.prototype = {
331
- add: function(e, r) {
332
- this.array.unshift(r);
262
+ L.prototype = {
263
+ add: function(e, t) {
264
+ this.array.unshift(t);
333
265
  },
334
266
  keep: function(e) {
335
267
  this._keep.unshift({
@@ -347,166 +279,158 @@ B.prototype = {
347
279
  },
348
280
  forNode: function(e) {
349
281
  if (e.isBlank) return this.blankRule;
350
- var r;
351
- return (r = d(this.array, e, this.options)) || (r = d(this._keep, e, this.options)) || (r = d(this._remove, e, this.options)) ? r : this.defaultRule;
282
+ var t;
283
+ return (t = d(this.array, e, this.options)) || (t = d(this._keep, e, this.options)) || (t = d(this._remove, e, this.options)) ? t : this.defaultRule;
352
284
  },
353
285
  forEach: function(e) {
354
- for (var r = 0; r < this.array.length; r++) e(this.array[r], r);
286
+ for (var t = 0; t < this.array.length; t++) e(this.array[t], t);
355
287
  }
356
288
  };
357
- function d(e, r, t) {
289
+ function d(e, t, r) {
358
290
  for (var n = 0; n < e.length; n++) {
359
291
  var i = e[n];
360
- if (V(i, r, t)) return i;
292
+ if (j(i, t, r)) return i;
361
293
  }
362
294
  }
363
- function V(e, r, t) {
295
+ function j(e, t, r) {
364
296
  var n = e.filter;
365
297
  if (typeof n == "string") {
366
- if (n === r.nodeName.toLowerCase()) return !0;
298
+ if (n === t.nodeName.toLowerCase()) return !0;
367
299
  } else if (Array.isArray(n)) {
368
- if (n.indexOf(r.nodeName.toLowerCase()) > -1) return !0;
300
+ if (n.indexOf(t.nodeName.toLowerCase()) > -1) return !0;
369
301
  } else if (typeof n == "function") {
370
- if (n.call(e, r, t)) return !0;
302
+ if (n.call(e, t, r)) return !0;
371
303
  } else
372
304
  throw new TypeError("`filter` needs to be a string, array, or function");
373
305
  }
374
- function U(e) {
375
- var r = e.element, t = e.isBlock, n = e.isVoid, i = e.isPre || function(P) {
376
- return P.nodeName === "PRE";
306
+ function G(e) {
307
+ var t = e.element, r = e.isBlock, n = e.isVoid, i = e.isPre || function(I) {
308
+ return I.nodeName === "PRE";
377
309
  };
378
- if (!(!r.firstChild || i(r))) {
379
- for (var a = null, s = !1, u = null, l = k(u, r, i); l !== r; ) {
310
+ if (!(!t.firstChild || i(t))) {
311
+ for (var a = null, s = !1, u = null, l = T(u, t, i); l !== t; ) {
380
312
  if (l.nodeType === 3 || l.nodeType === 4) {
381
- var f = l.data.replace(/[ \r\n\t]+/g, " ");
382
- if ((!a || / $/.test(a.data)) && !s && f[0] === " " && (f = f.substr(1)), !f) {
313
+ var c = l.data.replace(/[ \r\n\t]+/g, " ");
314
+ if ((!a || / $/.test(a.data)) && !s && c[0] === " " && (c = c.substr(1)), !c) {
383
315
  l = m(l);
384
316
  continue;
385
317
  }
386
- l.data = f, a = l;
318
+ l.data = c, a = l;
387
319
  } else if (l.nodeType === 1)
388
- t(l) || l.nodeName === "BR" ? (a && (a.data = a.data.replace(/ $/, "")), a = null, s = !1) : n(l) || i(l) ? (a = null, s = !0) : a && (s = !1);
320
+ r(l) || l.nodeName === "BR" ? (a && (a.data = a.data.replace(/ $/, "")), a = null, s = !1) : n(l) || i(l) ? (a = null, s = !0) : a && (s = !1);
389
321
  else {
390
322
  l = m(l);
391
323
  continue;
392
324
  }
393
- var c = k(u, l, i);
394
- u = l, l = c;
325
+ var f = T(u, l, i);
326
+ u = l, l = f;
395
327
  }
396
328
  a && (a.data = a.data.replace(/ $/, ""), a.data || m(a));
397
329
  }
398
330
  }
399
331
  function m(e) {
400
- var r = e.nextSibling || e.parentNode;
401
- return e.parentNode.removeChild(e), r;
332
+ var t = e.nextSibling || e.parentNode;
333
+ return e.parentNode.removeChild(e), t;
402
334
  }
403
- function k(e, r, t) {
404
- return e && e.parentNode === r || t(r) ? r.nextSibling || r.parentNode : r.firstChild || r.nextSibling || r.parentNode;
335
+ function T(e, t, r) {
336
+ return e && e.parentNode === t || r(t) ? t.nextSibling || t.parentNode : t.firstChild || t.nextSibling || t.parentNode;
405
337
  }
406
- var y = typeof window < "u" ? window : {};
407
- function W() {
408
- var e = y.DOMParser, r = !1;
338
+ var E = typeof window < "u" ? window : {};
339
+ function X() {
340
+ var e = E.DOMParser, t = !1;
409
341
  try {
410
- new e().parseFromString("", "text/html") && (r = !0);
342
+ new e().parseFromString("", "text/html") && (t = !0);
411
343
  } catch {
412
344
  }
413
- return r;
345
+ return t;
414
346
  }
415
- function _() {
347
+ function K() {
416
348
  var e = function() {
417
349
  };
418
- return j() ? e.prototype.parseFromString = function(r) {
419
- var t = new window.ActiveXObject("htmlfile");
420
- return t.designMode = "on", t.open(), t.write(r), t.close(), t;
421
- } : e.prototype.parseFromString = function(r) {
422
- var t = document.implementation.createHTMLDocument("");
423
- return t.open(), t.write(r), t.close(), t;
350
+ return Y() ? e.prototype.parseFromString = function(t) {
351
+ var r = new window.ActiveXObject("htmlfile");
352
+ return r.designMode = "on", r.open(), r.write(t), r.close(), r;
353
+ } : e.prototype.parseFromString = function(t) {
354
+ var r = document.implementation.createHTMLDocument("");
355
+ return r.open(), r.write(t), r.close(), r;
424
356
  }, e;
425
357
  }
426
- function j() {
358
+ function Y() {
427
359
  var e = !1;
428
360
  try {
429
361
  document.implementation.createHTMLDocument("").open();
430
362
  } catch {
431
- y.ActiveXObject && (e = !0);
363
+ E.ActiveXObject && (e = !0);
432
364
  }
433
365
  return e;
434
366
  }
435
- var G = W() ? y.DOMParser : _();
436
- function X(e, r) {
437
- var t;
367
+ var z = X() ? E.DOMParser : K();
368
+ function q(e, t) {
369
+ var r;
438
370
  if (typeof e == "string") {
439
- var n = K().parseFromString(
371
+ var n = Q().parseFromString(
440
372
  // DOM parsers arrange elements in the <head> and <body>.
441
373
  // Wrapping in a custom element ensures elements are reliably arranged in
442
374
  // a single element.
443
375
  '<x-turndown id="turndown-root">' + e + "</x-turndown>",
444
376
  "text/html"
445
377
  );
446
- t = n.getElementById("turndown-root");
378
+ r = n.getElementById("turndown-root");
447
379
  } else
448
- t = e.cloneNode(!0);
449
- return U({
450
- element: t,
380
+ r = e.cloneNode(!0);
381
+ return G({
382
+ element: r,
451
383
  isBlock: A,
452
- isVoid: S,
453
- isPre: r.preformattedCode ? Y : null
454
- }), t;
384
+ isVoid: O,
385
+ isPre: t.preformattedCode ? J : null
386
+ }), r;
455
387
  }
456
388
  var g;
457
- function K() {
458
- return g = g || new G(), g;
389
+ function Q() {
390
+ return g = g || new z(), g;
459
391
  }
460
- function Y(e) {
392
+ function J(e) {
461
393
  return e.nodeName === "PRE" || e.nodeName === "CODE";
462
394
  }
463
- function z(e, r) {
464
- return e.isBlock = A(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = q(e), e.flankingWhitespace = Q(e, r), e;
465
- }
466
- function q(e) {
467
- return !S(e) && !H(e) && /^\s*$/i.test(e.textContent) && !$(e) && !F(e);
468
- }
469
- function Q(e, r) {
470
- if (e.isBlock || r.preformattedCode && e.isCode)
471
- return { leading: "", trailing: "" };
472
- var t = J(e.textContent);
473
- return t.leadingAscii && E("left", e, r) && (t.leading = t.leadingNonAscii), t.trailingAscii && E("right", e, r) && (t.trailing = t.trailingNonAscii), { leading: t.leading, trailing: t.trailing };
395
+ function Z(e, t) {
396
+ return e.isBlock = A(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = ee(e), e.flankingWhitespace = te(e, t), e;
397
+ }
398
+ function ee(e) {
399
+ return !O(e) && !U(e) && /^\s*$/i.test(e.textContent) && !V(e) && !W(e);
400
+ }
401
+ function te(e, t) {
402
+ if (e.isBlock || t.preformattedCode && e.isCode)
403
+ return {
404
+ leading: "",
405
+ trailing: ""
406
+ };
407
+ var r = re(e.textContent);
408
+ return r.leadingAscii && R("left", e, t) && (r.leading = r.leadingNonAscii), r.trailingAscii && R("right", e, t) && (r.trailing = r.trailingNonAscii), {
409
+ leading: r.leading,
410
+ trailing: r.trailing
411
+ };
474
412
  }
475
- function J(e) {
476
- var r = e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
413
+ function re(e) {
414
+ var t = e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
477
415
  return {
478
- leading: r[1],
416
+ leading: t[1],
479
417
  // whole string for whitespace-only strings
480
- leadingAscii: r[2],
481
- leadingNonAscii: r[3],
482
- trailing: r[4],
418
+ leadingAscii: t[2],
419
+ leadingNonAscii: t[3],
420
+ trailing: t[4],
483
421
  // empty for whitespace-only strings
484
- trailingNonAscii: r[5],
485
- trailingAscii: r[6]
422
+ trailingNonAscii: t[5],
423
+ trailingAscii: t[6]
486
424
  };
487
425
  }
488
- function E(e, r, t) {
426
+ function R(e, t, r) {
489
427
  var n, i, a;
490
- return e === "left" ? (n = r.previousSibling, i = / $/) : (n = r.nextSibling, i = /^ /), n && (n.nodeType === 3 ? a = i.test(n.nodeValue) : t.preformattedCode && n.nodeName === "CODE" ? a = !1 : n.nodeType === 1 && !A(n) && (a = i.test(n.textContent))), a;
491
- }
492
- var Z = Array.prototype.reduce, ee = [
493
- [/\\/g, "\\\\"],
494
- [/\*/g, "\\*"],
495
- [/^-/g, "\\-"],
496
- [/^\+ /g, "\\+ "],
497
- [/^(=+)/g, "\\$1"],
498
- [/^(#{1,6}) /g, "\\$1 "],
499
- [/`/g, "\\`"],
500
- [/^~~~/g, "\\~~~"],
501
- [/\[/g, "\\["],
502
- [/\]/g, "\\]"],
503
- [/^>/g, "\\>"],
504
- [/_/g, "\\_"],
505
- [/^(\d+)\. /g, "$1\\. "]
506
- ];
428
+ return e === "left" ? (n = t.previousSibling, i = / $/) : (n = t.nextSibling, i = /^ /), n && (n.nodeType === 3 ? a = i.test(n.nodeValue) : r.preformattedCode && n.nodeName === "CODE" ? a = !1 : n.nodeType === 1 && !A(n) && (a = i.test(n.textContent))), a;
429
+ }
430
+ var ne = Array.prototype.reduce;
507
431
  function p(e) {
508
432
  if (!(this instanceof p)) return new p(e);
509
- var r = {
433
+ var t = {
510
434
  rules: o,
511
435
  headingStyle: "setext",
512
436
  hr: "* * *",
@@ -519,27 +443,27 @@ function p(e) {
519
443
  linkReferenceStyle: "full",
520
444
  br: " ",
521
445
  preformattedCode: !1,
522
- blankReplacement: function(t, n) {
446
+ blankReplacement: function(r, n) {
523
447
  return n.isBlock ? `
524
448
 
525
449
  ` : "";
526
450
  },
527
- keepReplacement: function(t, n) {
451
+ keepReplacement: function(r, n) {
528
452
  return n.isBlock ? `
529
453
 
530
454
  ` + n.outerHTML + `
531
455
 
532
456
  ` : n.outerHTML;
533
457
  },
534
- defaultReplacement: function(t, n) {
458
+ defaultReplacement: function(r, n) {
535
459
  return n.isBlock ? `
536
460
 
537
- ` + t + `
461
+ ` + r + `
538
462
 
539
- ` : t;
463
+ ` : r;
540
464
  }
541
465
  };
542
- this.options = M({}, r, e), this.rules = new B(this.options);
466
+ this.options = H({}, t, e), this.rules = new L(this.options);
543
467
  }
544
468
  p.prototype = {
545
469
  /**
@@ -550,13 +474,11 @@ p.prototype = {
550
474
  * @type String
551
475
  */
552
476
  turndown: function(e) {
553
- if (!ne(e))
554
- throw new TypeError(
555
- e + " is not a string, or an element/document/fragment node."
556
- );
477
+ if (!le(e))
478
+ throw new TypeError(e + " is not a string, or an element/document/fragment node.");
557
479
  if (e === "") return "";
558
- var r = D.call(this, new X(e, this.options));
559
- return re.call(this, r);
480
+ var t = P.call(this, new q(e, this.options));
481
+ return ie.call(this, t);
560
482
  },
561
483
  /**
562
484
  * Add one or more plugins
@@ -567,7 +489,7 @@ p.prototype = {
567
489
  */
568
490
  use: function(e) {
569
491
  if (Array.isArray(e))
570
- for (var r = 0; r < e.length; r++) this.use(e[r]);
492
+ for (var t = 0; t < e.length; t++) this.use(e[t]);
571
493
  else if (typeof e == "function")
572
494
  e(this);
573
495
  else
@@ -582,8 +504,8 @@ p.prototype = {
582
504
  * @returns The Turndown instance for chaining
583
505
  * @type Object
584
506
  */
585
- addRule: function(e, r) {
586
- return this.rules.add(e, r), this;
507
+ addRule: function(e, t) {
508
+ return this.rules.add(e, t), this;
587
509
  },
588
510
  /**
589
511
  * Keep a node (as HTML) that matches the filter
@@ -613,46 +535,44 @@ p.prototype = {
613
535
  * @type String
614
536
  */
615
537
  escape: function(e) {
616
- return ee.reduce(function(r, t) {
617
- return r.replace(t[0], t[1]);
618
- }, e);
538
+ return x(e);
619
539
  }
620
540
  };
621
- function D(e) {
622
- var r = this;
623
- return Z.call(e.childNodes, function(t, n) {
624
- n = new z(n, r.options);
541
+ function P(e) {
542
+ var t = this;
543
+ return ne.call(e.childNodes, function(r, n) {
544
+ n = new Z(n, t.options);
625
545
  var i = "";
626
- return n.nodeType === 3 ? i = n.isCode ? n.nodeValue : r.escape(n.nodeValue) : n.nodeType === 1 && (i = te.call(r, n)), x(t, i);
546
+ return n.nodeType === 3 ? i = n.isCode ? n.nodeValue : t.escape(n.nodeValue) : n.nodeType === 1 && (i = ae.call(t, n)), M(r, i);
627
547
  }, "");
628
548
  }
629
- function re(e) {
630
- var r = this;
631
- return this.rules.forEach(function(t) {
632
- typeof t.append == "function" && (e = x(e, t.append(r.options)));
549
+ function ie(e) {
550
+ var t = this;
551
+ return this.rules.forEach(function(r) {
552
+ typeof r.append == "function" && (e = M(e, r.append(t.options)));
633
553
  }), e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
634
554
  }
635
- function te(e) {
636
- var r = this.rules.forNode(e), t = D.call(this, e), n = e.flankingWhitespace;
637
- return (n.leading || n.trailing) && (t = t.trim()), n.leading + r.replacement(t, e, this.options) + n.trailing;
555
+ function ae(e) {
556
+ var t = this.rules.forNode(e), r = P.call(this, e), n = e.flankingWhitespace;
557
+ return (n.leading || n.trailing) && (r = r.trim()), n.leading + t.replacement(r, e, this.options) + n.trailing;
638
558
  }
639
- function x(e, r) {
640
- var t = R(e), n = T(r), i = Math.max(e.length - t.length, r.length - n.length), a = `
559
+ function M(e, t) {
560
+ var r = b(e), n = C(t), i = Math.max(e.length - r.length, t.length - n.length), a = `
641
561
 
642
562
  `.substring(0, i);
643
- return t + a + n;
563
+ return r + a + n;
644
564
  }
645
- function ne(e) {
565
+ function le(e) {
646
566
  return e != null && (typeof e == "string" || e.nodeType && (e.nodeType === 1 || e.nodeType === 9 || e.nodeType === 11));
647
567
  }
648
- const ae = (e) => {
649
- const r = new p({
568
+ const oe = (e) => {
569
+ const t = new p({
650
570
  headingStyle: "atx",
651
571
  hr: "---",
652
572
  bulletListMarker: "-",
653
573
  codeBlockStyle: "fenced"
654
574
  });
655
- r.addRule("latex", {
575
+ t.addRule("latex", {
656
576
  filter: function(n) {
657
577
  return n.nodeName === "SPAN" && n.getAttribute("data-type") === "latex";
658
578
  },
@@ -666,15 +586,15 @@ $$
666
586
 
667
587
  ` : `$${s}$`;
668
588
  }
669
- }), r.addRule("strikethrough", {
589
+ }), t.addRule("strikethrough", {
670
590
  filter: ["del", "s"],
671
591
  replacement: function(n) {
672
592
  return "~~" + n + "~~";
673
593
  }
674
594
  });
675
- const t = (n) => n.replace(/<span([^>]+data-type="latex"[^>]*)><\/span>/g, "<span$1>•</span>");
676
- return r.turndown(L.sanitize(t(e)));
595
+ const r = (n) => n.replace(/<span([^>]+data-type="latex"[^>]*)><\/span>/g, "<span$1>•</span>");
596
+ return t.turndown($.sanitize(r(e)));
677
597
  };
678
598
  export {
679
- ae as html2md
599
+ oe as html2md
680
600
  };