@subiz/widget-v4 4.1.36 → 4.1.39

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 (44) hide show
  1. package/assets/less/widget.less +1 -1
  2. package/compiled_src/chatbox/Widget.js +6 -0
  3. package/compiled_src/lib.js +43 -0
  4. package/compiled_src/popup/popup.js +16 -2
  5. package/compiled_src/store/store.js +8 -0
  6. package/compiled_src/util/common.js +3 -3
  7. package/dist/178.js +1 -1
  8. package/dist/{18924eff71e.178.js → 18a02605dff.178.js} +1 -1
  9. package/dist/18a02605dff.362.js +1 -0
  10. package/dist/18a02605dff.441.js +1 -0
  11. package/dist/18a02605dff.782.js +1 -0
  12. package/dist/18a02605dff.app.js +1 -0
  13. package/dist/{18924eff71e.index.html → 18a02605dff.index.html} +1 -1
  14. package/dist/{18924eff71e.library.html → 18a02605dff.library.html} +1 -1
  15. package/dist/18a02605dff.library.js +1 -0
  16. package/dist/{18924eff71e.preview.html → 18a02605dff.preview.html} +1 -1
  17. package/dist/18a02605dff.preview.js +1 -0
  18. package/dist/18a02605dff.screenshoot.js +1 -0
  19. package/dist/18a02605dff.webview.js +1 -0
  20. package/dist/362.js +1 -1
  21. package/dist/441.js +682 -1408
  22. package/dist/782.js +1 -1
  23. package/dist/HASH +1 -1
  24. package/dist/screenshoot.html +1 -1
  25. package/dist/screenshoot.js +68 -30
  26. package/package.json +10 -10
  27. package/src/chatbox/Widget.js +9 -0
  28. package/src/lib.js +38 -0
  29. package/src/popup/popup.js +19 -3
  30. package/src/store/store.js +10 -1
  31. package/src/util/common.js +9 -3
  32. package/dist/18924eff71e.362.js +0 -1
  33. package/dist/18924eff71e.441.js +0 -1
  34. package/dist/18924eff71e.782.js +0 -1
  35. package/dist/18924eff71e.app.js +0 -1
  36. package/dist/18924eff71e.library.js +0 -1
  37. package/dist/18924eff71e.preview.js +0 -1
  38. package/dist/18924eff71e.screenshoot.js +0 -1
  39. package/dist/18924eff71e.webview.js +0 -1
  40. /package/dist/{18924eff71e.132.js → 18a02605dff.132.js} +0 -0
  41. /package/dist/{18924eff71e.213.js → 18a02605dff.213.js} +0 -0
  42. /package/dist/{18924eff71e.335.js → 18a02605dff.335.js} +0 -0
  43. /package/dist/{18924eff71e.605.js → 18a02605dff.605.js} +0 -0
  44. /package/dist/{18924eff71e.678.js → 18a02605dff.678.js} +0 -0
package/dist/441.js CHANGED
@@ -6,16 +6,16 @@
6
6
 
7
7
  __webpack_require__.r(__webpack_exports__);
8
8
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ Hooks: () => (/* binding */ Hooks),
10
- /* harmony export */ Lexer: () => (/* binding */ Lexer),
9
+ /* harmony export */ Hooks: () => (/* binding */ _Hooks),
10
+ /* harmony export */ Lexer: () => (/* binding */ _Lexer),
11
11
  /* harmony export */ Marked: () => (/* binding */ Marked),
12
- /* harmony export */ Parser: () => (/* binding */ Parser),
13
- /* harmony export */ Renderer: () => (/* binding */ Renderer),
14
- /* harmony export */ Slugger: () => (/* binding */ Slugger),
15
- /* harmony export */ TextRenderer: () => (/* binding */ TextRenderer),
16
- /* harmony export */ Tokenizer: () => (/* binding */ Tokenizer),
17
- /* harmony export */ defaults: () => (/* binding */ defaults),
18
- /* harmony export */ getDefaults: () => (/* binding */ getDefaults),
12
+ /* harmony export */ Parser: () => (/* binding */ _Parser),
13
+ /* harmony export */ Renderer: () => (/* binding */ _Renderer),
14
+ /* harmony export */ Slugger: () => (/* binding */ _Slugger),
15
+ /* harmony export */ TextRenderer: () => (/* binding */ _TextRenderer),
16
+ /* harmony export */ Tokenizer: () => (/* binding */ _Tokenizer),
17
+ /* harmony export */ defaults: () => (/* binding */ _defaults),
18
+ /* harmony export */ getDefaults: () => (/* binding */ _getDefaults),
19
19
  /* harmony export */ lexer: () => (/* binding */ lexer),
20
20
  /* harmony export */ marked: () => (/* binding */ marked),
21
21
  /* harmony export */ options: () => (/* binding */ options),
@@ -27,7 +27,7 @@ __webpack_require__.r(__webpack_exports__);
27
27
  /* harmony export */ walkTokens: () => (/* binding */ walkTokens)
28
28
  /* harmony export */ });
29
29
  /**
30
- * marked v5.1.0 - a markdown parser
30
+ * marked v6.0.0 - a markdown parser
31
31
  * Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
32
32
  * https://github.com/markedjs/marked
33
33
  */
@@ -37,7 +37,22 @@ __webpack_require__.r(__webpack_exports__);
37
37
  * The code in this file is generated from files in ./src/
38
38
  */
39
39
 
