marked 13.0.2 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/marked.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v13.0.2 - a markdown parser
2
+ * marked v14.0.0 - a markdown parser
3
3
  * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -29,7 +29,7 @@
29
29
  renderer: null,
30
30
  silent: false,
31
31
  tokenizer: null,
32
- walkTokens: null
32
+ walkTokens: null,
33
33
  };
34
34
  }
35
35
  exports.defaults = _getDefaults();
@@ -49,7 +49,7 @@
49
49
  '<': '&lt;',
50
50
  '>': '&gt;',
51
51
  '"': '&quot;',
52
- "'": '&#39;'
52
+ "'": '&#39;',
53
53
  };
54
54
  const getEscapeReplacement = (ch) => escapeReplacements[ch];
55
55
  function escape$1(html, encode) {
@@ -65,21 +65,6 @@
65
65
  }
66
66
  return html;
67
67
  }
68
- const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
69
- function unescape(html) {
70
- // explicitly match decimal, hex, and named HTML entities
71
- return html.replace(unescapeTest, (_, n) => {
72
- n = n.toLowerCase();
73
- if (n === 'colon')
74
- return ':';
75
- if (n.charAt(0) === '#') {
76
- return n.charAt(1) === 'x'
77
- ? String.fromCharCode(parseInt(n.substring(2), 16))
78
- : String.fromCharCode(+n.substring(1));
79
- }
80
- return '';
81
- });
82
- }
83
68
  const caret = /(^|[^\[])\^/g;
84
69
  function edit(regex, opt) {
85
70
  let source = typeof regex === 'string' ? regex : regex.source;
@@ -93,7 +78,7 @@
93
78
  },
94
79
  getRegex: () => {
95
80
  return new RegExp(source, opt);
96
- }
81
+ },
97
82
  };
98
83
  return obj;
99
84
  }
@@ -101,7 +86,7 @@
101
86
  try {
102
87
  href = encodeURI(href).replace(/%25/g, '%');
103
88
  }
104
- catch (e) {
89
+ catch {
105
90
  return null;
106
91
  }
107
92
  return href;
@@ -212,7 +197,7 @@
212
197
  href,
213
198
  title,
214
199
  text,
215
- tokens: lexer.inlineTokens(text)
200
+ tokens: lexer.inlineTokens(text),
216
201
  };
217
202
  lexer.state.inLink = false;
218
203
  return token;
@@ -222,7 +207,7 @@
222
207
  raw,
223
208
  href,
224
209
  title,
225
- text: escape$1(text)
210
+ text: escape$1(text),
226
211
  };
227
212
  }
228
213
  function indentCodeCompensation(raw, text) {
@@ -261,7 +246,7 @@
261
246
  if (cap && cap[0].length > 0) {
262
247
  return {
263
248
  type: 'space',
264
- raw: cap[0]
249
+ raw: cap[0],
265
250
  };
266
251
  }
267
252
  }
@@ -275,7 +260,7 @@
275
260
  codeBlockStyle: 'indented',
276
261
  text: !this.options.pedantic
277
262
  ? rtrim(text, '\n')
278
- : text
263
+ : text,
279
264
  };
280
265
  }
281
266
  }
@@ -288,7 +273,7 @@
288
273
  type: 'code',
289
274
  raw,
290
275
  lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
291
- text
276
+ text,
292
277
  };
293
278
  }
294
279
  }
@@ -312,7 +297,7 @@
312
297
  raw: cap[0],
313
298
  depth: cap[1].length,
314
299
  text,
315
- tokens: this.lexer.inline(text)
300
+ tokens: this.lexer.inline(text),
316
301
  };
317
302
  }
318
303
  }
@@ -321,7 +306,7 @@
321
306
  if (cap) {
322
307
  return {
323
308
  type: 'hr',
324
- raw: rtrim(cap[0], '\n')
309
+ raw: rtrim(cap[0], '\n'),
325
310
  };
326
311
  }
327
312
  }
@@ -398,7 +383,7 @@
398
383
  type: 'blockquote',
399
384
  raw,
400
385
  tokens,
401
- text
386
+ text,
402
387
  };
403
388
  }
404
389
  }
@@ -413,7 +398,7 @@
413
398
  ordered: isordered,
414
399
  start: isordered ? +bull.slice(0, -1) : '',
415
400
  loose: false,
416
- items: []
401
+ items: [],
417
402
  };
418
403
  bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
419
404
  if (this.options.pedantic) {
@@ -543,7 +528,7 @@
543
528
  checked: ischecked,
544
529
  loose: false,
545
530
  text: itemContents,
546
- tokens: []
531
+ tokens: [],
547
532
  });
548
533
  list.raw += raw;
549
534
  }
@@ -579,7 +564,7 @@
579
564
  block: true,
580
565
  raw: cap[0],
581
566
  pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
582
- text: cap[0]
567
+ text: cap[0],
583
568
  };
584
569
  return token;
585
570
  }
@@ -595,7 +580,7 @@
595
580
  tag,
596
581
  raw: cap[0],
597
582
  href,
598
- title
583
+ title,
599
584
  };
600
585
  }
601
586
  }
@@ -616,7 +601,7 @@
616
601
  raw: cap[0],
617
602
  header: [],
618
603
  align: [],
619
- rows: []
604
+ rows: [],
620
605
  };
621
606
  if (headers.length !== aligns.length) {
622
607
  // header and align columns must be equal, rows can be different.
@@ -641,7 +626,7 @@
641
626
  text: headers[i],
642
627
  tokens: this.lexer.inline(headers[i]),
643
628
  header: true,
644
- align: item.align[i]
629
+ align: item.align[i],
645
630
  });
646
631
  }
647
632
  for (const row of rows) {
@@ -650,7 +635,7 @@
650
635
  text: cell,
651
636
  tokens: this.lexer.inline(cell),
652
637
  header: false,
653
- align: item.align[i]
638
+ align: item.align[i],
654
639
  };
655
640
  }));
656
641
  }
@@ -664,7 +649,7 @@
664
649
  raw: cap[0],
665
650
  depth: cap[2].charAt(0) === '=' ? 1 : 2,
666
651
  text: cap[1],
667
- tokens: this.lexer.inline(cap[1])
652
+ tokens: this.lexer.inline(cap[1]),
668
653
  };
669
654
  }
670
655
  }
@@ -678,7 +663,7 @@
678
663
  type: 'paragraph',
679
664
  raw: cap[0],
680
665
  text,
681
- tokens: this.lexer.inline(text)
666
+ tokens: this.lexer.inline(text),
682
667
  };
683
668
  }
684
669
  }
@@ -689,7 +674,7 @@
689
674
  type: 'text',
690
675
  raw: cap[0],
691
676
  text: cap[0],
692
- tokens: this.lexer.inline(cap[0])
677
+ tokens: this.lexer.inline(cap[0]),
693
678
  };
694
679
  }
695
680
  }
@@ -699,7 +684,7 @@
699
684
  return {
700
685
  type: 'escape',
701
686
  raw: cap[0],
702
- text: escape$1(cap[1])
687
+ text: escape$1(cap[1]),
703
688
  };
704
689
  }
705
690
  }
@@ -724,7 +709,7 @@
724
709
  inLink: this.lexer.state.inLink,
725
710
  inRawBlock: this.lexer.state.inRawBlock,
726
711
  block: false,
727
- text: cap[0]
712
+ text: cap[0],
728
713
  };
729
714
  }
730
715
  }
@@ -779,7 +764,7 @@
779
764
  }
780
765
  return outputLink(cap, {
781
766
  href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
782
- title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
767
+ title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title,
783
768
  }, cap[0], this.lexer);
784
769
  }
785
770
  }
@@ -794,7 +779,7 @@
794
779
  return {
795
780
  type: 'text',
796
781
  raw: text,
797
- text
782
+ text,
798
783
  };
799
784
  }
800
785
  return outputLink(cap, link, cap[0], this.lexer);
@@ -846,7 +831,7 @@
846
831
  type: 'em',
847
832
  raw,
848
833
  text,
849
- tokens: this.lexer.inlineTokens(text)
834
+ tokens: this.lexer.inlineTokens(text),
850
835
  };
851
836
  }
852
837
  // Create 'strong' if smallest delimiter has even char count. **a***
@@ -855,7 +840,7 @@
855
840
  type: 'strong',
856
841
  raw,
857
842
  text,