40
- function getDefaults() {
40
+ var __accessCheck = (obj, member, msg) => {
41
+ if (!member.has(obj))
42
+ throw TypeError("Cannot " + msg);
43
+ };
44
+ var __privateAdd = (obj, member, value) => {
45
+ if (member.has(obj))
46
+ throw TypeError("Cannot add the same private member more than once");
47
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
48
+ };
49
+ var __privateMethod = (obj, member, method) => {
50
+ __accessCheck(obj, member, "access private method");
51
+ return method;
52
+ };
53
+
54
+ // src/defaults.ts
55
+ function _getDefaults() {
41
56
  return {
42
57
  async: false,
43
58
  baseUrl: null,
@@ -45,10 +60,10 @@ function getDefaults() {
45
60
  extensions: null,
46
61
  gfm: true,
47
62
  headerIds: true,
48
- headerPrefix: '',
63
+ headerPrefix: "",
49
64
  highlight: null,
50
65
  hooks: null,
51
- langPrefix: 'language-',
66
+ langPrefix: "language-",
52
67
  mangle: true,
53
68
  pedantic: false,
54
69
  renderer: null,
@@ -61,28 +76,24 @@ function getDefaults() {
61
76
  xhtml: false
62
77
  };
63
78
  }
64
-
65
- let defaults = getDefaults();
66
-
79
+ var _defaults = _getDefaults();
67
80
  function changeDefaults(newDefaults) {
68
- defaults = newDefaults;
81
+ _defaults = newDefaults;
69
82
  }
70
83
 
71
- /**
72
- * Helpers
73
- */
74
- const escapeTest = /[&<>"']/;
75
- const escapeReplace = new RegExp(escapeTest.source, 'g');
76
- const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
77
- const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
78
- const escapeReplacements = {
79
- '&': '&amp;',
80
- '<': '&lt;',
81
- '>': '&gt;',
82
- '"': '&quot;',
83
- "'": '&#39;'
84
+ // src/helpers.ts
85
+ var escapeTest = /[&<>"']/;
86
+ var escapeReplace = new RegExp(escapeTest.source, "g");
87
+ var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
88
+ var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
89
+ var escapeReplacements = {
90
+ "&": "&amp;",
91
+ "<": "&lt;",
92
+ ">": "&gt;",
93
+ '"': "&quot;",
94
+ "'": "&#39;"
84
95
  };
85
- const getEscapeReplacement = (ch) => escapeReplacements[ch];
96
+ var getEscapeReplacement = (ch) => escapeReplacements[ch];
86
97
  function escape(html, encode) {
87
98
  if (encode) {
88
99
  if (escapeTest.test(html)) {
@@ -93,42 +104,28 @@ function escape(html, encode) {
93
104
  return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
94
105
  }
95
106
  }
96
-
97
107
  return html;
98
108
  }
99
-
100
- const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
101
-
102
- /**
103
- * @param {string} html
104
- */
109
+ var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
105
110
  function unescape(html) {
106
- // explicitly match decimal, hex, and named HTML entities
107
111
  return html.replace(unescapeTest, (_, n) => {
108
112
  n = n.toLowerCase();
109
- if (n === 'colon') return ':';
110
- if (n.charAt(0) === '#') {
111
- return n.charAt(1) === 'x'
112
- ? String.fromCharCode(parseInt(n.substring(2), 16))
113
- : String.fromCharCode(+n.substring(1));
113
+ if (n === "colon")
114
+ return ":";
115
+ if (n.charAt(0) === "#") {
116
+ return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
114
117
  }
115
- return '';
118
+ return "";
116
119
  });
117
120
  }
118
-
119
- const caret = /(^|[^\[])\^/g;
120
-
121
- /**
122
- * @param {string | RegExp} regex
123
- * @param {string} opt
124
- */
121
+ var caret = /(^|[^\[])\^/g;
125
122
  function edit(regex, opt) {
126
- regex = typeof regex === 'string' ? regex : regex.source;
127
- opt = opt || '';
123
+ regex = typeof regex === "string" ? regex : regex.source;
124
+ opt = opt || "";
128
125
  const obj = {
129
126
  replace: (name, val) => {
130
- val = val.source || val;
131
- val = val.replace(caret, '$1');
127
+ val = typeof val === "object" && "source" in val ? val.source : val;
128
+ val = val.replace(caret, "$1");
132
129
  regex = regex.replace(name, val);
133
130
  return obj;
134
131
  },
@@ -138,26 +135,17 @@ function edit(regex, opt) {
138
135
  };
139
136
  return obj;
140
137
  }
141
-
142
- const nonWordAndColonTest = /[^\w:]/g;
143
- const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
144
-
145
- /**
146
- * @param {boolean} sanitize
147
- * @param {string} base
148
- * @param {string} href
149
- */
138
+ var nonWordAndColonTest = /[^\w:]/g;
139
+ var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
150
140
  function cleanUrl(sanitize, base, href) {
151
141
  if (sanitize) {
152
142
  let prot;
153
143
  try {
154
- prot = decodeURIComponent(unescape(href))
155
- .replace(nonWordAndColonTest, '')
156
- .toLowerCase();
144
+ prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, "").toLowerCase();
157
145
  } catch (e) {
158
146
  return null;
159
147
  }
160
- if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
148
+ if (prot.indexOf("javascript:") === 0 || prot.indexOf("vbscript:") === 0 || prot.indexOf("data:") === 0) {
161
149
  return null;
162
150
  }
163
151
  }
@@ -165,107 +153,76 @@ function cleanUrl(sanitize, base, href) {
165
153
  href = resolveUrl(base, href);
166
154
  }
167
155
  try {
168
- href = encodeURI(href).replace(/%25/g, '%');
156
+ href = encodeURI(href).replace(/%25/g, "%");
169
157
  } catch (e) {
170
158
  return null;
171
159
  }
172
160
  return href;
173
161
  }
174
-
175
- const baseUrls = {};
176
- const justDomain = /^[^:]+:\/*[^/]*$/;
177
- const protocol = /^([^:]+:)[\s\S]*$/;
178
- const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
179
-
180
- /**
181
- * @param {string} base
182
- * @param {string} href
183
- */
162
+ var baseUrls = {};
163
+ var justDomain = /^[^:]+:\/*[^/]*$/;
164
+ var protocol = /^([^:]+:)[\s\S]*$/;
165
+ var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
184
166
  function resolveUrl(base, href) {
185
- if (!baseUrls[' ' + base]) {
186
- // we can ignore everything in base after the last slash of its path component,
187
- // but we might need to add _that_
188
- // https://tools.ietf.org/html/rfc3986#section-3
167
+ if (!baseUrls[" " + base]) {
189
168
  if (justDomain.test(base)) {
190
- baseUrls[' ' + base] = base + '/';
169
+ baseUrls[" " + base] = base + "/";
191
170
  } else {
192
- baseUrls[' ' + base] = rtrim(base, '/', true);
171
+ baseUrls[" " + base] = rtrim(base, "/", true);
193
172
  }
194
173
  }
195
- base = baseUrls[' ' + base];
196
- const relativeBase = base.indexOf(':') === -1;
197
-
198
- if (href.substring(0, 2) === '//') {
174
+ base = baseUrls[" " + base];
175
+ const relativeBase = base.indexOf(":") === -1;
176
+ if (href.substring(0, 2) === "//") {
199
177
  if (relativeBase) {
200
178
  return href;
201
179
  }
202
- return base.replace(protocol, '$1') + href;
203
- } else if (href.charAt(0) === '/') {
180
+ return base.replace(protocol, "$1") + href;
181
+ } else if (href.charAt(0) === "/") {
204
182
  if (relativeBase) {
205
183
  return href;
206
184
  }
207
- return base.replace(domain, '$1') + href;
185
+ return base.replace(domain, "$1") + href;
208
186
  } else {
209
187
  return base + href;
210
188
  }
211
189
  }
212
-
213
- const noopTest = { exec: function noopTest() {} };
214
-
190
+ var noopTest = { exec: () => null };
215
191
  function splitCells(tableRow, count) {
216
- // ensure that every cell-delimiting pipe has a space
217
- // before it to distinguish it from an escaped pipe
218
192
  const row = tableRow.replace(/\|/g, (match, offset, str) => {
219
- let escaped = false,
220
- curr = offset;
221
- while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
222
- if (escaped) {
223
- // odd number of slashes means | is escaped
224
- // so we leave it alone
225
- return '|';
226
- } else {
227
- // add space before unescaped |
228
- return ' |';
229
- }
230
- }),
231
- cells = row.split(/ \|/);
193
+ let escaped = false, curr = offset;
194
+ while (--curr >= 0 && str[curr] === "\\")
195
+ escaped = !escaped;
196
+ if (escaped) {
197
+ return "|";
198
+ } else {
199
+ return " |";
200
+ }
201
+ }), cells = row.split(/ \|/);
232
202
  let i = 0;
233
-
234
- // First/last cell in a row cannot be empty if it has no leading/trailing pipe
235
- if (!cells[0].trim()) { cells.shift(); }
236
- if (cells.length > 0 && !cells[cells.length - 1].trim()) { cells.pop(); }
237
-
203
+ if (!cells[0].trim()) {
204
+ cells.shift();
205
+ }
206
+ if (cells.length > 0 && !cells[cells.length - 1].trim()) {
207
+ cells.pop();
208
+ }
238
209
  if (cells.length > count) {
239
210
  cells.splice(count);
240
211
  } else {
241
- while (cells.length < count) cells.push('');
212
+ while (cells.length < count)
213
+ cells.push("");
242
214
  }
243
-
244
215
  for (; i < cells.length; i++) {
245
- // leading or trailing whitespace is ignored per the gfm spec
246
- cells[i] = cells[i].trim().replace(/\\\|/g, '|');
216
+ cells[i] = cells[i].trim().replace(/\\\|/g, "|");
247
217
  }
248
218
  return cells;
249
219
  }
250
-
251
- /**
252
- * Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
253
- * /c*$/ is vulnerable to REDOS.
254
- *
255
- * @param {string} str
256
- * @param {string} c
257
- * @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
258
- */
259
220
  function rtrim(str, c, invert) {
260
221
  const l = str.length;
261
222
  if (l === 0) {
262
- return '';
223
+ return "";
263
224
  }
264
-
265
- // Length of suffix matching the invert condition.
266
225
  let suffLen = 0;
267
-
268
- // Step left until we fail to match the invert condition.
269
226
  while (suffLen < l) {
270
227
  const currChar = str.charAt(l - suffLen - 1);
271
228
  if (currChar === c && !invert) {
@@ -276,19 +233,16 @@ function rtrim(str, c, invert) {
276
233
  break;
277
234
  }
278
235
  }
279
-
280
236
  return str.slice(0, l - suffLen);
281
237
  }
282
-
283
238
  function findClosingBracket(str, b) {
284
239
  if (str.indexOf(b[1]) === -1) {
285
240
  return -1;
286
241
  }
287
242
  const l = str.length;
288
- let level = 0,
289
- i = 0;
243
+ let level = 0, i = 0;
290
244
  for (; i < l; i++) {
291
- if (str[i] === '\\') {
245
+ if (str[i] === "\\") {
292
246
  i++;
293
247
  } else if (str[i] === b[0]) {
294
248
  level++;
@@ -301,166 +255,132 @@ function findClosingBracket(str, b) {
301
255
  }
302
256
  return -1;
303
257
  }
304
-
305
258
  function checkDeprecations(opt, callback) {
306
259
  if (!opt || opt.silent) {
307
260
  return;
308
261
  }
309
-
310
262
  if (callback) {
311
- console.warn('marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async');
263
+ console.warn("marked(): callback is deprecated since version 5.0.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/using_pro#async");
312
264
  }
313
-
314
265
  if (opt.sanitize || opt.sanitizer) {
315
- console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
266
+ console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options");
316
267
  }
317
-
318
- if (opt.highlight || opt.langPrefix !== 'language-') {
319
- console.warn('marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight.');
268
+ if (opt.highlight || opt.langPrefix !== "language-") {
269
+ console.warn("marked(): highlight and langPrefix parameters are deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-highlight.");
320
270
  }
321
-
322
271
  if (opt.mangle) {
323
- console.warn('marked(): mangle parameter is enabled by default, but is deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-mangle, or disable by setting `{mangle: false}`.');
272
+ console.warn("marked(): mangle parameter is enabled by default, but is deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-mangle, or disable by setting `{mangle: false}`.");
324
273
  }
325
-
326
274
  if (opt.baseUrl) {
327
- console.warn('marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url.');
275
+ console.warn("marked(): baseUrl parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-base-url.");
328
276
  }
329
-
330
277
  if (opt.smartypants) {
331
- console.warn('marked(): smartypants parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-smartypants.');
278
+ console.warn("marked(): smartypants parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-smartypants.");
332
279
  }
333
-
334
280
  if (opt.xhtml) {
335
- console.warn('marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml.');
281
+ console.warn("marked(): xhtml parameter is deprecated since version 5.0.0, should not be used and will be removed in the future. Instead use https://www.npmjs.com/package/marked-xhtml.");
336
282
  }
337
-
338
283
  if (opt.headerIds || opt.headerPrefix) {
339
- console.warn('marked(): headerIds and headerPrefix parameters enabled by default, but are deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-gfm-heading-id, or disable by setting `{headerIds: false}`.');
284
+ console.warn("marked(): headerIds and headerPrefix parameters enabled by default, but are deprecated since version 5.0.0, and will be removed in the future. To clear this warning, install https://www.npmjs.com/package/marked-gfm-heading-id, or disable by setting `{headerIds: false}`.");
340
285
  }
341
286
  }
342
287
 
343
- function outputLink(cap, link, raw, lexer) {
288
+ // src/Tokenizer.ts
289
+ function outputLink(cap, link, raw, lexer2) {
344
290
  const href = link.href;
345
291
  const title = link.title ? escape(link.title) : null;
346
- const text = cap[1].replace(/\\([\[\]])/g, '$1');
347
-
348
- if (cap[0].charAt(0) !== '!') {
349
- lexer.state.inLink = true;
292
+ const text = cap[1].replace(/\\([\[\]])/g, "$1");
293
+ if (cap[0].charAt(0) !== "!") {
294
+ lexer2.state.inLink = true;
350
295
  const token = {
351
- type: 'link',
296
+ type: "link",
352
297
  raw,
353
298
  href,
354
299
  title,
355
300
  text,
356
- tokens: lexer.inlineTokens(text)
301
+ tokens: lexer2.inlineTokens(text)
357
302
  };
358
- lexer.state.inLink = false;
303
+ lexer2.state.inLink = false;
359
304
  return token;
360
305
  }
361
306
  return {
362
- type: 'image',
307
+ type: "image",
363
308
  raw,
364
309
  href,
365
310
  title,
366
311
  text: escape(text)
367
312
  };
368
313
  }
369
-
370
314
  function indentCodeCompensation(raw, text) {
371
315
  const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
372
-
373
316
  if (matchIndentToCode === null) {
374
317
  return text;
375
318
  }
376
-
377
319
  const indentToCode = matchIndentToCode[1];
378
-
379
- return text
380
- .split('\n')
381
- .map(node => {
382
- const matchIndentInNode = node.match(/^\s+/);
383
- if (matchIndentInNode === null) {
384
- return node;
385
- }
386
-
387
- const [indentInNode] = matchIndentInNode;
388
-
389
- if (indentInNode.length >= indentToCode.length) {
390
- return node.slice(indentToCode.length);
391
- }
392
-
320
+ return text.split("\n").map((node) => {
321
+ const matchIndentInNode = node.match(/^\s+/);
322
+ if (matchIndentInNode === null) {
393
323
  return node;
394
- })
395
- .join('\n');
324
+ }
325
+ const [indentInNode] = matchIndentInNode;
326
+ if (indentInNode.length >= indentToCode.length) {
327
+ return node.slice(indentToCode.length);
328
+ }
329
+ return node;
330
+ }).join("\n");
396
331
  }
397
-
398
- /**
399
- * Tokenizer
400
- */
401
- class Tokenizer {
402
- constructor(options) {
403
- this.options = options || defaults;
332
+ var _Tokenizer = class {
333
+ constructor(options2) {
334
+ this.options = options2 || _defaults;
404
335
  }
405
-
406
336
  space(src) {
407
337
  const cap = this.rules.block.newline.exec(src);
408
338
  if (cap && cap[0].length > 0) {
409
339
  return {
410
- type: 'space',
340
+ type: "space",
411
341
  raw: cap[0]
412
342
  };
413
343
  }
414
344
  }
415
-
416
345
  code(src) {
417
346
  const cap = this.rules.block.code.exec(src);
418
347
  if (cap) {
419
- const text = cap[0].replace(/^ {1,4}/gm, '');
348
+ const text = cap[0].replace(/^ {1,4}/gm, "");
420
349
  return {
421
- type: 'code',
350
+ type: "code",
422
351
  raw: cap[0],
423
- codeBlockStyle: 'indented',
424
- text: !this.options.pedantic
425
- ? rtrim(text, '\n')
426
- : text
352
+ codeBlockStyle: "indented",
353
+ text: !this.options.pedantic ? rtrim(text, "\n") : text
427
354
  };
428
355
  }
429
356
  }
430
-
431
357
  fences(src) {
432
358
  const cap = this.rules.block.fences.exec(src);
433
359
  if (cap) {
434
360
  const raw = cap[0];
435
- const text = indentCodeCompensation(raw, cap[3] || '');
436
-
361
+ const text = indentCodeCompensation(raw, cap[3] || "");
437
362
  return {
438
- type: 'code',
363
+ type: "code",
439
364
  raw,
440
- lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, '$1') : cap[2],
365
+ lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, "$1") : cap[2],
441
366
  text
442
367
  };
443
368
  }
444
369
  }
445
-
446
370
  heading(src) {
447
371
  const cap = this.rules.block.heading.exec(src);
448
372
  if (cap) {
449
373
  let text = cap[2].trim();
450
-
451
- // remove trailing #s
452
374
  if (/#$/.test(text)) {
453
- const trimmed = rtrim(text, '#');
375
+ const trimmed = rtrim(text, "#");
454
376
  if (this.options.pedantic) {
455
377
  text = trimmed.trim();
456
378
  } else if (!trimmed || / $/.test(trimmed)) {
457
- // CommonMark requires space before trailing #s
458
379
  text = trimmed.trim();
459
380
  }
460
381
  }
461
-
462
382
  return {
463
- type: 'heading',
383
+ type: "heading",
464
384
  raw: cap[0],
465
385
  depth: cap[1].length,
466
386
  text,
@@ -468,142 +388,107 @@ class Tokenizer {
468
388
  };
469
389
  }
470
390
  }
471
-
472
391
  hr(src) {
473
392
  const cap = this.rules.block.hr.exec(src);
474
393
  if (cap) {
475
394
  return {
476
- type: 'hr',
395
+ type: "hr",
477
396
  raw: cap[0]
478
397
  };
479
398
  }
480
399
  }
481
-
482
400
  blockquote(src) {
483
401
  const cap = this.rules.block.blockquote.exec(src);
484
402
  if (cap) {
485
- const text = cap[0].replace(/^ *>[ \t]?/gm, '');
403
+ const text = cap[0].replace(/^ *>[ \t]?/gm, "");
486
404
  const top = this.lexer.state.top;
487
405
  this.lexer.state.top = true;
488
406
  const tokens = this.lexer.blockTokens(text);
489
407
  this.lexer.state.top = top;
490
408
  return {
491
- type: 'blockquote',
409
+ type: "blockquote",
492
410
  raw: cap[0],
493
411
  tokens,
494
412
  text
495
413
  };
496
414
  }
497
415
  }
498
-
499
416
  list(src) {
500
417
  let cap = this.rules.block.list.exec(src);
501
418
  if (cap) {
502
- let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine,
503
- line, nextLine, rawLine, itemContents, endEarly;
504
-
419
+ let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, nextLine, rawLine, itemContents, endEarly;
505
420
  let bull = cap[1].trim();
506
421
  const isordered = bull.length > 1;
507
-
508
422
  const list = {
509
- type: 'list',
510
- raw: '',
423
+ type: "list",
424
+ raw: "",
511
425
  ordered: isordered,
512
- start: isordered ? +bull.slice(0, -1) : '',
426
+ start: isordered ? +bull.slice(0, -1) : "",
513
427
  loose: false,
514
428
  items: []
515
429
  };
516
-
517
430
  bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
518
-
519
431
  if (this.options.pedantic) {
520
- bull = isordered ? bull : '[*+-]';
432
+ bull = isordered ? bull : "[*+-]";
521
433
  }
522
-
523
- // Get next list item
524
- const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
525
-
526
- // Check if current bullet point can start a new List Item
434
+ const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
527
435
  while (src) {
528
436
  endEarly = false;
529
437
  if (!(cap = itemRegex.exec(src))) {
530
438
  break;
531
439
  }
532
-
533
- if (this.rules.block.hr.test(src)) { // End list if bullet was actually HR (possibly move into itemRegex?)
440
+ if (this.rules.block.hr.test(src)) {
534
441
  break;
535
442
  }
536
-
537
443
  raw = cap[0];
538
444
  src = src.substring(raw.length);
539
-
540
- line = cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length));
541
- nextLine = src.split('\n', 1)[0];
542
-
445
+ line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t) => " ".repeat(3 * t.length));
446
+ nextLine = src.split("\n", 1)[0];
543
447
  if (this.options.pedantic) {
544
448
  indent = 2;
545
449
  itemContents = line.trimLeft();
546
450
  } else {
547
- indent = cap[2].search(/[^ ]/); // Find first non-space char
548
- indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
451
+ indent = cap[2].search(/[^ ]/);
452
+ indent = indent > 4 ? 1 : indent;
549
453
  itemContents = line.slice(indent);
550
454
  indent += cap[1].length;
551
455
  }
552
-
553
456
  blankLine = false;
554
-
555
- if (!line && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
556
- raw += nextLine + '\n';
457
+ if (!line && /^ *$/.test(nextLine)) {
458
+ raw += nextLine + "\n";
557
459
  src = src.substring(nextLine.length + 1);
558
460
  endEarly = true;
559
461
  }
560
-
561
462
  if (!endEarly) {
562
- const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
463
+ const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`);
563
464
  const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
564
465
  const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
565
466
  const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
566
-
567
- // Check if following lines should be included in List Item
568
467
  while (src) {
569
- rawLine = src.split('\n', 1)[0];
468
+ rawLine = src.split("\n", 1)[0];
570
469
  nextLine = rawLine;
571
-
572
- // Re-align to follow commonmark nesting rules
573
470
  if (this.options.pedantic) {
574
- nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
471
+ nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
575
472
  }
576
-
577
- // End list item if found code fences
578
473
  if (fencesBeginRegex.test(nextLine)) {
579
474
  break;
580
475
  }
581
-
582
- // End list item if found start of new heading
583
476
  if (headingBeginRegex.test(nextLine)) {
584
477
  break;
585
478
  }
586
-
587
- // End list item if found start of new bullet
588
479
  if (nextBulletRegex.test(nextLine)) {
589
480
  break;
590
481
  }
591
-
592
- // Horizontal rule found
593
482
  if (hrRegex.test(src)) {
594
483
  break;
595
484
  }
596
-
597
- if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible
598
- itemContents += '\n' + nextLine.slice(indent);
485
+ if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
486
+ itemContents += "\n" + nextLine.slice(indent);
599
487
  } else {
600
- // not enough indentation
601
488
  if (blankLine) {
602
489
  break;
603
490
  }
604
-
605
- // paragraph continuation unless last line was a different block level element
606
- if (line.search(/[^ ]/) >= 4) { // indented code block
491
+ if (line.search(/[^ ]/) >= 4) {
607
492
  break;
608
493
  }
609
494
  if (fencesBeginRegex.test(line)) {
@@ -615,111 +500,89 @@ class Tokenizer {
615
500
  if (hrRegex.test(line)) {
616
501
  break;
617
502
  }
618
-
619
- itemContents += '\n' + nextLine;
503
+ itemContents += "\n" + nextLine;
620
504
  }
621
-
622
- if (!blankLine && !nextLine.trim()) { // Check if current line is blank
505
+ if (!blankLine && !nextLine.trim()) {
623
506
  blankLine = true;
624
507
  }
625
-
626
- raw += rawLine + '\n';
508
+ raw += rawLine + "\n";
627
509
  src = src.substring(rawLine.length + 1);
628
510
  line = nextLine.slice(indent);
629
511
  }
630
512
  }
631
-
632
513
  if (!list.loose) {
633
- // If the previous item ended with a blank line, the list is loose
634
514
  if (endsWithBlankLine) {
635
515
  list.loose = true;
636
516
  } else if (/\n *\n *$/.test(raw)) {
637
517
  endsWithBlankLine = true;
638
518
  }
639
519
  }
640
-
641
- // Check for task list items
642
520
  if (this.options.gfm) {
643
521
  istask = /^\[[ xX]\] /.exec(itemContents);
644
522
  if (istask) {
645
- ischecked = istask[0] !== '[ ] ';
646
- itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
523
+ ischecked = istask[0] !== "[ ] ";
524
+ itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
647
525
  }
648
526
  }
649
-
650
527
  list.items.push({
651
- type: 'list_item',
528
+ type: "list_item",
652
529
  raw,
653
530
  task: !!istask,
654
531
  checked: ischecked,
655
532
  loose: false,
656
533
  text: itemContents
657
534
  });
658
-
659
535
  list.raw += raw;
660
536
  }
661
-
662
- // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
663
537
  list.items[list.items.length - 1].raw = raw.trimRight();
664
538
  list.items[list.items.length - 1].text = itemContents.trimRight();
665
539
  list.raw = list.raw.trimRight();
666
-
667
540
  const l = list.items.length;
668
-
669
- // Item child tokens handled here at end because we needed to have the final item to trim it first
670
541
  for (i = 0; i < l; i++) {
671
542
  this.lexer.state.top = false;
672
543
  list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
673
-
674
544
  if (!list.loose) {
675
- // Check if list should be loose
676
- const spacers = list.items[i].tokens.filter(t => t.type === 'space');
677
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => /\n.*\n/.test(t.raw));
678
-
545
+ const spacers = list.items[i].tokens.filter((t) => t.type === "space");
546
+ const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => /\n.*\n/.test(t.raw));
679
547
  list.loose = hasMultipleLineBreaks;
680
548
  }
681
549
  }
682
-
683
- // Set all items to loose if list is loose
684
550
  if (list.loose) {
685
551
  for (i = 0; i < l; i++) {
686
552
  list.items[i].loose = true;
687
553
  }
688
554
  }
689
-
690
555
  return list;
691
556
  }
692
557
  }
693
-
694
558
  html(src) {
695
559
  const cap = this.rules.block.html.exec(src);
696
560
  if (cap) {
697
561
  const token = {
698
- type: 'html',
562
+ type: "html",
699
563
  block: true,
700
564
  raw: cap[0],
701
- pre: !this.options.sanitizer
702
- && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
565
+ pre: !this.options.sanitizer && (cap[1] === "pre" || cap[1] === "script" || cap[1] === "style"),
703
566
  text: cap[0]
704
567
  };
705
568
  if (this.options.sanitize) {
706
569
  const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
707
- token.type = 'paragraph';
708
- token.text = text;
709
- token.tokens = this.lexer.inline(text);
570
+ const paragraph = token;
571
+ paragraph.type = "paragraph";
572
+ paragraph.text = text;
573
+ paragraph.tokens = this.lexer.inline(text);
710
574
  }
711
575
  return token;
712
576
  }
713
577
  }
714
-
715
578
  def(src) {
716
579
  const cap = this.rules.block.def.exec(src);
717
580
  if (cap) {
718
- const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
719
- const href = cap[2] ? cap[2].replace(/^<(.*)>$/, '$1').replace(this.rules.inline._escapes, '$1') : '';
720
- const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline._escapes, '$1') : cap[3];
581
+ const tag = cap[1].toLowerCase().replace(/\s+/g, " ");
582
+ const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline._escapes, "$1") : "";
583
+ const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline._escapes, "$1") : cap[3];
721
584
  return {
722
- type: 'def',
585
+ type: "def",
723
586
  tag,
724
587
  raw: cap[0],
725
588
  href,
@@ -727,48 +590,44 @@ class Tokenizer {
727
590
  };
728
591
  }
729
592
  }
730
-
731
593
  table(src) {
732
594
  const cap = this.rules.block.table.exec(src);
733
595
  if (cap) {
734
596
  const item = {
735
- type: 'table',
736
- header: splitCells(cap[1]).map(c => { return { text: c }; }),
737
- align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
738
- rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
597
+ type: "table",
598
+ // splitCells expects a number as second argument
599
+ // @ts-expect-error
600
+ header: splitCells(cap[1]).map((c) => {
601
+ return { text: c };
602
+ }),
603
+ align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
604
+ rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : []
739
605
  };
740
-
741
606
  if (item.header.length === item.align.length) {
742
607
  item.raw = cap[0];
743
-
744
608
  let l = item.align.length;
745
609
  let i, j, k, row;
746
610
  for (i = 0; i < l; i++) {
747
611
  if (/^ *-+: *$/.test(item.align[i])) {
748
- item.align[i] = 'right';
612
+ item.align[i] = "right";
749
613
  } else if (/^ *:-+: *$/.test(item.align[i])) {
750
- item.align[i] = 'center';
614
+ item.align[i] = "center";
751
615
  } else if (/^ *:-+ *$/.test(item.align[i])) {
752
- item.align[i] = 'left';
616
+ item.align[i] = "left";
753
617
  } else {
754
618
  item.align[i] = null;
755
619
  }
756
620
  }
757
-
758
621
  l = item.rows.length;
759
622
  for (i = 0; i < l; i++) {
760
- item.rows[i] = splitCells(item.rows[i], item.header.length).map(c => { return { text: c }; });
623
+ item.rows[i] = splitCells(item.rows[i], item.header.length).map((c) => {
624
+ return { text: c };
625
+ });
761
626
  }
762
-
763
- // parse child tokens inside headers and cells
764
-
765
- // header child tokens
766
627
  l = item.header.length;
767
628
  for (j = 0; j < l; j++) {
768
629
  item.header[j].tokens = this.lexer.inline(item.header[j].text);
769
630
  }
770
-
771
- // cell child tokens
772
631
  l = item.rows.length;
773
632
  for (j = 0; j < l; j++) {
774
633
  row = item.rows[j];
@@ -776,63 +635,55 @@ class Tokenizer {
776
635
  row[k].tokens = this.lexer.inline(row[k].text);
777
636
  }
778
637
  }
779
-
780
638
  return item;
781
639
  }
782
640
  }
783
641
  }
784
-
785
642
  lheading(src) {
786
643
  const cap = this.rules.block.lheading.exec(src);
787
644
  if (cap) {
788
645
  return {
789
- type: 'heading',
646
+ type: "heading",
790
647
  raw: cap[0],
791
- depth: cap[2].charAt(0) === '=' ? 1 : 2,
648
+ depth: cap[2].charAt(0) === "=" ? 1 : 2,
792
649
  text: cap[1],
793
650
  tokens: this.lexer.inline(cap[1])
794
651
  };
795
652
  }
796
653
  }
797
-
798
654
  paragraph(src) {
799
655
  const cap = this.rules.block.paragraph.exec(src);
800
656
  if (cap) {
801
- const text = cap[1].charAt(cap[1].length - 1) === '\n'
802
- ? cap[1].slice(0, -1)
803
- : cap[1];
657
+ const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
804
658
  return {
805
- type: 'paragraph',
659
+ type: "paragraph",
806
660
  raw: cap[0],
807
661
  text,
808
662
  tokens: this.lexer.inline(text)
809
663
  };
810
664
  }
811
665
  }
812
-
813
666
  text(src) {
814
667
  const cap = this.rules.block.text.exec(src);
815
668
  if (cap) {
816
669
  return {
817
- type: 'text',
670
+ type: "text",
818
671
  raw: cap[0],
819
672
  text: cap[0],
820
673
  tokens: this.lexer.inline(cap[0])
821
674
  };
822
675
  }
823
676
  }
824
-
825
677
  escape(src) {
826
678
  const cap = this.rules.inline.escape.exec(src);
827
679
  if (cap) {
828
680
  return {
829
- type: 'escape',
681
+ type: "escape",
830
682
  raw: cap[0],
831
683
  text: escape(cap[1])
832
684
  };
833
685
  }
834
686
  }
835
-
836
687
  tag(src) {
837
688
  const cap = this.rules.inline.tag.exec(src);
838
689
  if (cap) {
@@ -846,90 +697,72 @@ class Tokenizer {
846
697
  } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
847
698
  this.lexer.state.inRawBlock = false;
848
699
  }
849
-
850
700
  return {
851
- type: this.options.sanitize
852
- ? 'text'
853
- : 'html',
701
+ type: this.options.sanitize ? "text" : "html",
854
702
  raw: cap[0],
855
703
  inLink: this.lexer.state.inLink,
856
704
  inRawBlock: this.lexer.state.inRawBlock,
857
705
  block: false,
858
- text: this.options.sanitize
859
- ? (this.options.sanitizer
860
- ? this.options.sanitizer(cap[0])
861
- : escape(cap[0]))
862
- : cap[0]
706
+ text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]
863
707
  };
864
708
  }
865
709
  }
866
-
867
710
  link(src) {
868
711
  const cap = this.rules.inline.link.exec(src);
869
712
  if (cap) {
870
713
  const trimmedUrl = cap[2].trim();
871
714
  if (!this.options.pedantic && /^</.test(trimmedUrl)) {
872
- // commonmark requires matching angle brackets
873
- if (!(/>$/.test(trimmedUrl))) {
715
+ if (!/>$/.test(trimmedUrl)) {
874
716
  return;
875
717
  }
876
-
877
- // ending angle bracket cannot be escaped
878
- const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
718
+ const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
879
719
  if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
880
720
  return;
881
721
  }
882
722
  } else {
883
- // find closing parenthesis
884
- const lastParenIndex = findClosingBracket(cap[2], '()');
723
+ const lastParenIndex = findClosingBracket(cap[2], "()");
885
724
  if (lastParenIndex > -1) {
886
- const start = cap[0].indexOf('!') === 0 ? 5 : 4;
725
+ const start = cap[0].indexOf("!") === 0 ? 5 : 4;
887
726
  const linkLen = start + cap[1].length + lastParenIndex;
888
727
  cap[2] = cap[2].substring(0, lastParenIndex);
889
728
  cap[0] = cap[0].substring(0, linkLen).trim();
890
- cap[3] = '';
729
+ cap[3] = "";
891
730
  }
892
731
  }
893
732
  let href = cap[2];
894
- let title = '';
733
+ let title = "";
895
734
  if (this.options.pedantic) {
896
- // split pedantic href and title
897
735
  const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
898
-
899
736
  if (link) {
900
737
  href = link[1];
901
738
  title = link[3];
902
739
  }
903
740
  } else {
904
- title = cap[3] ? cap[3].slice(1, -1) : '';
741
+ title = cap[3] ? cap[3].slice(1, -1) : "";
905
742
  }
906
-
907
743
  href = href.trim();
908
744
  if (/^</.test(href)) {
909
- if (this.options.pedantic && !(/>$/.test(trimmedUrl))) {
910
- // pedantic allows starting angle bracket without ending angle bracket
745
+ if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
911
746
  href = href.slice(1);
912
747
  } else {
913
748
  href = href.slice(1, -1);
914
749
  }
915
750
  }
916
751
  return outputLink(cap, {
917
- href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
918
- title: title ? title.replace(this.rules.inline._escapes, '$1') : title
752
+ href: href ? href.replace(this.rules.inline._escapes, "$1") : href,
753
+ title: title ? title.replace(this.rules.inline._escapes, "$1") : title
919
754
  }, cap[0], this.lexer);
920
755
  }
921
756
  }
922
-
923
757
  reflink(src, links) {
924
758
  let cap;
925
- if ((cap = this.rules.inline.reflink.exec(src))
926
- || (cap = this.rules.inline.nolink.exec(src))) {
927
- let link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
759
+ if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
760
+ let link = (cap[2] || cap[1]).replace(/\s+/g, " ");
928
761
  link = links[link.toLowerCase()];
929
762
  if (!link) {
930
763
  const text = cap[0].charAt(0);
931
764
  return {
932
- type: 'text',
765
+ type: "text",
933
766
  raw: text,
934
767
  text
935
768
  };
@@ -937,67 +770,50 @@ class Tokenizer {
937
770
  return outputLink(cap, link, cap[0], this.lexer);
938
771
  }
939
772
  }
940
-
941
- emStrong(src, maskedSrc, prevChar = '') {
773
+ emStrong(src, maskedSrc, prevChar = "") {
942
774
  let match = this.rules.inline.emStrong.lDelim.exec(src);
943
- if (!match) return;
944
-
945
- // _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
946
- if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) return;
947
-
948
- const nextChar = match[1] || match[2] || '';
949
-
775
+ if (!match)
776
+ return;
777
+ if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
778
+ return;
779
+ const nextChar = match[1] || match[2] || "";
950
780
  if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
951
781
  const lLength = match[0].length - 1;
952
782
  let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
953
-
954
- const endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
783
+ const endReg = match[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
955
784
  endReg.lastIndex = 0;
956
-
957
- // Clip maskedSrc to same section of string as src (move to lexer?)
958
785
  maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
959
-
960
786
  while ((match = endReg.exec(maskedSrc)) != null) {
961
787
  rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
962
-
963
- if (!rDelim) continue; // skip single * in __abc*abc__
964
-
788
+ if (!rDelim)
789
+ continue;
965
790
  rLength = rDelim.length;
966
-
967
- if (match[3] || match[4]) { // found another Left Delim
791
+ if (match[3] || match[4]) {
968
792
  delimTotal += rLength;
969
793
  continue;
970
- } else if (match[5] || match[6]) { // either Left or Right Delim
794
+ } else if (match[5] || match[6]) {
971
795
  if (lLength % 3 && !((lLength + rLength) % 3)) {
972
796
  midDelimTotal += rLength;
973
- continue; // CommonMark Emphasis Rules 9-10
797
+ continue;
974
798
  }
975
799
  }
976
-
977
800
  delimTotal -= rLength;
978
-
979
- if (delimTotal > 0) continue; // Haven't found enough closing delimiters
980
-
981
- // Remove extra characters. *a*** -> *a*
801
+ if (delimTotal > 0)
802
+ continue;
982
803
  rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
983
-
984
804
  const raw = src.slice(0, lLength + match.index + rLength + 1);
985
-
986
- // Create `em` if smallest delimiter has odd char count. *a***
987
805
  if (Math.min(lLength, rLength) % 2) {
988
- const text = raw.slice(1, -1);
806
+ const text2 = raw.slice(1, -1);
989
807
  return {
990
- type: 'em',
808
+ type: "em",
991
809
  raw,
992
- text,
993
- tokens: this.lexer.inlineTokens(text)
810
+ text: text2,
811
+ tokens: this.lexer.inlineTokens(text2)
994
812
  };
995
813
  }
996
-
997
- // Create 'strong' if smallest delimiter has even char count. **a***
998
814
  const text = raw.slice(2, -2);
999
815
  return {
1000
- type: 'strong',
816
+ type: "strong",
1001
817
  raw,
1002
818
  text,
1003
819
  tokens: this.lexer.inlineTokens(text)
@@ -1005,11 +821,10 @@ class Tokenizer {
1005
821
  }
1006
822
  }
1007
823
  }
1008
-
1009
824
  codespan(src) {
1010
825
  const cap = this.rules.inline.code.exec(src);
1011
826
  if (cap) {
1012
- let text = cap[2].replace(/\n/g, ' ');
827
+ let text = cap[2].replace(/\n/g, " ");
1013
828
  const hasNonSpaceChars = /[^ ]/.test(text);
1014
829
  const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
1015
830
  if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
@@ -1017,55 +832,51 @@ class Tokenizer {
1017
832
  }
1018
833
  text = escape(text, true);
1019
834
  return {
1020
- type: 'codespan',
835
+ type: "codespan",
1021
836
  raw: cap[0],
1022
837
  text
1023
838
  };
1024
839
  }
1025
840
  }
1026
-
1027
841
  br(src) {
1028
842
  const cap = this.rules.inline.br.exec(src);
1029
843
  if (cap) {
1030
844
  return {
1031
- type: 'br',
845
+ type: "br",
1032
846
  raw: cap[0]
1033
847
  };
1034
848
  }
1035
849
  }
1036
-
1037
850
  del(src) {
1038
851
  const cap = this.rules.inline.del.exec(src);
1039
852
  if (cap) {
1040
853
  return {
1041
- type: 'del',
854
+ type: "del",
1042
855
  raw: cap[0],
1043
856
  text: cap[2],
1044
857
  tokens: this.lexer.inlineTokens(cap[2])
1045
858
  };
1046
859
  }
1047
860
  }
1048
-
1049
- autolink(src, mangle) {
861
+ autolink(src, mangle2) {
1050
862
  const cap = this.rules.inline.autolink.exec(src);
1051
863
  if (cap) {
1052
864
  let text, href;
1053
- if (cap[2] === '@') {
1054
- text = escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
1055
- href = 'mailto:' + text;
865
+ if (cap[2] === "@") {
866
+ text = escape(this.options.mangle ? mangle2(cap[1]) : cap[1]);
867
+ href = "mailto:" + text;
1056
868
  } else {
1057
869
  text = escape(cap[1]);
1058
870
  href = text;
1059
871
  }
1060
-
1061
872
  return {
1062
- type: 'link',
873
+ type: "link",
1063
874
  raw: cap[0],
1064
875
  text,
1065
876
  href,
1066
877
  tokens: [
1067
878
  {
1068
- type: 'text',
879
+ type: "text",
1069
880
  raw: text,
1070
881
  text
1071
882
  }
@@ -1073,36 +884,34 @@ class Tokenizer {
1073
884
  };
1074
885
  }
1075
886
  }
1076
-
1077
- url(src, mangle) {
887
+ url(src, mangle2) {
1078
888
  let cap;
1079
889
  if (cap = this.rules.inline.url.exec(src)) {
1080
890
  let text, href;
1081
- if (cap[2] === '@') {
1082
- text = escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
1083
- href = 'mailto:' + text;
891
+ if (cap[2] === "@") {
892
+ text = escape(this.options.mangle ? mangle2(cap[0]) : cap[0]);
893
+ href = "mailto:" + text;
1084
894
  } else {
1085
- // do extended autolink path validation
1086
895
  let prevCapZero;
1087
896
  do {
1088
897
  prevCapZero = cap[0];
1089
898
  cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
1090
899
  } while (prevCapZero !== cap[0]);
1091
900
  text = escape(cap[0]);
1092
- if (cap[1] === 'www.') {
1093
- href = 'http://' + cap[0];
901
+ if (cap[1] === "www.") {
902
+ href = "http://" + cap[0];
1094
903
  } else {
1095
904
  href = cap[0];
1096
905
  }
1097
906
  }
1098
907
  return {
1099
- type: 'link',
908
+ type: "link",
1100
909
  raw: cap[0],
1101
910
  text,
1102
911
  href,
1103
912
  tokens: [
1104
913
  {
1105
- type: 'text',
914
+ type: "text",
1106
915
  raw: text,
1107
916
  text
1108
917
  }
@@ -1110,29 +919,26 @@ class Tokenizer {
1110
919
  };
1111
920
  }
1112
921
  }
1113
-
1114
- inlineText(src, smartypants) {
922
+ inlineText(src, smartypants2) {
1115
923
  const cap = this.rules.inline.text.exec(src);
1116
924
  if (cap) {
1117
925
  let text;
1118
926
  if (this.lexer.state.inRawBlock) {
1119
- text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0];
927
+ text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
1120
928
  } else {
1121
- text = escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
929
+ text = escape(this.options.smartypants ? smartypants2(cap[0]) : cap[0]);
1122
930
  }
1123
931
  return {
1124
- type: 'text',
932
+ type: "text",
1125
933
  raw: cap[0],
1126
934
  text
1127
935
  };
1128
936
  }
1129
937
  }
1130
- }
938
+ };
1131
939
 
1132
- /**
1133
- * Block-Level Grammar
1134
- */
1135
- const block = {
940
+ // src/rules.ts
941
+ var block = {
1136
942
  newline: /^(?: *(?:\n|$))+/,
1137
943
  code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
1138
944
  fences: /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
@@ -1140,16 +946,7 @@ const block = {
1140
946
  heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
1141
947
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
1142
948
  list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
1143
- html: '^ {0,3}(?:' // optional indentation
1144
- + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
1145
- + '|comment[^\\n]*(\\n+|$)' // (2)
1146
- + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
1147
- + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
1148
- + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
1149
- + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
1150
- + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
1151
- + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
1152
- + ')',
949
+ html: "^ {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 *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",
1153
950
  def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
1154
951
  table: noopTest,
1155
952
  lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
@@ -1158,151 +955,55 @@ const block = {
1158
955
  _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
1159
956
  text: /^[^\n]+/
1160
957
  };
1161
-
1162
958
  block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
1163
959
  block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
1164
- block.def = edit(block.def)
1165
- .replace('label', block._label)
1166
- .replace('title', block._title)
1167
- .getRegex();
1168
-
960
+ block.def = edit(block.def).replace("label", block._label).replace("title", block._title).getRegex();
1169
961
  block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
1170
- block.listItemStart = edit(/^( *)(bull) */)
1171
- .replace('bull', block.bullet)
1172
- .getRegex();
1173
-
1174
- block.list = edit(block.list)
1175
- .replace(/bull/g, block.bullet)
1176
- .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
1177
- .replace('def', '\\n+(?=' + block.def.source + ')')
1178
- .getRegex();
1179
-
1180
- block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
1181
- + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
1182
- + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
1183
- + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
1184
- + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
1185
- + '|track|ul';
962
+ block.listItemStart = edit(/^( *)(bull) */).replace("bull", block.bullet).getRegex();
963
+ block.list = edit(block.list).replace(/bull/g, block.bullet).replace("hr", "\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def", "\\n+(?=" + block.def.source + ")").getRegex();
964
+ block._tag = "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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
1186
965
  block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
1187
- block.html = edit(block.html, 'i')
1188
- .replace('comment', block._comment)
1189
- .replace('tag', block._tag)
1190
- .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
1191
- .getRegex();
1192
-
1193
- block.lheading = edit(block.lheading)
1194
- .replace(/bull/g, block.bullet) // lists can interrupt
1195
- .getRegex();
1196
-
1197
- block.paragraph = edit(block._paragraph)
1198
- .replace('hr', block.hr)
1199
- .replace('heading', ' {0,3}#{1,6} ')
1200
- .replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
1201
- .replace('|table', '')
1202
- .replace('blockquote', ' {0,3}>')
1203
- .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
1204
- .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1205
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1206
- .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
1207
- .getRegex();
1208
-
1209
- block.blockquote = edit(block.blockquote)
1210
- .replace('paragraph', block.paragraph)
1211
- .getRegex();
1212
-
1213
- /**
1214
- * Normal Block Grammar
1215
- */
1216
-
966
+ block.html = edit(block.html, "i").replace("comment", block._comment).replace("tag", block._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
967
+ block.lheading = edit(block.lheading).replace(/bull/g, block.bullet).getRegex();
968
+ block.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
969
+ block.blockquote = edit(block.blockquote).replace("paragraph", block.paragraph).getRegex();
1217
970
  block.normal = { ...block };
1218
-
1219
- /**
1220
- * GFM Block Grammar
1221
- */
1222
-
1223
971
  block.gfm = {
1224
972
  ...block.normal,
1225
- table: '^ *([^\\n ].*\\|.*)\\n' // Header
1226
- + ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
1227
- + '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
973
+ table: "^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
974
+ // Cells
1228
975
  };
1229
-
1230
- block.gfm.table = edit(block.gfm.table)
1231
- .replace('hr', block.hr)
1232
- .replace('heading', ' {0,3}#{1,6} ')
1233
- .replace('blockquote', ' {0,3}>')
1234
- .replace('code', ' {4}[^\\n]')
1235
- .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
1236
- .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1237
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1238
- .replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
1239
- .getRegex();
1240
-
1241
- block.gfm.paragraph = edit(block._paragraph)
1242
- .replace('hr', block.hr)
1243
- .replace('heading', ' {0,3}#{1,6} ')
1244
- .replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
1245
- .replace('table', block.gfm.table) // interrupt paragraphs with table
1246
- .replace('blockquote', ' {0,3}>')
1247
- .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
1248
- .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1249
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1250
- .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
1251
- .getRegex();
1252
- /**
1253
- * Pedantic grammar (original John Gruber's loose markdown specification)
1254
- */
1255
-
976
+ block.gfm.table = edit(block.gfm.table).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
977
+ block.gfm.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("table", block.gfm.table).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
1256
978
  block.pedantic = {
1257
979
  ...block.normal,
1258
980
  html: edit(
1259
- '^ *(?:comment *(?:\\n|\\s*$)'
1260
- + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
1261
- + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
1262
- .replace('comment', block._comment)
1263
- .replace(/tag/g, '(?!(?:'
1264
- + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
1265
- + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
1266
- + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
1267
- .getRegex(),
981
+ `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
982
+ ).replace("comment", block._comment).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(),
1268
983
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
1269
984
  heading: /^(#{1,6})(.*)(?:\n+|$)/,
1270
- fences: noopTest, // fences not supported
985
+ fences: noopTest,
986
+ // fences not supported
1271
987
  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1272
- paragraph: edit(block.normal._paragraph)
1273
- .replace('hr', block.hr)
1274
- .replace('heading', ' *#{1,6} *[^\n]')
1275
- .replace('lheading', block.lheading)
1276
- .replace('blockquote', ' {0,3}>')
1277
- .replace('|fences', '')
1278
- .replace('|list', '')
1279
- .replace('|html', '')
1280
- .getRegex()
988
+ paragraph: edit(block.normal._paragraph).replace("hr", block.hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", block.lheading).replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").getRegex()
1281
989
  };
1282
-
1283
- /**
1284
- * Inline-Level Grammar
1285
- */
1286
- const inline = {
990
+ var inline = {
1287
991
  escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
1288
992
  autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
1289
993
  url: noopTest,
1290
- tag: '^comment'
1291
- + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
1292
- + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
1293
- + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
1294
- + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
1295
- + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
994
+ tag: "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
995
+ // CDATA section
1296
996
  link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
1297
997
  reflink: /^!?\[(label)\]\[(ref)\]/,
1298
998
  nolink: /^!?\[(ref)\](?:\[\])?/,
1299
- reflinkSearch: 'reflink|nolink(?!\\()',
999
+ reflinkSearch: "reflink|nolink(?!\\()",
1300
1000
  emStrong: {
1301
1001
  lDelim: /^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,
1302
1002
  // (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
1303
1003
  // | Skip orphan inside strong | Consume to delim | (1) #*** | (2) a***#, a*** | (3) #***a, ***a | (4) ***# | (5) #***# | (6) a***a
1304
1004
  rDelimAst: /^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,
1305
- rDelimUnd: /^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/ // ^- Not allowed for _
1005
+ rDelimUnd: /^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/
1006
+ // ^- Not allowed for _
1306
1007
  },
1307
1008
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
1308
1009
  br: /^( {2,}|\\)\n(?!\s*$)/,
@@ -1310,86 +1011,30 @@ const inline = {
1310
1011
  text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
1311
1012
  punctuation: /^((?![*_])[\spunctuation])/
1312
1013
  };
1313
-
1314
- // list of unicode punctuation marks, plus any missing characters from CommonMark spec
1315
- inline._punctuation = '\\p{P}$+<=>`^|~';
1316
- inline.punctuation = edit(inline.punctuation, 'u').replace(/punctuation/g, inline._punctuation).getRegex();
1317
-
1318
- // sequences em should skip over [title](link), `code`, <html>
1014
+ inline._punctuation = "\\p{P}$+<=>`^|~";
1015
+ inline.punctuation = edit(inline.punctuation, "u").replace(/punctuation/g, inline._punctuation).getRegex();
1319
1016
  inline.blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
1320
1017
  inline.anyPunctuation = /\\[punct]/g;
1321
1018
  inline._escapes = /\\([punct])/g;
1322
-
1323
- inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex();
1324
-
1325
- inline.emStrong.lDelim = edit(inline.emStrong.lDelim, 'u')
1326
- .replace(/punct/g, inline._punctuation)
1327
- .getRegex();
1328
-
1329
- inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, 'gu')
1330
- .replace(/punct/g, inline._punctuation)
1331
- .getRegex();
1332
-
1333
- inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, 'gu')
1334
- .replace(/punct/g, inline._punctuation)
1335
- .getRegex();
1336
-
1337
- inline.anyPunctuation = edit(inline.anyPunctuation, 'gu')
1338
- .replace(/punct/g, inline._punctuation)
1339
- .getRegex();
1340
-
1341
- inline._escapes = edit(inline._escapes, 'gu')
1342
- .replace(/punct/g, inline._punctuation)
1343
- .getRegex();
1344
-
1019
+ inline._comment = edit(block._comment).replace("(?:-->|$)", "-->").getRegex();
1020
+ inline.emStrong.lDelim = edit(inline.emStrong.lDelim, "u").replace(/punct/g, inline._punctuation).getRegex();
1021
+ inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, "gu").replace(/punct/g, inline._punctuation).getRegex();
1022
+ inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, "gu").replace(/punct/g, inline._punctuation).getRegex();
1023
+ inline.anyPunctuation = edit(inline.anyPunctuation, "gu").replace(/punct/g, inline._punctuation).getRegex();
1024
+ inline._escapes = edit(inline._escapes, "gu").replace(/punct/g, inline._punctuation).getRegex();
1345
1025
  inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
1346
1026
  inline._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])?)+(?![-_])/;
1347
- inline.autolink = edit(inline.autolink)
1348
- .replace('scheme', inline._scheme)
1349
- .replace('email', inline._email)
1350
- .getRegex();
1351
-
1027
+ inline.autolink = edit(inline.autolink).replace("scheme", inline._scheme).replace("email", inline._email).getRegex();
1352
1028
  inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
1353
-
1354
- inline.tag = edit(inline.tag)
1355
- .replace('comment', inline._comment)
1356
- .replace('attribute', inline._attribute)
1357
- .getRegex();
1358
-
1029
+ inline.tag = edit(inline.tag).replace("comment", inline._comment).replace("attribute", inline._attribute).getRegex();
1359
1030
  inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
1360
1031
  inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
1361
1032
  inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
1362
-
1363
- inline.link = edit(inline.link)
1364
- .replace('label', inline._label)
1365
- .replace('href', inline._href)
1366
- .replace('title', inline._title)
1367
- .getRegex();
1368
-
1369
- inline.reflink = edit(inline.reflink)
1370
- .replace('label', inline._label)
1371
- .replace('ref', block._label)
1372
- .getRegex();
1373
-
1374
- inline.nolink = edit(inline.nolink)
1375
- .replace('ref', block._label)
1376
- .getRegex();
1377
-
1378
- inline.reflinkSearch = edit(inline.reflinkSearch, 'g')
1379
- .replace('reflink', inline.reflink)
1380
- .replace('nolink', inline.nolink)
1381
- .getRegex();
1382
-
1383
- /**
1384
- * Normal Inline Grammar
1385
- */
1386
-
1033
+ inline.link = edit(inline.link).replace("label", inline._label).replace("href", inline._href).replace("title", inline._title).getRegex();
1034
+ inline.reflink = edit(inline.reflink).replace("label", inline._label).replace("ref", block._label).getRegex();
1035
+ inline.nolink = edit(inline.nolink).replace("ref", block._label).getRegex();
1036
+ inline.reflinkSearch = edit(inline.reflinkSearch, "g").replace("reflink", inline.reflink).replace("nolink", inline.nolink).getRegex();
1387
1037
  inline.normal = { ...inline };
1388
-
1389
- /**
1390
- * Pedantic Inline Grammar
1391
- */
1392
-
1393
1038
  inline.pedantic = {
1394
1039
  ...inline.normal,
1395
1040
  strong: {
@@ -1404,96 +1049,47 @@ inline.pedantic = {
1404
1049
  endAst: /\*(?!\*)/g,
1405
1050
  endUnd: /_(?!_)/g
1406
1051
  },
1407
- link: edit(/^!?\[(label)\]\((.*?)\)/)
1408
- .replace('label', inline._label)
1409
- .getRegex(),
1410
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
1411
- .replace('label', inline._label)
1412
- .getRegex()
1052
+ link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", inline._label).getRegex(),
1053
+ reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", inline._label).getRegex()
1413
1054
  };
1414
-
1415
- /**
1416
- * GFM Inline Grammar
1417
- */
1418
-
1419
1055
  inline.gfm = {
1420
1056
  ...inline.normal,
1421
- escape: edit(inline.escape).replace('])', '~|])').getRegex(),
1057
+ escape: edit(inline.escape).replace("])", "~|])").getRegex(),
1422
1058
  _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
1423
1059
  url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
1424
1060
  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
1425
1061
  del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
1426
1062
  text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
1427
1063
  };
1428
-
1429
- inline.gfm.url = edit(inline.gfm.url, 'i')
1430
- .replace('email', inline.gfm._extended_email)
1431
- .getRegex();
1432
- /**
1433
- * GFM + Line Breaks Inline Grammar
1434
- */
1435
-
1064
+ inline.gfm.url = edit(inline.gfm.url, "i").replace("email", inline.gfm._extended_email).getRegex();
1436
1065
  inline.breaks = {
1437
1066
  ...inline.gfm,
1438
- br: edit(inline.br).replace('{2,}', '*').getRegex(),
1439
- text: edit(inline.gfm.text)
1440
- .replace('\\b_', '\\b_| {2,}\\n')
1441
- .replace(/\{2,\}/g, '*')
1442
- .getRegex()
1067
+ br: edit(inline.br).replace("{2,}", "*").getRegex(),
1068
+ text: edit(inline.gfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
1443
1069
  };
1444
1070
 
1445
- /**
1446
- * smartypants text replacement
1447
- * @param {string} text
1448
- */
1071
+ // src/Lexer.ts
1449
1072
  function smartypants(text) {
1450
- return text
1451
- // em-dashes
1452
- .replace(/---/g, '\u2014')
1453
- // en-dashes
1454
- .replace(/--/g, '\u2013')
1455
- // opening singles
1456
- .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
1457
- // closing singles & apostrophes
1458
- .replace(/'/g, '\u2019')
1459
- // opening doubles
1460
- .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
1461
- // closing doubles
1462
- .replace(/"/g, '\u201d')
1463
- // ellipses
1464
- .replace(/\.{3}/g, '\u2026');
1073
+ return text.replace(/---/g, "\u2014").replace(/--/g, "\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018").replace(/'/g, "\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C").replace(/"/g, "\u201D").replace(/\.{3}/g, "\u2026");
1465
1074
  }
1466
-
1467
- /**
1468
- * mangle email addresses
1469
- * @param {string} text
1470
- */
1471
1075
  function mangle(text) {
1472
- let out = '',
1473
- i,
1474
- ch;
1475
-
1076
+ let out = "", i, ch;
1476
1077
  const l = text.length;
1477
1078
  for (i = 0; i < l; i++) {
1478
1079
  ch = text.charCodeAt(i);
1479
1080
  if (Math.random() > 0.5) {
1480
- ch = 'x' + ch.toString(16);
1081
+ ch = "x" + ch.toString(16);
1481
1082
  }
1482
- out += '&#' + ch + ';';
1083
+ out += "&#" + ch + ";";
1483
1084
  }
1484
-
1485
1085
  return out;
1486
1086
  }
1487
-
1488
- /**
1489
- * Block Lexer
1490
- */
1491
- class Lexer {
1492
- constructor(options) {
1087
+ var _Lexer = class {
1088
+ constructor(options2) {
1493
1089
  this.tokens = [];
1494
- this.tokens.links = Object.create(null);
1495
- this.options = options || defaults;
1496
- this.options.tokenizer = this.options.tokenizer || new Tokenizer();
1090
+ this.tokens.links = /* @__PURE__ */ Object.create(null);
1091
+ this.options = options2 || _defaults;
1092
+ this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
1497
1093
  this.tokenizer = this.options.tokenizer;
1498
1094
  this.tokenizer.options = this.options;
1499
1095
  this.tokenizer.lexer = this;
@@ -1503,12 +1099,10 @@ class Lexer {
1503
1099
  inRawBlock: false,
1504
1100
  top: true
1505
1101
  };
1506
-
1507
1102
  const rules = {
1508
1103
  block: block.normal,
1509
1104
  inline: inline.normal
1510
1105
  };
1511
-
1512
1106
  if (this.options.pedantic) {
1513
1107
  rules.block = block.pedantic;
1514
1108
  rules.inline = inline.pedantic;
@@ -1522,7 +1116,6 @@ class Lexer {
1522
1116
  }
1523
1117
  this.tokenizer.rules = rules;
1524
1118
  }
1525
-
1526
1119
  /**
1527
1120
  * Expose Rules
1528
1121
  */
@@ -1532,145 +1125,109 @@ class Lexer {
1532
1125
  inline
1533
1126
  };
1534
1127
  }
1535
-
1536
1128
  /**
1537
1129
  * Static Lex Method
1538
1130
  */
1539
- static lex(src, options) {
1540
- const lexer = new Lexer(options);
1541
- return lexer.lex(src);
1131
+ static lex(src, options2) {
1132
+ const lexer2 = new _Lexer(options2);
1133
+ return lexer2.lex(src);
1542
1134
  }
1543
-
1544
1135
  /**
1545
1136
  * Static Lex Inline Method
1546
1137
  */
1547
- static lexInline(src, options) {
1548
- const lexer = new Lexer(options);
1549
- return lexer.inlineTokens(src);
1138
+ static lexInline(src, options2) {
1139
+ const lexer2 = new _Lexer(options2);
1140
+ return lexer2.inlineTokens(src);
1550
1141
  }
1551
-
1552
1142
  /**
1553
1143
  * Preprocessing
1554
1144
  */
1555
1145
  lex(src) {
1556
- src = src
1557
- .replace(/\r\n|\r/g, '\n');
1558
-
1146
+ src = src.replace(/\r\n|\r/g, "\n");
1559
1147
  this.blockTokens(src, this.tokens);
1560
-
1561
1148
  let next;
1562
1149
  while (next = this.inlineQueue.shift()) {
1563
1150
  this.inlineTokens(next.src, next.tokens);
1564
1151
  }
1565
-
1566
1152
  return this.tokens;
1567
1153
  }
1568
-
1569
- /**
1570
- * Lexing
1571
- */
1572
1154
  blockTokens(src, tokens = []) {
1573
1155
  if (this.options.pedantic) {
1574
- src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
1156
+ src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
1575
1157
  } else {
1576
1158
  src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
1577
- return leading + ' '.repeat(tabs.length);
1159
+ return leading + " ".repeat(tabs.length);
1578
1160
  });
1579
1161
  }
1580
-
1581
1162
  let token, lastToken, cutSrc, lastParagraphClipped;
1582
-
1583
1163
  while (src) {
1584
- if (this.options.extensions
1585
- && this.options.extensions.block
1586
- && this.options.extensions.block.some((extTokenizer) => {
1587
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1588
- src = src.substring(token.raw.length);
1589
- tokens.push(token);
1590
- return true;
1591
- }
1592
- return false;
1593
- })) {
1164
+ if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
1165
+ if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1166
+ src = src.substring(token.raw.length);
1167
+ tokens.push(token);
1168
+ return true;
1169
+ }
1170
+ return false;
1171
+ })) {
1594
1172
  continue;
1595
1173
  }
1596
-
1597
- // newline
1598
1174
  if (token = this.tokenizer.space(src)) {
1599
1175
  src = src.substring(token.raw.length);
1600
1176
  if (token.raw.length === 1 && tokens.length > 0) {
1601
- // if there's a single \n as a spacer, it's terminating the last line,
1602
- // so move it there so that we don't get unecessary paragraph tags
1603
- tokens[tokens.length - 1].raw += '\n';
1177
+ tokens[tokens.length - 1].raw += "\n";
1604
1178
  } else {
1605
1179
  tokens.push(token);
1606
1180
  }
1607
1181
  continue;
1608
1182
  }
1609
-
1610
- // code
1611
1183
  if (token = this.tokenizer.code(src)) {
1612
1184
  src = src.substring(token.raw.length);
1613
1185
  lastToken = tokens[tokens.length - 1];
1614
- // An indented code block cannot interrupt a paragraph.
1615
- if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
1616
- lastToken.raw += '\n' + token.raw;
1617
- lastToken.text += '\n' + token.text;
1186
+ if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
1187
+ lastToken.raw += "\n" + token.raw;
1188
+ lastToken.text += "\n" + token.text;
1618
1189
  this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1619
1190
  } else {
1620
1191
  tokens.push(token);
1621
1192
  }
1622
1193
  continue;
1623
1194
  }
1624
-
1625
- // fences
1626
1195
  if (token = this.tokenizer.fences(src)) {
1627
1196
  src = src.substring(token.raw.length);
1628
1197
  tokens.push(token);
1629
1198
  continue;
1630
1199
  }
1631
-
1632
- // heading
1633
1200
  if (token = this.tokenizer.heading(src)) {
1634
1201
  src = src.substring(token.raw.length);
1635
1202
  tokens.push(token);
1636
1203
  continue;
1637
1204
  }
1638
-
1639
- // hr
1640
1205
  if (token = this.tokenizer.hr(src)) {
1641
1206
  src = src.substring(token.raw.length);
1642
1207
  tokens.push(token);
1643
1208
  continue;
1644
1209
  }
1645
-
1646
- // blockquote
1647
1210
  if (token = this.tokenizer.blockquote(src)) {
1648
1211
  src = src.substring(token.raw.length);
1649
1212
  tokens.push(token);
1650
1213
  continue;
1651
1214
  }
1652
-
1653
- // list
1654
1215
  if (token = this.tokenizer.list(src)) {
1655
1216
  src = src.substring(token.raw.length);
1656
1217
  tokens.push(token);
1657
1218
  continue;
1658
1219
  }
1659
-
1660
- // html
1661
1220
  if (token = this.tokenizer.html(src)) {
1662
1221
  src = src.substring(token.raw.length);
1663
1222
  tokens.push(token);
1664
1223
  continue;
1665
1224
  }
1666
-
1667
- // def
1668
1225
  if (token = this.tokenizer.def(src)) {
1669
1226
  src = src.substring(token.raw.length);
1670
1227
  lastToken = tokens[tokens.length - 1];
1671
- if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
1672
- lastToken.raw += '\n' + token.raw;
1673
- lastToken.text += '\n' + token.raw;
1228
+ if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
1229
+ lastToken.raw += "\n" + token.raw;
1230
+ lastToken.text += "\n" + token.raw;
1674
1231
  this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1675
1232
  } else if (!this.tokens.links[token.tag]) {
1676
1233
  this.tokens.links[token.tag] = {
@@ -1680,31 +1237,26 @@ class Lexer {
1680
1237
  }
1681
1238
  continue;
1682
1239
  }
1683
-
1684
- // table (gfm)
1685
1240
  if (token = this.tokenizer.table(src)) {
1686
1241
  src = src.substring(token.raw.length);
1687
1242
  tokens.push(token);
1688
1243
  continue;
1689
1244
  }
1690
-
1691
- // lheading
1692
1245
  if (token = this.tokenizer.lheading(src)) {
1693
1246
  src = src.substring(token.raw.length);
1694
1247
  tokens.push(token);
1695
1248
  continue;
1696
1249
  }
1697
-
1698
- // top-level paragraph
1699
- // prevent paragraph consuming extensions by clipping 'src' to extension start
1700
1250
  cutSrc = src;
1701
1251
  if (this.options.extensions && this.options.extensions.startBlock) {
1702
1252
  let startIndex = Infinity;
1703
1253
  const tempSrc = src.slice(1);
1704
1254
  let tempStart;
1705
- this.options.extensions.startBlock.forEach(function(getStartIndex) {
1255
+ this.options.extensions.startBlock.forEach((getStartIndex) => {
1706
1256
  tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1707
- if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
1257
+ if (typeof tempStart === "number" && tempStart >= 0) {
1258
+ startIndex = Math.min(startIndex, tempStart);
1259
+ }
1708
1260
  });
1709
1261
  if (startIndex < Infinity && startIndex >= 0) {
1710
1262
  cutSrc = src.substring(0, startIndex + 1);
@@ -1712,26 +1264,24 @@ class Lexer {
1712
1264
  }
1713
1265
  if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
1714
1266
  lastToken = tokens[tokens.length - 1];
1715
- if (lastParagraphClipped && lastToken.type === 'paragraph') {
1716
- lastToken.raw += '\n' + token.raw;
1717
- lastToken.text += '\n' + token.text;
1267
+ if (lastParagraphClipped && lastToken.type === "paragraph") {
1268
+ lastToken.raw += "\n" + token.raw;
1269
+ lastToken.text += "\n" + token.text;
1718
1270
  this.inlineQueue.pop();
1719
1271
  this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1720
1272
  } else {
1721
1273
  tokens.push(token);
1722
1274
  }
1723
- lastParagraphClipped = (cutSrc.length !== src.length);
1275
+ lastParagraphClipped = cutSrc.length !== src.length;
1724
1276
  src = src.substring(token.raw.length);
1725
1277
  continue;
1726
1278
  }
1727
-
1728
- // text
1729
1279
  if (token = this.tokenizer.text(src)) {
1730
1280
  src = src.substring(token.raw.length);
1731
1281
  lastToken = tokens[tokens.length - 1];
1732
- if (lastToken && lastToken.type === 'text') {
1733
- lastToken.raw += '\n' + token.raw;
1734
- lastToken.text += '\n' + token.text;
1282
+ if (lastToken && lastToken.type === "text") {
1283
+ lastToken.raw += "\n" + token.raw;
1284
+ lastToken.text += "\n" + token.text;
1735
1285
  this.inlineQueue.pop();
1736
1286
  this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1737
1287
  } else {
@@ -1739,9 +1289,8 @@ class Lexer {
1739
1289
  }
1740
1290
  continue;
1741
1291
  }
1742
-
1743
1292
  if (src) {
1744
- const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
1293
+ const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1745
1294
  if (this.options.silent) {
1746
1295
  console.error(errMsg);
1747
1296
  break;
@@ -1750,80 +1299,61 @@ class Lexer {
1750
1299
  }
1751
1300
  }
1752
1301
  }
1753
-
1754
1302
  this.state.top = true;
1755
1303
  return tokens;
1756
1304
  }
1757
-
1758
1305
  inline(src, tokens = []) {
1759
1306
  this.inlineQueue.push({ src, tokens });
1760
1307
  return tokens;
1761
1308
  }
1762
-
1763
1309
  /**
1764
1310
  * Lexing/Compiling
1765
1311
  */
1766
1312
  inlineTokens(src, tokens = []) {
1767
1313
  let token, lastToken, cutSrc;
1768
-
1769
- // String with links masked to avoid interference with em and strong
1770
1314
  let maskedSrc = src;
1771
1315
  let match;
1772
1316
  let keepPrevChar, prevChar;
1773
-
1774
- // Mask out reflinks
1775
1317
  if (this.tokens.links) {
1776
1318
  const links = Object.keys(this.tokens.links);
1777
1319
  if (links.length > 0) {
1778
1320
  while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1779
- if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
1780
- maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1321
+ if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
1322
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1781
1323
  }
1782
1324
  }
1783
1325
  }
1784
1326
  }
1785
- // Mask out other blocks
1786
1327
  while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1787
- maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1328
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1788
1329
  }
1789
-
1790
- // Mask out escaped characters
1791
1330
  while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
1792
- maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1331
+ maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1793
1332
  }
1794
-
1795
1333
  while (src) {
1796
1334
  if (!keepPrevChar) {
1797
- prevChar = '';
1335
+ prevChar = "";
1798
1336
  }
1799
1337
  keepPrevChar = false;
1800
-
1801
- // extensions
1802
- if (this.options.extensions
1803
- && this.options.extensions.inline
1804
- && this.options.extensions.inline.some((extTokenizer) => {
1805
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1806
- src = src.substring(token.raw.length);
1807
- tokens.push(token);
1808
- return true;
1809
- }
1810
- return false;
1811
- })) {
1338
+ if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
1339
+ if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1340
+ src = src.substring(token.raw.length);
1341
+ tokens.push(token);
1342
+ return true;
1343
+ }
1344
+ return false;
1345
+ })) {
1812
1346
  continue;
1813
1347
  }
1814
-
1815
- // escape
1816
1348
  if (token = this.tokenizer.escape(src)) {
1817
1349
  src = src.substring(token.raw.length);
1818
1350
  tokens.push(token);
1819
1351
  continue;
1820
1352
  }
1821
-
1822
- // tag
1823
1353
  if (token = this.tokenizer.tag(src)) {
1824
1354
  src = src.substring(token.raw.length);
1825
1355
  lastToken = tokens[tokens.length - 1];
1826
- if (lastToken && token.type === 'text' && lastToken.type === 'text') {
1356
+ if (lastToken && token.type === "text" && lastToken.type === "text") {
1827
1357
  lastToken.raw += token.raw;
1828
1358
  lastToken.text += token.text;
1829
1359
  } else {
@@ -1831,19 +1361,15 @@ class Lexer {
1831
1361
  }
1832
1362
  continue;
1833
1363
  }
1834
-
1835
- // link
1836
1364
  if (token = this.tokenizer.link(src)) {
1837
1365
  src = src.substring(token.raw.length);
1838
1366
  tokens.push(token);
1839
1367
  continue;
1840
1368
  }
1841
-
1842
- // reflink, nolink
1843
1369
  if (token = this.tokenizer.reflink(src, this.tokens.links)) {
1844
1370
  src = src.substring(token.raw.length);
1845
1371
  lastToken = tokens[tokens.length - 1];
1846
- if (lastToken && token.type === 'text' && lastToken.type === 'text') {
1372
+ if (lastToken && token.type === "text" && lastToken.type === "text") {
1847
1373
  lastToken.raw += token.raw;
1848
1374
  lastToken.text += token.text;
1849
1375
  } else {
@@ -1851,59 +1377,46 @@ class Lexer {
1851
1377
  }
1852
1378
  continue;
1853
1379
  }
1854
-
1855
- // em & strong
1856
1380
  if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
1857
1381
  src = src.substring(token.raw.length);
1858
1382
  tokens.push(token);
1859
1383
  continue;
1860
1384
  }
1861
-
1862
- // code
1863
1385
  if (token = this.tokenizer.codespan(src)) {
1864
1386
  src = src.substring(token.raw.length);
1865
1387
  tokens.push(token);
1866
1388
  continue;
1867
1389
  }
1868
-
1869
- // br
1870
1390
  if (token = this.tokenizer.br(src)) {
1871
1391
  src = src.substring(token.raw.length);
1872
1392
  tokens.push(token);
1873
1393
  continue;
1874
1394
  }
1875
-
1876
- // del (gfm)
1877
1395
  if (token = this.tokenizer.del(src)) {
1878
1396
  src = src.substring(token.raw.length);
1879
1397
  tokens.push(token);
1880
1398
  continue;
1881
1399
  }
1882
-
1883
- // autolink
1884
1400
  if (token = this.tokenizer.autolink(src, mangle)) {
1885
1401
  src = src.substring(token.raw.length);
1886
1402
  tokens.push(token);
1887
1403
  continue;
1888
1404
  }
1889
-
1890
- // url (gfm)
1891
1405
  if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
1892
1406
  src = src.substring(token.raw.length);
1893
1407
  tokens.push(token);
1894
1408
  continue;
1895
1409
  }
1896
-
1897
- // text
1898
- // prevent inlineText consuming extensions by clipping 'src' to extension start
1899
1410
  cutSrc = src;
1900
1411
  if (this.options.extensions && this.options.extensions.startInline) {
1901
1412
  let startIndex = Infinity;
1902
1413
  const tempSrc = src.slice(1);
1903
1414
  let tempStart;
1904
- this.options.extensions.startInline.forEach(function(getStartIndex) {
1415
+ this.options.extensions.startInline.forEach((getStartIndex) => {
1905
1416
  tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1906
- if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
1417
+ if (typeof tempStart === "number" && tempStart >= 0) {
1418
+ startIndex = Math.min(startIndex, tempStart);
1419
+ }
1907
1420
  });
1908
1421
  if (startIndex < Infinity && startIndex >= 0) {
1909
1422
  cutSrc = src.substring(0, startIndex + 1);
@@ -1911,12 +1424,12 @@ class Lexer {
1911
1424
  }
1912
1425
  if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
1913
1426
  src = src.substring(token.raw.length);
1914
- if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started
1427
+ if (token.raw.slice(-1) !== "_") {
1915
1428
  prevChar = token.raw.slice(-1);
1916
1429
  }
1917
1430
  keepPrevChar = true;
1918
1431
  lastToken = tokens[tokens.length - 1];
1919
- if (lastToken && lastToken.type === 'text') {
1432
+ if (lastToken && lastToken.type === "text") {
1920
1433
  lastToken.raw += token.raw;
1921
1434
  lastToken.text += token.text;
1922
1435
  } else {
@@ -1924,9 +1437,8 @@ class Lexer {
1924
1437
  }
1925
1438
  continue;
1926
1439
  }
1927
-
1928
1440
  if (src) {
1929
- const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
1441
+ const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1930
1442
  if (this.options.silent) {
1931
1443
  console.error(errMsg);
1932
1444
  break;
@@ -1935,21 +1447,17 @@ class Lexer {
1935
1447
  }
1936
1448
  }
1937
1449
  }
1938
-
1939
1450
  return tokens;
1940
1451
  }
1941
- }
1452
+ };
1942
1453
 
1943
- /**
1944
- * Renderer
1945
- */
1946
- class Renderer {
1947
- constructor(options) {
1948
- this.options = options || defaults;
1454
+ // src/Renderer.ts
1455
+ var _Renderer = class {
1456
+ constructor(options2) {
1457
+ this.options = options2 || _defaults;
1949
1458
  }
1950
-
1951
1459
  code(code, infostring, escaped) {
1952
- const lang = (infostring || '').match(/\S*/)[0];
1460
+ const lang = (infostring || "").match(/\S*/)[0];
1953
1461
  if (this.options.highlight) {
1954
1462
  const out = this.options.highlight(code, lang);
1955
1463
  if (out != null && out !== code) {
@@ -1957,150 +1465,81 @@ class Renderer {
1957
1465
  code = out;
1958
1466
  }
1959
1467
  }
1960
-
1961
- code = code.replace(/\n$/, '') + '\n';
1962
-
1468
+ code = code.replace(/\n$/, "") + "\n";
1963
1469
  if (!lang) {
1964
- return '<pre><code>'
1965
- + (escaped ? code : escape(code, true))
1966
- + '</code></pre>\n';
1470
+ return "<pre><code>" + (escaped ? code : escape(code, true)) + "</code></pre>\n";
1967
1471
  }
1968
-
1969
- return '<pre><code class="'
1970
- + this.options.langPrefix
1971
- + escape(lang)
1972
- + '">'
1973
- + (escaped ? code : escape(code, true))
1974
- + '</code></pre>\n';
1472
+ return '<pre><code class="' + this.options.langPrefix + escape(lang) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
1975
1473
  }
1976
-
1977
- /**
1978
- * @param {string} quote
1979
- */
1980
1474
  blockquote(quote) {
1981
- return `<blockquote>\n${quote}</blockquote>\n`;
1475
+ return `<blockquote>
1476
+ ${quote}</blockquote>
1477
+ `;
1982
1478
  }
1983
-
1984
- html(html, block) {
1479
+ html(html, block2) {
1985
1480
  return html;
1986
1481
  }
1987
-
1988
- /**
1989
- * @param {string} text
1990
- * @param {string} level
1991
- * @param {string} raw
1992
- * @param {any} slugger
1993
- */
1994
1482
  heading(text, level, raw, slugger) {
1995
1483
  if (this.options.headerIds) {
1996
1484
  const id = this.options.headerPrefix + slugger.slug(raw);
1997
- return `<h${level} id="${id}">${text}</h${level}>\n`;
1485
+ return `<h${level} id="${id}">${text}</h${level}>
1486
+ `;
1998
1487
  }
1999
-
2000
- // ignore IDs
2001
- return `<h${level}>${text}</h${level}>\n`;
1488
+ return `<h${level}>${text}</h${level}>
1489
+ `;
2002
1490
  }
2003
-
2004
1491
  hr() {
2005
- return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
1492
+ return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
2006
1493
  }
2007
-
2008
1494
  list(body, ordered, start) {
2009
- const type = ordered ? 'ol' : 'ul',
2010
- startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
2011
- return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
1495
+ const type = ordered ? "ol" : "ul", startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
1496
+ return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
2012
1497
  }
2013
-
2014
- /**
2015
- * @param {string} text
2016
- */
2017
- listitem(text) {
2018
- return `<li>${text}</li>\n`;
1498
+ listitem(text, task, checked) {
1499
+ return `<li>${text}</li>
1500
+ `;
2019
1501
  }
2020
-
2021
1502
  checkbox(checked) {
2022
- return '<input '
2023
- + (checked ? 'checked="" ' : '')
2024
- + 'disabled="" type="checkbox"'
2025
- + (this.options.xhtml ? ' /' : '')
2026
- + '> ';
1503
+ return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
2027
1504
  }
2028
-
2029
- /**
2030
- * @param {string} text
2031
- */
2032
1505
  paragraph(text) {
2033
- return `<p>${text}</p>\n`;
1506
+ return `<p>${text}</p>
1507
+ `;
2034
1508
  }
2035
-
2036
- /**
2037
- * @param {string} header
2038
- * @param {string} body
2039
- */
2040
1509
  table(header, body) {
2041
- if (body) body = `<tbody>${body}</tbody>`;
2042
-
2043
- return '<table>\n'
2044
- + '<thead>\n'
2045
- + header
2046
- + '</thead>\n'
2047
- + body
2048
- + '</table>\n';
1510
+ if (body)
1511
+ body = `<tbody>${body}</tbody>`;
1512
+ return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
2049
1513
  }
2050
-
2051
- /**
2052
- * @param {string} content
2053
- */
2054
1514
  tablerow(content) {
2055
- return `<tr>\n${content}</tr>\n`;
1515
+ return `<tr>
1516
+ ${content}</tr>
1517
+ `;
2056
1518
  }
2057
-
2058
1519
  tablecell(content, flags) {
2059
- const type = flags.header ? 'th' : 'td';
2060
- const tag = flags.align
2061
- ? `<${type} align="${flags.align}">`
2062
- : `<${type}>`;
2063
- return tag + content + `</${type}>\n`;
1520
+ const type = flags.header ? "th" : "td";
1521
+ const tag = flags.align ? `<${type} align="${flags.align}">` : `<${type}>`;
1522
+ return tag + content + `</${type}>
1523
+ `;
2064
1524
  }
2065
-
2066
1525
  /**
2067
1526
  * span level renderer
2068
- * @param {string} text
2069
1527
  */
2070
1528
  strong(text) {
2071
1529
  return `<strong>${text}</strong>`;
2072
1530
  }
2073
-
2074
- /**
2075
- * @param {string} text
2076
- */
2077
1531
  em(text) {
2078
1532
  return `<em>${text}</em>`;
2079
1533
  }
2080
-
2081
- /**
2082
- * @param {string} text
2083
- */
2084
1534
  codespan(text) {
2085
1535
  return `<code>${text}</code>`;
2086
1536
  }
2087
-
2088
1537
  br() {
2089
- return this.options.xhtml ? '<br/>' : '<br>';
1538
+ return this.options.xhtml ? "<br/>" : "<br>";
2090
1539
  }
2091
-
2092
- /**
2093
- * @param {string} text
2094
- */
2095
1540
  del(text) {
2096
1541
  return `<del>${text}</del>`;
2097
1542
  }
2098
-
2099
- /**
2100
- * @param {string} href
2101
- * @param {string} title
2102
- * @param {string} text
2103
- */
2104
1543
  link(href, title, text) {
2105
1544
  href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2106
1545
  if (href === null) {
@@ -2110,103 +1549,68 @@ class Renderer {
2110
1549
  if (title) {
2111
1550
  out += ' title="' + title + '"';
2112
1551
  }
2113
- out += '>' + text + '</a>';
1552
+ out += ">" + text + "</a>";
2114
1553
  return out;
2115
1554
  }
2116
-
2117
- /**
2118
- * @param {string} href
2119
- * @param {string} title
2120
- * @param {string} text
2121
- */
2122
1555
  image(href, title, text) {
2123
1556
  href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2124
1557
  if (href === null) {
2125
1558
  return text;
2126
1559
  }
2127
-
2128
1560
  let out = `<img src="${href}" alt="${text}"`;
2129
1561
  if (title) {
2130
1562
  out += ` title="${title}"`;
2131
1563
  }
2132
- out += this.options.xhtml ? '/>' : '>';
1564
+ out += this.options.xhtml ? "/>" : ">";
2133
1565
  return out;
2134
1566
  }
2135
-
2136
1567
  text(text) {
2137
1568
  return text;
2138
1569
  }
2139
- }
1570
+ };
2140
1571
 
2141
- /**
2142
- * TextRenderer
2143
- * returns only the textual part of the token
2144
- */
2145
- class TextRenderer {
1572
+ // src/TextRenderer.ts
1573
+ var _TextRenderer = class {
2146
1574
  // no need for block level renderers
2147
1575
  strong(text) {
2148
1576
  return text;
2149
1577
  }
2150
-
2151
1578
  em(text) {
2152
1579
  return text;
2153
1580
  }
2154
-
2155
1581
  codespan(text) {
2156
1582
  return text;
2157
1583
  }
2158
-
2159
1584
  del(text) {
2160
1585
  return text;
2161
1586
  }
2162
-
2163
1587
  html(text) {
2164
1588
  return text;
2165
1589
  }
2166
-
2167
1590
  text(text) {
2168
1591
  return text;
2169
1592
  }
2170
-
2171
1593
  link(href, title, text) {
2172
- return '' + text;
1594
+ return "" + text;
2173
1595
  }
2174
-
2175
1596
  image(href, title, text) {
2176
- return '' + text;
1597
+ return "" + text;
2177
1598
  }
2178
-
2179
1599
  br() {
2180
- return '';
1600
+ return "";
2181
1601
  }
2182
- }
1602
+ };
2183
1603
 
2184
- /**
2185
- * Slugger generates header id
2186
- */
2187
- class Slugger {
1604
+ // src/Slugger.ts
1605
+ var _Slugger = class {
2188
1606
  constructor() {
2189
1607
  this.seen = {};
2190
1608
  }
2191
-
2192
- /**
2193
- * @param {string} value
2194
- */
2195
1609
  serialize(value) {
2196
- return value
2197
- .toLowerCase()
2198
- .trim()
2199
- // remove html tags
2200
- .replace(/<[!\/a-z].*?>/ig, '')
2201
- // remove unwanted chars
2202
- .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
2203
- .replace(/\s/g, '-');
1610
+ return value.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
2204
1611
  }
2205
-
2206
1612
  /**
2207
1613
  * Finds the next safe (unique) slug to use
2208
- * @param {string} originalSlug
2209
- * @param {boolean} isDryRun
2210
1614
  */
2211
1615
  getNextSafeSlug(originalSlug, isDryRun) {
2212
1616
  let slug = originalSlug;
@@ -2215,7 +1619,7 @@ class Slugger {
2215
1619
  occurenceAccumulator = this.seen[originalSlug];
2216
1620
  do {
2217
1621
  occurenceAccumulator++;
2218
- slug = originalSlug + '-' + occurenceAccumulator;
1622
+ slug = originalSlug + "-" + occurenceAccumulator;
2219
1623
  } while (this.seen.hasOwnProperty(slug));
2220
1624
  }
2221
1625
  if (!isDryRun) {
@@ -2224,113 +1628,82 @@ class Slugger {
2224
1628
  }
2225
1629
  return slug;
2226
1630
  }
2227
-
2228
1631
  /**
2229
1632
  * Convert string to unique id
2230
- * @param {object} [options]
2231
- * @param {boolean} [options.dryrun] Generates the next unique slug without
2232
- * updating the internal accumulator.
2233
1633
  */
2234
- slug(value, options = {}) {
1634
+ slug(value, options2 = {}) {
2235
1635
  const slug = this.serialize(value);
2236
- return this.getNextSafeSlug(slug, options.dryrun);
1636
+ return this.getNextSafeSlug(slug, options2.dryrun);
2237
1637
  }
2238
- }
1638
+ };
2239
1639
 
2240
- /**
2241
- * Parsing & Compiling
2242
- */
2243
- class Parser {
2244
- constructor(options) {
2245
- this.options = options || defaults;
2246
- this.options.renderer = this.options.renderer || new Renderer();
1640
+ // src/Parser.ts
1641
+ var _Parser = class {
1642
+ constructor(options2) {
1643
+ this.options = options2 || _defaults;
1644
+ this.options.renderer = this.options.renderer || new _Renderer();
2247
1645
  this.renderer = this.options.renderer;
2248
1646
  this.renderer.options = this.options;
2249
- this.textRenderer = new TextRenderer();
2250
- this.slugger = new Slugger();
1647
+ this.textRenderer = new _TextRenderer();
1648
+ this.slugger = new _Slugger();
2251
1649
  }
2252
-
2253
1650
  /**
2254
1651
  * Static Parse Method
2255
1652
  */
2256
- static parse(tokens, options) {
2257
- const parser = new Parser(options);
2258
- return parser.parse(tokens);
1653
+ static parse(tokens, options2) {
1654
+ const parser2 = new _Parser(options2);
1655
+ return parser2.parse(tokens);
2259
1656
  }
2260
-
2261
1657
  /**
2262
1658
  * Static Parse Inline Method
2263
1659
  */
2264
- static parseInline(tokens, options) {
2265
- const parser = new Parser(options);
2266
- return parser.parseInline(tokens);
1660
+ static parseInline(tokens, options2) {
1661
+ const parser2 = new _Parser(options2);
1662
+ return parser2.parseInline(tokens);
2267
1663
  }
2268
-
2269
1664
  /**
2270
1665
  * Parse Loop
2271
1666
  */
2272
1667
  parse(tokens, top = true) {
2273
- let out = '',
2274
- i,
2275
- j,
2276
- k,
2277
- l2,
2278
- l3,
2279
- row,
2280
- cell,
2281
- header,
2282
- body,
2283
- token,
2284
- ordered,
2285
- start,
2286
- loose,
2287
- itemBody,
2288
- item,
2289
- checked,
2290
- task,
2291
- checkbox,
2292
- ret;
2293
-
1668
+ let out = "", i, j, k, l2, l3, row, cell, header, body, token, ordered, start, loose, itemBody, item, checked, task, checkbox, ret;
2294
1669
  const l = tokens.length;
2295
1670
  for (i = 0; i < l; i++) {
2296
1671
  token = tokens[i];
2297
-
2298
- // Run any renderer extensions
2299
1672
  if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
2300
1673
  ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
2301
- if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
2302
- out += ret || '';
1674
+ if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(token.type)) {
1675
+ out += ret || "";
2303
1676
  continue;
2304
1677
  }
2305
1678
  }
2306
-
2307
1679
  switch (token.type) {
2308
- case 'space': {
1680
+ case "space": {
2309
1681
  continue;
2310
1682
  }
2311
- case 'hr': {
1683
+ case "hr": {
2312
1684
  out += this.renderer.hr();
2313
1685
  continue;
2314
1686
  }
2315
- case 'heading': {
1687
+ case "heading": {
2316
1688
  out += this.renderer.heading(
2317
1689
  this.parseInline(token.tokens),
2318
1690
  token.depth,
2319
1691
  unescape(this.parseInline(token.tokens, this.textRenderer)),
2320
- this.slugger);
1692
+ this.slugger
1693
+ );
2321
1694
  continue;
2322
1695
  }
2323
- case 'code': {
2324
- out += this.renderer.code(token.text,
1696
+ case "code": {
1697
+ out += this.renderer.code(
1698
+ token.text,
2325
1699
  token.lang,
2326
- token.escaped);
1700
+ !!token.escaped
1701
+ );
2327
1702
  continue;
2328
1703
  }
2329
- case 'table': {
2330
- header = '';
2331
-
2332
- // header
2333
- cell = '';
1704
+ case "table": {
1705
+ header = "";
1706
+ cell = "";
2334
1707
  l2 = token.header.length;
2335
1708
  for (j = 0; j < l2; j++) {
2336
1709
  cell += this.renderer.tablecell(
@@ -2339,13 +1712,11 @@ class Parser {
2339
1712
  );
2340
1713
  }
2341
1714
  header += this.renderer.tablerow(cell);
2342
-
2343
- body = '';
1715
+ body = "";
2344
1716
  l2 = token.rows.length;
2345
1717
  for (j = 0; j < l2; j++) {
2346
1718
  row = token.rows[j];
2347
-
2348
- cell = '';
1719
+ cell = "";
2349
1720
  l3 = row.length;
2350
1721
  for (k = 0; k < l3; k++) {
2351
1722
  cell += this.renderer.tablecell(
@@ -2353,41 +1724,38 @@ class Parser {
2353
1724
  { header: false, align: token.align[k] }
2354
1725
  );
2355
1726
  }
2356
-
2357
1727
  body += this.renderer.tablerow(cell);
2358
1728
  }
2359
1729
  out += this.renderer.table(header, body);
2360
1730
  continue;
2361
1731
  }
2362
- case 'blockquote': {
1732
+ case "blockquote": {
2363
1733
  body = this.parse(token.tokens);
2364
1734
  out += this.renderer.blockquote(body);
2365
1735
  continue;
2366
1736
  }
2367
- case 'list': {
1737
+ case "list": {
2368
1738
  ordered = token.ordered;
2369
1739
  start = token.start;
2370
1740
  loose = token.loose;
2371
1741
  l2 = token.items.length;
2372
-
2373
- body = '';
1742
+ body = "";
2374
1743
  for (j = 0; j < l2; j++) {
2375
1744
  item = token.items[j];
2376
1745
  checked = item.checked;
2377
1746
  task = item.task;
2378
-
2379
- itemBody = '';
1747
+ itemBody = "";
2380
1748
  if (item.task) {
2381
- checkbox = this.renderer.checkbox(checked);
1749
+ checkbox = this.renderer.checkbox(!!checked);
2382
1750
  if (loose) {
2383
- if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
2384
- item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
2385
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
2386
- item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
1751
+ if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
1752
+ item.tokens[0].text = checkbox + " " + item.tokens[0].text;
1753
+ if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
1754
+ item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
2387
1755
  }
2388
1756
  } else {
2389
1757
  item.tokens.unshift({
2390
- type: 'text',
1758
+ type: "text",
2391
1759
  text: checkbox
2392
1760
  });
2393
1761
  }
@@ -2395,108 +1763,96 @@ class Parser {
2395
1763
  itemBody += checkbox;
2396
1764
  }
2397
1765
  }
2398
-
2399
1766
  itemBody += this.parse(item.tokens, loose);
2400
- body += this.renderer.listitem(itemBody, task, checked);
1767
+ body += this.renderer.listitem(itemBody, task, !!checked);
2401
1768
  }
2402
-
2403
1769
  out += this.renderer.list(body, ordered, start);
2404
1770
  continue;
2405
1771
  }
2406
- case 'html': {
1772
+ case "html": {
2407
1773
  out += this.renderer.html(token.text, token.block);
2408
1774
  continue;
2409
1775
  }
2410
- case 'paragraph': {
1776
+ case "paragraph": {
2411
1777
  out += this.renderer.paragraph(this.parseInline(token.tokens));
2412
1778
  continue;
2413
1779
  }
2414
- case 'text': {
1780
+ case "text": {
2415
1781
  body = token.tokens ? this.parseInline(token.tokens) : token.text;
2416
- while (i + 1 < l && tokens[i + 1].type === 'text') {
1782
+ while (i + 1 < l && tokens[i + 1].type === "text") {
2417
1783
  token = tokens[++i];
2418
- body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
1784
+ body += "\n" + (token.tokens ? this.parseInline(token.tokens) : token.text);
2419
1785
  }
2420
1786
  out += top ? this.renderer.paragraph(body) : body;
2421
1787
  continue;
2422
1788
  }
2423
-
2424
1789
  default: {
2425
1790
  const errMsg = 'Token with "' + token.type + '" type was not found.';
2426
1791
  if (this.options.silent) {
2427
1792
  console.error(errMsg);
2428
- return;
1793
+ return "";
2429
1794
  } else {
2430
1795
  throw new Error(errMsg);
2431
1796
  }
2432
1797
  }
2433
1798
  }
2434
1799
  }
2435
-
2436
1800
  return out;
2437
1801
  }
2438
-
2439
1802
  /**
2440
1803
  * Parse Inline Tokens
2441
1804
  */
2442
1805
  parseInline(tokens, renderer) {
2443
1806
  renderer = renderer || this.renderer;
2444
- let out = '',
2445
- i,
2446
- token,
2447
- ret;
2448
-
1807
+ let out = "", i, token, ret;
2449
1808
  const l = tokens.length;
2450
1809
  for (i = 0; i < l; i++) {
2451
1810
  token = tokens[i];
2452
-
2453
- // Run any renderer extensions
2454
1811
  if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
2455
1812
  ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
2456
- if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
2457
- out += ret || '';
1813
+ if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
1814
+ out += ret || "";
2458
1815
  continue;
2459
1816
  }
2460
1817
  }
2461
-
2462
1818
  switch (token.type) {
2463
- case 'escape': {
1819
+ case "escape": {
2464
1820
  out += renderer.text(token.text);
2465
1821
  break;
2466
1822
  }
2467
- case 'html': {
1823
+ case "html": {
2468
1824
  out += renderer.html(token.text);
2469
1825
  break;
2470
1826
  }
2471
- case 'link': {
1827
+ case "link": {
2472
1828
  out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
2473
1829
  break;
2474
1830
  }
2475
- case 'image': {
1831
+ case "image": {
2476
1832
  out += renderer.image(token.href, token.title, token.text);
2477
1833
  break;
2478
1834
  }
2479
- case 'strong': {
1835
+ case "strong": {
2480
1836
  out += renderer.strong(this.parseInline(token.tokens, renderer));
2481
1837
  break;
2482
1838
  }
2483
- case 'em': {
1839
+ case "em": {
2484
1840
  out += renderer.em(this.parseInline(token.tokens, renderer));
2485
1841
  break;
2486
1842
  }
2487
- case 'codespan': {
1843
+ case "codespan": {
2488
1844
  out += renderer.codespan(token.text);
2489
1845
  break;
2490
1846
  }
2491
- case 'br': {
1847
+ case "br": {
2492
1848
  out += renderer.br();
2493
1849
  break;
2494
1850
  }
2495
- case 'del': {
1851
+ case "del": {
2496
1852
  out += renderer.del(this.parseInline(token.tokens, renderer));
2497
1853
  break;
2498
1854
  }
2499
- case 'text': {
1855
+ case "text": {
2500
1856
  out += renderer.text(token.text);
2501
1857
  break;
2502
1858
  }
@@ -2504,7 +1860,7 @@ class Parser {
2504
1860
  const errMsg = 'Token with "' + token.type + '" type was not found.';
2505
1861
  if (this.options.silent) {
2506
1862
  console.error(errMsg);
2507
- return;
1863
+ return "";
2508
1864
  } else {
2509
1865
  throw new Error(errMsg);
2510
1866
  }
@@ -2513,60 +1869,61 @@ class Parser {
2513
1869
  }
2514
1870
  return out;
2515
1871
  }
2516
- }
1872
+ };
2517
1873
 
2518
- class Hooks {
2519
- constructor(options) {
2520
- this.options = options || defaults;
1874
+ // src/Hooks.ts
1875
+ var _Hooks = class {
1876
+ constructor(options2) {
1877
+ this.options = options2 || _defaults;
2521
1878
  }
2522
-
2523
- static passThroughHooks = new Set([
2524
- 'preprocess',
2525
- 'postprocess'
2526
- ]);
2527
-
2528
1879
  /**
2529
1880
  * Process markdown before marked
2530
1881
  */
2531
1882
  preprocess(markdown) {
2532
1883
  return markdown;
2533
1884
  }
2534
-
2535
1885
  /**
2536
1886
  * Process HTML after marked is finished
2537
1887
  */
2538
1888
  postprocess(html) {
2539
1889
  return html;
2540
1890
  }
2541
- }
2542
-
2543
- class Marked {
2544
- defaults = getDefaults();
2545
- options = this.setOptions;
2546
-
2547
- parse = this.#parseMarkdown(Lexer.lex, Parser.parse);
2548
- parseInline = this.#parseMarkdown(Lexer.lexInline, Parser.parseInline);
2549
-
2550
- Parser = Parser;
2551
- parser = Parser.parse;
2552
- Renderer = Renderer;
2553
- TextRenderer = TextRenderer;
2554
- Lexer = Lexer;
2555
- lexer = Lexer.lex;
2556
- Tokenizer = Tokenizer;
2557
- Slugger = Slugger;
2558
- Hooks = Hooks;
2559
-
1891
+ };
1892
+ _Hooks.passThroughHooks = /* @__PURE__ */ new Set([
1893
+ "preprocess",
1894
+ "postprocess"
1895
+ ]);
1896
+
1897
+ // src/Instance.ts
1898
+ var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
1899
+ var Marked = class {
2560
1900
  constructor(...args) {
1901
+ __privateAdd(this, _parseMarkdown);
1902
+ __privateAdd(this, _onError);
1903
+ this.defaults = _getDefaults();
1904
+ this.options = this.setOptions;
1905
+ this.parse = __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse);
1906
+ this.parseInline = __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline);
1907
+ this.Parser = _Parser;
1908
+ this.parser = _Parser.parse;
1909
+ this.Renderer = _Renderer;
1910
+ this.TextRenderer = _TextRenderer;
1911
+ this.Lexer = _Lexer;
1912
+ this.lexer = _Lexer.lex;
1913
+ this.Tokenizer = _Tokenizer;
1914
+ this.Slugger = _Slugger;
1915
+ this.Hooks = _Hooks;
2561
1916
  this.use(...args);
2562
1917
  }
2563
-
1918
+ /**
1919
+ * Run callback for every token
1920
+ */
2564
1921
  walkTokens(tokens, callback) {
2565
1922
  let values = [];
2566
1923
  for (const token of tokens) {
2567
1924
  values = values.concat(callback.call(this, token));
2568
1925
  switch (token.type) {
2569
- case 'table': {
1926
+ case "table": {
2570
1927
  for (const cell of token.header) {
2571
1928
  values = values.concat(this.walkTokens(cell.tokens, callback));
2572
1929
  }
@@ -2577,12 +1934,12 @@ class Marked {
2577
1934
  }
2578
1935
  break;
2579
1936
  }
2580
- case 'list': {
1937
+ case "list": {
2581
1938
  values = values.concat(this.walkTokens(token.items, callback));
2582
1939
  break;
2583
1940
  }
2584
1941
  default: {
2585
- if (this.defaults.extensions && this.defaults.extensions.childTokens && this.defaults.extensions.childTokens[token.type]) { // Walk any extensions
1942
+ if (this.defaults.extensions && this.defaults.extensions.childTokens && this.defaults.extensions.childTokens[token.type]) {
2586
1943
  this.defaults.extensions.childTokens[token.type].forEach((childTokens) => {
2587
1944
  values = values.concat(this.walkTokens(token[childTokens], callback));
2588
1945
  });
@@ -2594,31 +1951,23 @@ class Marked {
2594
1951
  }
2595
1952
  return values;
2596
1953
  }
2597
-
2598
1954
  use(...args) {
2599
1955
  const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
2600
-
2601
1956
  args.forEach((pack) => {
2602
- // copy options to new object
2603
1957
  const opts = { ...pack };
2604
-
2605
- // set async to true if it was set to true before
2606
1958
  opts.async = this.defaults.async || opts.async || false;
2607
-
2608
- // ==-- Parse "addon" extensions --== //
2609
1959
  if (pack.extensions) {
2610
1960
  pack.extensions.forEach((ext) => {
2611
1961
  if (!ext.name) {
2612
- throw new Error('extension name required');
1962
+ throw new Error("extension name required");
2613
1963
  }
2614
- if (ext.renderer) { // Renderer extensions
1964
+ if ("renderer" in ext) {
2615
1965
  const prevRenderer = extensions.renderers[ext.name];
2616
1966
  if (prevRenderer) {
2617
- // Replace extension with func to run new extension but fall back if false
2618
- extensions.renderers[ext.name] = function(...args) {
2619
- let ret = ext.renderer.apply(this, args);
1967
+ extensions.renderers[ext.name] = function(...args2) {
1968
+ let ret = ext.renderer.apply(this, args2);
2620
1969
  if (ret === false) {
2621
- ret = prevRenderer.apply(this, args);
1970
+ ret = prevRenderer.apply(this, args2);
2622
1971
  }
2623
1972
  return ret;
2624
1973
  };
@@ -2626,8 +1975,8 @@ class Marked {
2626
1975
  extensions.renderers[ext.name] = ext.renderer;
2627
1976
  }
2628
1977
  }
2629
- if (ext.tokenizer) { // Tokenizer Extensions
2630
- if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) {
1978
+ if ("tokenizer" in ext) {
1979
+ if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
2631
1980
  throw new Error("extension level must be 'block' or 'inline'");
2632
1981
  }
2633
1982
  if (extensions[ext.level]) {
@@ -2635,14 +1984,14 @@ class Marked {
2635
1984
  } else {
2636
1985
  extensions[ext.level] = [ext.tokenizer];
2637
1986
  }
2638
- if (ext.start) { // Function to check for start of token
2639
- if (ext.level === 'block') {
1987
+ if (ext.start) {
1988
+ if (ext.level === "block") {
2640
1989
  if (extensions.startBlock) {
2641
1990
  extensions.startBlock.push(ext.start);
2642
1991
  } else {
2643
1992
  extensions.startBlock = [ext.start];
2644
1993
  }
2645
- } else if (ext.level === 'inline') {
1994
+ } else if (ext.level === "inline") {
2646
1995
  if (extensions.startInline) {
2647
1996
  extensions.startInline.push(ext.start);
2648
1997
  } else {
@@ -2651,23 +2000,20 @@ class Marked {
2651
2000
  }
2652
2001
  }
2653
2002
  }
2654
- if (ext.childTokens) { // Child tokens to be visited by walkTokens
2003
+ if ("childTokens" in ext && ext.childTokens) {
2655
2004
  extensions.childTokens[ext.name] = ext.childTokens;
2656
2005
  }
2657
2006
  });
2658
2007
  opts.extensions = extensions;
2659
2008
  }
2660
-
2661
- // ==-- Parse "overwrite" extensions --== //
2662
2009
  if (pack.renderer) {
2663
- const renderer = this.defaults.renderer || new Renderer(this.defaults);
2010
+ const renderer = this.defaults.renderer || new _Renderer(this.defaults);
2664
2011
  for (const prop in pack.renderer) {
2665
2012
  const prevRenderer = renderer[prop];
2666
- // Replace renderer with func to run extension, but fall back if false
2667
- renderer[prop] = (...args) => {
2668
- let ret = pack.renderer[prop].apply(renderer, args);
2013
+ renderer[prop] = (...args2) => {
2014
+ let ret = pack.renderer[prop].apply(renderer, args2);
2669
2015
  if (ret === false) {
2670
- ret = prevRenderer.apply(renderer, args);
2016
+ ret = prevRenderer.apply(renderer, args2);
2671
2017
  }
2672
2018
  return ret;
2673
2019
  };
@@ -2675,42 +2021,38 @@ class Marked {
2675
2021
  opts.renderer = renderer;
2676
2022
  }
2677
2023
  if (pack.tokenizer) {
2678
- const tokenizer = this.defaults.tokenizer || new Tokenizer(this.defaults);
2024
+ const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
2679
2025
  for (const prop in pack.tokenizer) {
2680
2026
  const prevTokenizer = tokenizer[prop];
2681
- // Replace tokenizer with func to run extension, but fall back if false
2682
- tokenizer[prop] = (...args) => {
2683
- let ret = pack.tokenizer[prop].apply(tokenizer, args);
2027
+ tokenizer[prop] = (...args2) => {
2028
+ let ret = pack.tokenizer[prop].apply(tokenizer, args2);
2684
2029
  if (ret === false) {
2685
- ret = prevTokenizer.apply(tokenizer, args);
2030
+ ret = prevTokenizer.apply(tokenizer, args2);
2686
2031
  }
2687
2032
  return ret;
2688
2033
  };
2689
2034
  }
2690
2035
  opts.tokenizer = tokenizer;
2691
2036
  }
2692
-
2693
- // ==-- Parse Hooks extensions --== //
2694
2037
  if (pack.hooks) {
2695
- const hooks = this.defaults.hooks || new Hooks();
2038
+ const hooks = this.defaults.hooks || new _Hooks();
2696
2039
  for (const prop in pack.hooks) {
2697
2040
  const prevHook = hooks[prop];
2698
- if (Hooks.passThroughHooks.has(prop)) {
2041
+ if (_Hooks.passThroughHooks.has(prop)) {
2699
2042
  hooks[prop] = (arg) => {
2700
2043
  if (this.defaults.async) {
2701
- return Promise.resolve(pack.hooks[prop].call(hooks, arg)).then(ret => {
2702
- return prevHook.call(hooks, ret);
2044
+ return Promise.resolve(pack.hooks[prop].call(hooks, arg)).then((ret2) => {
2045
+ return prevHook.call(hooks, ret2);
2703
2046
  });
2704
2047
  }
2705
-
2706
2048
  const ret = pack.hooks[prop].call(hooks, arg);
2707
2049
  return prevHook.call(hooks, ret);
2708
2050
  };
2709
2051
  } else {
2710
- hooks[prop] = (...args) => {
2711
- let ret = pack.hooks[prop].apply(hooks, args);
2052
+ hooks[prop] = (...args2) => {
2053
+ let ret = pack.hooks[prop].apply(hooks, args2);
2712
2054
  if (ret === false) {
2713
- ret = prevHook.apply(hooks, args);
2055
+ ret = prevHook.apply(hooks, args2);
2714
2056
  }
2715
2057
  return ret;
2716
2058
  };
@@ -2718,265 +2060,197 @@ class Marked {
2718
2060
  }
2719
2061
  opts.hooks = hooks;
2720
2062
  }
2721
-
2722
- // ==-- Parse WalkTokens extensions --== //
2723
2063
  if (pack.walkTokens) {
2724
- const walkTokens = this.defaults.walkTokens;
2064
+ const walkTokens2 = this.defaults.walkTokens;
2725
2065
  opts.walkTokens = function(token) {
2726
2066
  let values = [];
2727
2067
  values.push(pack.walkTokens.call(this, token));
2728
- if (walkTokens) {
2729
- values = values.concat(walkTokens.call(this, token));
2068
+ if (walkTokens2) {
2069
+ values = values.concat(walkTokens2.call(this, token));
2730
2070
  }
2731
2071
  return values;
2732
2072
  };
2733
2073
  }
2734
-
2735
2074
  this.defaults = { ...this.defaults, ...opts };
2736
2075
  });
2737
-
2738
2076
  return this;
2739
2077
  }
2740
-
2741
2078
  setOptions(opt) {
2742
2079
  this.defaults = { ...this.defaults, ...opt };
2743
2080
  return this;
2744
2081
  }
2745
-
2746
- #parseMarkdown(lexer, parser) {
2747
- return (src, opt, callback) => {
2748
- if (typeof opt === 'function') {
2749
- callback = opt;
2750
- opt = null;
2751
- }
2752
-
2753
- const origOpt = { ...opt };
2754
- opt = { ...this.defaults, ...origOpt };
2755
- const throwError = this.#onError(opt.silent, opt.async, callback);
2756
-
2757
- // throw error in case of non string input
2758
- if (typeof src === 'undefined' || src === null) {
2759
- return throwError(new Error('marked(): input parameter is undefined or null'));
2760
- }
2761
- if (typeof src !== 'string') {
2762
- return throwError(new Error('marked(): input parameter is of type '
2763
- + Object.prototype.toString.call(src) + ', string expected'));
2764
- }
2765
-
2766
- checkDeprecations(opt, callback);
2767
-
2768
- if (opt.hooks) {
2769
- opt.hooks.options = opt;
2082
+ };
2083
+ _parseMarkdown = new WeakSet();
2084
+ parseMarkdown_fn = function(lexer2, parser2) {
2085
+ return (src, optOrCallback, callback) => {
2086
+ if (typeof optOrCallback === "function") {
2087
+ callback = optOrCallback;
2088
+ optOrCallback = null;
2089
+ }
2090
+ const origOpt = { ...optOrCallback };
2091
+ const opt = { ...this.defaults, ...origOpt };
2092
+ const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async, callback);
2093
+ if (typeof src === "undefined" || src === null) {
2094
+ return throwError(new Error("marked(): input parameter is undefined or null"));
2095
+ }
2096
+ if (typeof src !== "string") {
2097
+ return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
2098
+ }
2099
+ checkDeprecations(opt, callback);
2100
+ if (opt.hooks) {
2101
+ opt.hooks.options = opt;
2102
+ }
2103
+ if (callback) {
2104
+ const highlight = opt.highlight;
2105
+ let tokens;
2106
+ try {
2107
+ if (opt.hooks) {
2108
+ src = opt.hooks.preprocess(src);
2109
+ }
2110
+ tokens = lexer2(src, opt);
2111
+ } catch (e) {
2112
+ return throwError(e);
2770
2113
  }
2771
-
2772
- if (callback) {
2773
- const highlight = opt.highlight;
2774
- let tokens;
2775
-
2776
- try {
2777
- if (opt.hooks) {
2778
- src = opt.hooks.preprocess(src);
2114
+ const done = (err) => {
2115
+ let out;
2116
+ if (!err) {
2117
+ try {
2118
+ if (opt.walkTokens) {
2119
+ this.walkTokens(tokens, opt.walkTokens);
2120
+ }
2121
+ out = parser2(tokens, opt);
2122
+ if (opt.hooks) {
2123
+ out = opt.hooks.postprocess(out);
2124
+ }
2125
+ } catch (e) {
2126
+ err = e;
2779
2127
  }
2780
- tokens = lexer(src, opt);
2781
- } catch (e) {
2782
- return throwError(e);
2783
2128
  }
2784
-
2785
- const done = (err) => {
2786
- let out;
2787
-
2788
- if (!err) {
2789
- try {
2790
- if (opt.walkTokens) {
2791
- this.walkTokens(tokens, opt.walkTokens);
2129
+ opt.highlight = highlight;
2130
+ return err ? throwError(err) : callback(null, out);
2131
+ };
2132
+ if (!highlight || highlight.length < 3) {
2133
+ return done();
2134
+ }
2135
+ delete opt.highlight;
2136
+ if (!tokens.length)
2137
+ return done();
2138
+ let pending = 0;
2139
+ this.walkTokens(tokens, (token) => {
2140
+ if (token.type === "code") {
2141
+ pending++;
2142
+ setTimeout(() => {
2143
+ highlight(token.text, token.lang, (err, code) => {
2144
+ if (err) {
2145
+ return done(err);
2792
2146
  }
2793
- out = parser(tokens, opt);
2794
- if (opt.hooks) {
2795
- out = opt.hooks.postprocess(out);
2147
+ if (code != null && code !== token.text) {
2148
+ token.text = code;
2149
+ token.escaped = true;
2796
2150
  }
2797
- } catch (e) {
2798
- err = e;
2799
- }
2800
- }
2801
-
2802
- opt.highlight = highlight;
2803
-
2804
- return err
2805
- ? throwError(err)
2806
- : callback(null, out);
2807
- };
2808
-
2809
- if (!highlight || highlight.length < 3) {
2810
- return done();
2811
- }
2812
-
2813
- delete opt.highlight;
2814
-
2815
- if (!tokens.length) return done();
2816
-
2817
- let pending = 0;
2818
- this.walkTokens(tokens, (token) => {
2819
- if (token.type === 'code') {
2820
- pending++;
2821
- setTimeout(() => {
2822
- highlight(token.text, token.lang, (err, code) => {
2823
- if (err) {
2824
- return done(err);
2825
- }
2826
- if (code != null && code !== token.text) {
2827
- token.text = code;
2828
- token.escaped = true;
2829
- }
2830
-
2831
- pending--;
2832
- if (pending === 0) {
2833
- done();
2834
- }
2835
- });
2836
- }, 0);
2837
- }
2838
- });
2839
-
2840
- if (pending === 0) {
2841
- done();
2151
+ pending--;
2152
+ if (pending === 0) {
2153
+ done();
2154
+ }
2155
+ });
2156
+ }, 0);
2842
2157
  }
2843
-
2844
- return;
2158
+ });
2159
+ if (pending === 0) {
2160
+ done();
2845
2161
  }
2846
-
2847
- if (opt.async) {
2848
- return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
2849
- .then(src => lexer(src, opt))
2850
- .then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens)
2851
- .then(tokens => parser(tokens, opt))
2852
- .then(html => opt.hooks ? opt.hooks.postprocess(html) : html)
2853
- .catch(throwError);
2162
+ return;
2163
+ }
2164
+ if (opt.async) {
2165
+ return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html) => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
2166
+ }
2167
+ try {
2168
+ if (opt.hooks) {
2169
+ src = opt.hooks.preprocess(src);
2854
2170
  }
2855
-
2856
- try {
2857
- if (opt.hooks) {
2858
- src = opt.hooks.preprocess(src);
2859
- }
2860
- const tokens = lexer(src, opt);
2861
- if (opt.walkTokens) {
2862
- this.walkTokens(tokens, opt.walkTokens);
2863
- }
2864
- let html = parser(tokens, opt);
2865
- if (opt.hooks) {
2866
- html = opt.hooks.postprocess(html);
2867
- }
2868
- return html;
2869
- } catch (e) {
2870
- return throwError(e);
2171
+ const tokens = lexer2(src, opt);
2172
+ if (opt.walkTokens) {
2173
+ this.walkTokens(tokens, opt.walkTokens);
2871
2174
  }
2872
- };
2873
- }
2874
-
2875
- #onError(silent, async, callback) {
2876
- return (e) => {
2877
- e.message += '\nPlease report this to https://github.com/markedjs/this.';
2878
-
2879
- if (silent) {
2880
- const msg = '<p>An error occurred:</p><pre>'
2881
- + escape(e.message + '', true)
2882
- + '</pre>';
2883
- if (async) {
2884
- return Promise.resolve(msg);
2885
- }
2886
- if (callback) {
2887
- callback(null, msg);
2888
- return;
2889
- }
2890
- return msg;
2175
+ let html = parser2(tokens, opt);
2176
+ if (opt.hooks) {
2177
+ html = opt.hooks.postprocess(html);
2891
2178
  }
2892
-
2179
+ return html;
2180
+ } catch (e) {
2181
+ return throwError(e);
2182
+ }
2183
+ };
2184
+ };
2185
+ _onError = new WeakSet();
2186
+ onError_fn = function(silent, async, callback) {
2187
+ return (e) => {
2188
+ e.message += "\nPlease report this to https://github.com/markedjs/marked.";
2189
+ if (silent) {
2190
+ const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
2893
2191
  if (async) {
2894
- return Promise.reject(e);
2192
+ return Promise.resolve(msg);
2895
2193
  }
2896
2194
  if (callback) {
2897
- callback(e);
2195
+ callback(null, msg);
2898
2196
  return;
2899
2197
  }
2900
- throw e;
2901
- };
2902
- }
2903
- }
2904
-
2905
- const markedInstance = new Marked(defaults);
2198
+ return msg;
2199
+ }
2200
+ if (async) {
2201
+ return Promise.reject(e);
2202
+ }
2203
+ if (callback) {
2204
+ callback(e);
2205
+ return;
2206
+ }
2207
+ throw e;
2208
+ };
2209
+ };
2906
2210
 
2907
- /**
2908
- * Marked
2909
- */
2211
+ // src/marked.ts
2212
+ var markedInstance = new Marked();
2910
2213
  function marked(src, opt, callback) {
2911
2214
  return markedInstance.parse(src, opt, callback);
2912
2215
  }
2913
-
2914
- /**
2915
- * Options
2916
- */
2917
-
2918
- marked.options =
2919
- marked.setOptions = function(opt) {
2920
- markedInstance.setOptions(opt);
2216
+ marked.options = marked.setOptions = function(options2) {
2217
+ markedInstance.setOptions(options2);
2921
2218
  marked.defaults = markedInstance.defaults;
2922
2219
  changeDefaults(marked.defaults);
2923
2220
  return marked;
2924
2221
  };
2925
-
2926
- marked.getDefaults = getDefaults;
2927
-
2928
- marked.defaults = defaults;
2929
-
2930
- /**
2931
- * Use Extension
2932
- */
2933
-
2222
+ marked.getDefaults = _getDefaults;
2223
+ marked.defaults = _defaults;
2934
2224
  marked.use = function(...args) {
2935
2225
  markedInstance.use(...args);
2936
2226
  marked.defaults = markedInstance.defaults;
2937
2227
  changeDefaults(marked.defaults);
2938
2228
  return marked;
2939
2229
  };
2940
-
2941
- /**
2942
- * Run callback for every token
2943
- */
2944
-
2945
2230
  marked.walkTokens = function(tokens, callback) {
2946
2231
  return markedInstance.walkTokens(tokens, callback);
2947
2232
  };
2948
-
2949
- /**
2950
- * Parse Inline
2951
- * @param {string} src
2952
- */
2953
2233
  marked.parseInline = markedInstance.parseInline;
2954
-
2955
- /**
2956
- * Expose
2957
- */
2958
- marked.Parser = Parser;
2959
- marked.parser = Parser.parse;
2960
- marked.Renderer = Renderer;
2961
- marked.TextRenderer = TextRenderer;
2962
- marked.Lexer = Lexer;
2963
- marked.lexer = Lexer.lex;
2964
- marked.Tokenizer = Tokenizer;
2965
- marked.Slugger = Slugger;
2966
- marked.Hooks = Hooks;
2234
+ marked.Parser = _Parser;
2235
+ marked.parser = _Parser.parse;
2236
+ marked.Renderer = _Renderer;
2237
+ marked.TextRenderer = _TextRenderer;
2238
+ marked.Lexer = _Lexer;
2239
+ marked.lexer = _Lexer.lex;
2240
+ marked.Tokenizer = _Tokenizer;
2241
+ marked.Slugger = _Slugger;
2242
+ marked.Hooks = _Hooks;
2967
2243
  marked.parse = marked;
2968
-
2969
- const options = marked.options;
2970
- const setOptions = marked.setOptions;
2971
- const use = marked.use;
2972
- const walkTokens = marked.walkTokens;
2973
- const parseInline = marked.parseInline;
2974
- const parse = marked;
2975
- const parser = Parser.parse;
2976
- const lexer = Lexer.lex;
2977
-
2978
-
2979
-
2244
+ var options = marked.options;
2245
+ var setOptions = marked.setOptions;
2246
+ var use = marked.use;
2247
+ var walkTokens = marked.walkTokens;
2248
+ var parseInline = marked.parseInline;
2249
+ var parse = marked;
2250
+ var parser = _Parser.parse;
2251
+ var lexer = _Lexer.lex;
2252
+
2253
+ //# sourceMappingURL=marked.esm.js.map
2980
2254
 
2981
2255
  /***/ })
2982
2256