858
- tokens: this.lexer.inlineTokens(text)
843
+ tokens: this.lexer.inlineTokens(text),
859
844
  };
860
845
  }
861
846
  }
@@ -873,7 +858,7 @@
873
858
  return {
874
859
  type: 'codespan',
875
860
  raw: cap[0],
876
- text
861
+ text,
877
862
  };
878
863
  }
879
864
  }
@@ -882,7 +867,7 @@
882
867
  if (cap) {
883
868
  return {
884
869
  type: 'br',
885
- raw: cap[0]
870
+ raw: cap[0],
886
871
  };
887
872
  }
888
873
  }
@@ -893,7 +878,7 @@
893
878
  type: 'del',
894
879
  raw: cap[0],
895
880
  text: cap[2],
896
- tokens: this.lexer.inlineTokens(cap[2])
881
+ tokens: this.lexer.inlineTokens(cap[2]),
897
882
  };
898
883
  }
899
884
  }
@@ -918,9 +903,9 @@
918
903
  {
919
904
  type: 'text',
920
905
  raw: text,
921
- text
922
- }
923
- ]
906
+ text,
907
+ },
908
+ ],
924
909
  };
925
910
  }
926
911
  }
@@ -956,9 +941,9 @@
956
941
  {
957
942
  type: 'text',
958
943
  raw: text,
959
- text
960
- }
961
- ]
944
+ text,
945
+ },
946
+ ],
962
947
  };
963
948
  }
964
949
  }
@@ -975,7 +960,7 @@
975
960
  return {
976
961
  type: 'text',
977
962
  raw: cap[0],
978
- text
963
+ text,
979
964
  };
980
965
  }
981
966
  }
@@ -1059,7 +1044,7 @@
1059
1044
  newline,
1060
1045
  paragraph,
1061
1046
  table: noopTest,
1062
- text: blockText
1047
+ text: blockText,
1063
1048
  };
1064
1049
  /**
1065
1050
  * GFM Block Grammar
@@ -1089,7 +1074,7 @@
1089
1074
  .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1090
1075
  .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1091
1076
  .replace('tag', _tag) // pars can be interrupted by type (6) html blocks
1092
- .getRegex()
1077
+ .getRegex(),
1093
1078
  };
1094
1079
  /**
1095
1080
  * Pedantic grammar (original John Gruber's loose markdown specification)
@@ -1119,7 +1104,7 @@
1119
1104
  .replace('|list', '')
1120
1105
  .replace('|html', '')
1121
1106
  .replace('|tag', '')
1122
- .getRegex()
1107
+ .getRegex(),
1123
1108
  };
1124
1109
  /**
1125
1110
  * Inline-Level Grammar
@@ -1213,7 +1198,7 @@
1213
1198
  reflinkSearch,
1214
1199
  tag,
1215
1200
  text: inlineText,
1216
- url: noopTest
1201
+ url: noopTest,
1217
1202
  };
1218
1203
  /**
1219
1204
  * Pedantic Inline Grammar
@@ -1225,7 +1210,7 @@
1225
1210
  .getRegex(),
1226
1211
  reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
1227
1212
  .replace('label', _inlineLabel)
1228
- .getRegex()
1213
+ .getRegex(),
1229
1214
  };
1230
1215
  /**
1231
1216
  * GFM Inline Grammar
@@ -1238,7 +1223,7 @@
1238
1223
  .getRegex(),
1239
1224
  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
1240
1225
  del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
1241
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
1226
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/,
1242
1227
  };
1243
1228
  /**
1244
1229
  * GFM + Line Breaks Inline Grammar
@@ -1249,7 +1234,7 @@
1249
1234
  text: edit(inlineGfm.text)
1250
1235
  .replace('\\b_', '\\b_| {2,}\\n')
1251
1236
  .replace(/\{2,\}/g, '*')
1252
- .getRegex()
1237
+ .getRegex(),
1253
1238
  };
1254
1239
  /**
1255
1240
  * exports
@@ -1257,13 +1242,13 @@
1257
1242
  const block = {
1258
1243
  normal: blockNormal,
1259
1244
  gfm: blockGfm,
1260
- pedantic: blockPedantic
1245
+ pedantic: blockPedantic,
1261
1246
  };
1262
1247
  const inline = {
1263
1248
  normal: inlineNormal,
1264
1249
  gfm: inlineGfm,
1265
1250
  breaks: inlineBreaks,
1266
- pedantic: inlinePedantic
1251
+ pedantic: inlinePedantic,
1267
1252
  };
1268
1253
 
1269
1254
  /**
@@ -1288,11 +1273,11 @@
1288
1273
  this.state = {
1289
1274
  inLink: false,
1290
1275
  inRawBlock: false,
1291
- top: true
1276
+ top: true,
1292
1277
  };
1293
1278
  const rules = {
1294
1279
  block: block.normal,
1295
- inline: inline.normal
1280
+ inline: inline.normal,
1296
1281
  };
1297
1282
  if (this.options.pedantic) {
1298
1283
  rules.block = block.pedantic;
@@ -1315,7 +1300,7 @@
1315
1300
  static get rules() {
1316
1301
  return {
1317
1302
  block,
1318
- inline
1303
+ inline,
1319
1304
  };
1320
1305
  }
1321
1306
  /**
@@ -1447,7 +1432,7 @@
1447
1432
  else if (!this.tokens.links[token.tag]) {
1448
1433
  this.tokens.links[token.tag] = {
1449
1434
  href: token.href,
1450
- title: token.title
1435
+ title: token.title,
1451
1436
  };
1452
1437
  }
1453
1438
  continue;
@@ -1763,7 +1748,7 @@
1763
1748
  item.tokens.unshift({
1764
1749
  type: 'text',
1765
1750
  raw: checkbox + ' ',
1766
- text: checkbox + ' '
1751
+ text: checkbox + ' ',
1767
1752
  });
1768
1753
  }
1769
1754
  }
@@ -1999,7 +1984,7 @@
1999
1984
  type: 'paragraph',
2000
1985
  raw: body,
2001
1986
  text: body,
2002
- tokens: [{ type: 'text', raw: body, text: body }]
1987
+ tokens: [{ type: 'text', raw: body, text: body }],
2003
1988
  });
2004
1989
  }
2005
1990
  else {
@@ -2103,7 +2088,7 @@
2103
2088
  static passThroughHooks = new Set([
2104
2089
  'preprocess',
2105
2090
  'postprocess',
2106
- 'processAllTokens'
2091
+ 'processAllTokens',
2107
2092
  ]);
2108
2093
  /**
2109
2094
  * Process markdown before marked
@@ -2128,8 +2113,8 @@
2128
2113
  class Marked {
2129
2114
  defaults = _getDefaults();
2130
2115
  options = this.setOptions;
2131
- parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);
2132
- parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
2116
+ parse = this.parseMarkdown(_Lexer.lex, _Parser.parse);
2117
+ parseInline = this.parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
2133
2118
  Parser = _Parser;
2134
2119
  Renderer = _Renderer;
2135
2120
  TextRenderer = _TextRenderer;
@@ -2257,14 +2242,10 @@
2257
2242
  continue;
2258
2243
  }
2259
2244
  const rendererProp = prop;
2260
- let rendererFunc = pack.renderer[rendererProp];
2245
+ const rendererFunc = pack.renderer[rendererProp];
2261
2246
  const prevRenderer = renderer[rendererProp];
2262
2247
  // Replace renderer with func to run extension, but fall back if false
2263
2248
  renderer[rendererProp] = (...args) => {
2264
- if (!pack.useNewRenderer) {
2265
- // TODO: Remove this in next major version
2266
- rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer);
2267
- }
2268
2249
  let ret = rendererFunc.apply(renderer, args);
2269
2250
  if (ret === false) {
2270
2251
  ret = prevRenderer.apply(renderer, args);
@@ -2355,215 +2336,6 @@
2355
2336
  });
2356
2337
  return this;
2357
2338
  }
2358
- // TODO: Remove this in next major release
2359
- #convertRendererFunction(func, prop, renderer) {
2360
- switch (prop) {
2361
- case 'heading':
2362
- return function (token) {
2363
- if (!token.type || token.type !== prop) {
2364
- // @ts-ignore
2365
- // eslint-disable-next-line prefer-rest-params
2366
- return func.apply(this, arguments);
2367
- }
2368
- return func.call(this, renderer.parser.parseInline(token.tokens), token.depth, unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer)));
2369
- };
2370
- case 'code':
2371
- return function (token) {
2372
- if (!token.type || token.type !== prop) {
2373
- // @ts-ignore
2374
- // eslint-disable-next-line prefer-rest-params
2375
- return func.apply(this, arguments);
2376
- }
2377
- return func.call(this, token.text, token.lang, !!token.escaped);
2378
- };
2379
- case 'table':
2380
- return function (token) {
2381
- if (!token.type || token.type !== prop) {
2382
- // @ts-ignore
2383
- // eslint-disable-next-line prefer-rest-params
2384
- return func.apply(this, arguments);
2385
- }
2386
- let header = '';
2387
- // header
2388
- let cell = '';
2389
- for (let j = 0; j < token.header.length; j++) {
2390
- cell += this.tablecell({
2391
- text: token.header[j].text,
2392
- tokens: token.header[j].tokens,
2393
- header: true,
2394
- align: token.align[j]
2395
- });
2396
- }
2397
- header += this.tablerow({ text: cell });
2398
- let body = '';
2399
- for (let j = 0; j < token.rows.length; j++) {
2400
- const row = token.rows[j];
2401
- cell = '';
2402
- for (let k = 0; k < row.length; k++) {
2403
- cell += this.tablecell({
2404
- text: row[k].text,
2405
- tokens: row[k].tokens,
2406
- header: false,
2407
- align: token.align[k]
2408
- });
2409
- }
2410
- body += this.tablerow({ text: cell });
2411
- }
2412
- return func.call(this, header, body);
2413
- };
2414
- case 'blockquote':
2415
- return function (token) {
2416
- if (!token.type || token.type !== prop) {
2417
- // @ts-ignore
2418
- // eslint-disable-next-line prefer-rest-params
2419
- return func.apply(this, arguments);
2420
- }
2421
- const body = this.parser.parse(token.tokens);
2422
- return func.call(this, body);
2423
- };
2424
- case 'list':
2425
- return function (token) {
2426
- if (!token.type || token.type !== prop) {
2427
- // @ts-ignore
2428
- // eslint-disable-next-line prefer-rest-params
2429
- return func.apply(this, arguments);
2430
- }
2431
- const ordered = token.ordered;
2432
- const start = token.start;
2433
- const loose = token.loose;
2434
- let body = '';
2435
- for (let j = 0; j < token.items.length; j++) {
2436
- const item = token.items[j];
2437
- const checked = item.checked;
2438
- const task = item.task;
2439
- let itemBody = '';
2440
- if (item.task) {
2441
- const checkbox = this.checkbox({ checked: !!checked });
2442
- if (loose) {
2443
- if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
2444
- item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
2445
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
2446
- item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
2447
- }
2448
- }
2449
- else {
2450
- item.tokens.unshift({
2451
- type: 'text',
2452
- text: checkbox + ' '
2453
- });
2454
- }
2455
- }
2456
- else {
2457
- itemBody += checkbox + ' ';
2458
- }
2459
- }
2460
- itemBody += this.parser.parse(item.tokens, loose);
2461
- body += this.listitem({
2462
- type: 'list_item',
2463
- raw: itemBody,
2464
- text: itemBody,
2465
- task,
2466
- checked: !!checked,
2467
- loose,
2468
- tokens: item.tokens
2469
- });
2470
- }
2471
- return func.call(this, body, ordered, start);
2472
- };
2473
- case 'html':
2474
- return function (token) {
2475
- if (!token.type || token.type !== prop) {
2476
- // @ts-ignore
2477
- // eslint-disable-next-line prefer-rest-params
2478
- return func.apply(this, arguments);
2479
- }
2480
- return func.call(this, token.text, token.block);
2481
- };
2482
- case 'paragraph':
2483
- return function (token) {
2484
- if (!token.type || token.type !== prop) {
2485
- // @ts-ignore
2486
- // eslint-disable-next-line prefer-rest-params
2487
- return func.apply(this, arguments);
2488
- }
2489
- return func.call(this, this.parser.parseInline(token.tokens));
2490
- };
2491
- case 'escape':
2492
- return function (token) {
2493
- if (!token.type || token.type !== prop) {
2494
- // @ts-ignore
2495
- // eslint-disable-next-line prefer-rest-params
2496
- return func.apply(this, arguments);
2497
- }
2498
- return func.call(this, token.text);
2499
- };
2500
- case 'link':
2501
- return function (token) {
2502
- if (!token.type || token.type !== prop) {
2503
- // @ts-ignore
2504
- // eslint-disable-next-line prefer-rest-params
2505
- return func.apply(this, arguments);
2506
- }
2507
- return func.call(this, token.href, token.title, this.parser.parseInline(token.tokens));
2508
- };
2509
- case 'image':
2510
- return function (token) {
2511
- if (!token.type || token.type !== prop) {
2512
- // @ts-ignore
2513
- // eslint-disable-next-line prefer-rest-params
2514
- return func.apply(this, arguments);
2515
- }
2516
- return func.call(this, token.href, token.title, token.text);
2517
- };
2518
- case 'strong':
2519
- return function (token) {
2520
- if (!token.type || token.type !== prop) {
2521
- // @ts-ignore
2522
- // eslint-disable-next-line prefer-rest-params
2523
- return func.apply(this, arguments);
2524
- }
2525
- return func.call(this, this.parser.parseInline(token.tokens));
2526
- };
2527
- case 'em':
2528
- return function (token) {
2529
- if (!token.type || token.type !== prop) {
2530
- // @ts-ignore
2531
- // eslint-disable-next-line prefer-rest-params
2532
- return func.apply(this, arguments);
2533
- }
2534
- return func.call(this, this.parser.parseInline(token.tokens));
2535
- };
2536
- case 'codespan':
2537
- return function (token) {
2538
- if (!token.type || token.type !== prop) {
2539
- // @ts-ignore
2540
- // eslint-disable-next-line prefer-rest-params
2541
- return func.apply(this, arguments);
2542
- }
2543
- return func.call(this, token.text);
2544
- };
2545
- case 'del':
2546
- return function (token) {
2547
- if (!token.type || token.type !== prop) {
2548
- // @ts-ignore
2549
- // eslint-disable-next-line prefer-rest-params
2550
- return func.apply(this, arguments);
2551
- }
2552
- return func.call(this, this.parser.parseInline(token.tokens));
2553
- };
2554
- case 'text':
2555
- return function (token) {
2556
- if (!token.type || token.type !== prop) {
2557
- // @ts-ignore
2558
- // eslint-disable-next-line prefer-rest-params
2559
- return func.apply(this, arguments);
2560
- }
2561
- return func.call(this, token.text);
2562
- };
2563
- // do nothing
2564
- }
2565
- return func;
2566
- }
2567
2339
  setOptions(opt) {
2568
2340
  this.defaults = { ...this.defaults, ...opt };
2569
2341
  return this;
@@ -2574,18 +2346,16 @@
2574
2346
  parser(tokens, options) {
2575
2347
  return _Parser.parse(tokens, options ?? this.defaults);
2576
2348
  }
2577
- #parseMarkdown(lexer, parser) {
2578
- return (src, options) => {
2349
+ parseMarkdown(lexer, parser) {
2350
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2351
+ const parse = (src, options) => {
2579
2352
  const origOpt = { ...options };
2580
2353
  const opt = { ...this.defaults, ...origOpt };
2581
- // Show warning if an extension set async to true but the parse was called with async: false
2354
+ const throwError = this.onError(!!opt.silent, !!opt.async);
2355
+ // throw error if an extension set async to true but parse was called with async: false
2582
2356
  if (this.defaults.async === true && origOpt.async === false) {
2583
- if (!opt.silent) {
2584
- console.warn('marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.');
2585
- }
2586
- opt.async = true;
2357
+ return throwError(new Error('marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.'));
2587
2358
  }
2588
- const throwError = this.#onError(!!opt.silent, !!opt.async);
2589
2359
  // throw error in case of non string input
2590
2360
  if (typeof src === 'undefined' || src === null) {
2591
2361
  return throwError(new Error('marked(): input parameter is undefined or null'));
@@ -2627,8 +2397,9 @@
2627
2397
  return throwError(e);
2628
2398
  }
2629
2399
  };
2400
+ return parse;
2630
2401
  }
2631
- #onError(silent, async) {
2402
+ onError(silent, async) {
2632
2403
  return (e) => {
2633
2404
  e.message += '\nPlease report this to https://github.com/markedjs/marked.';
2634
2405
  if (silent) {