marked 13.0.2 → 13.0.3

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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v13.0.2 - a markdown parser
2
+ * marked v13.0.3 - a markdown parser
3
3
  * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -23,7 +23,7 @@ function _getDefaults() {
23
23
  renderer: null,
24
24
  silent: false,
25
25
  tokenizer: null,
26
- walkTokens: null
26
+ walkTokens: null,
27
27
  };
28
28
  }
29
29
  let _defaults = _getDefaults();
@@ -43,7 +43,7 @@ const escapeReplacements = {
43
43
  '<': '&lt;',
44
44
  '>': '&gt;',
45
45
  '"': '&quot;',
46
- "'": '&#39;'
46
+ "'": '&#39;',
47
47
  };
48
48
  const getEscapeReplacement = (ch) => escapeReplacements[ch];
49
49
  function escape$1(html, encode) {
@@ -87,7 +87,7 @@ function edit(regex, opt) {
87
87
  },
88
88
  getRegex: () => {
89
89
  return new RegExp(source, opt);
90
- }
90
+ },
91
91
  };
92
92
  return obj;
93
93
  }
@@ -95,7 +95,7 @@ function cleanUrl(href) {
95
95
  try {
96
96
  href = encodeURI(href).replace(/%25/g, '%');
97
97
  }
98
- catch (e) {
98
+ catch {
99
99
  return null;
100
100
  }
101
101
  return href;
@@ -206,7 +206,7 @@ function outputLink(cap, link, raw, lexer) {
206
206
  href,
207
207
  title,
208
208
  text,
209
- tokens: lexer.inlineTokens(text)
209
+ tokens: lexer.inlineTokens(text),
210
210
  };
211
211
  lexer.state.inLink = false;
212
212
  return token;
@@ -216,7 +216,7 @@ function outputLink(cap, link, raw, lexer) {
216
216
  raw,
217
217
  href,
218
218
  title,
219
- text: escape$1(text)
219
+ text: escape$1(text),
220
220
  };
221
221
  }
222
222
  function indentCodeCompensation(raw, text) {
@@ -255,7 +255,7 @@ class _Tokenizer {
255
255
  if (cap && cap[0].length > 0) {
256
256
  return {
257
257
  type: 'space',
258
- raw: cap[0]
258
+ raw: cap[0],
259
259
  };
260
260
  }
261
261
  }
@@ -269,7 +269,7 @@ class _Tokenizer {
269
269
  codeBlockStyle: 'indented',
270
270
  text: !this.options.pedantic
271
271
  ? rtrim(text, '\n')
272
- : text
272
+ : text,
273
273
  };
274
274
  }
275
275
  }
@@ -282,7 +282,7 @@ class _Tokenizer {
282
282
  type: 'code',
283
283
  raw,
284
284
  lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
285
- text
285
+ text,
286
286
  };
287
287
  }
288
288
  }
@@ -306,7 +306,7 @@ class _Tokenizer {
306
306
  raw: cap[0],
307
307
  depth: cap[1].length,
308
308
  text,
309
- tokens: this.lexer.inline(text)
309
+ tokens: this.lexer.inline(text),
310
310
  };
311
311
  }
312
312
  }
@@ -315,7 +315,7 @@ class _Tokenizer {
315
315
  if (cap) {
316
316
  return {
317
317
  type: 'hr',
318
- raw: rtrim(cap[0], '\n')
318
+ raw: rtrim(cap[0], '\n'),
319
319
  };
320
320
  }
321
321
  }
@@ -392,7 +392,7 @@ class _Tokenizer {
392
392
  type: 'blockquote',
393
393
  raw,
394
394
  tokens,
395
- text
395
+ text,
396
396
  };
397
397
  }
398
398
  }
@@ -407,7 +407,7 @@ class _Tokenizer {
407
407
  ordered: isordered,
408
408
  start: isordered ? +bull.slice(0, -1) : '',
409
409
  loose: false,
410
- items: []
410
+ items: [],
411
411
  };
412
412
  bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
413
413
  if (this.options.pedantic) {
@@ -537,7 +537,7 @@ class _Tokenizer {
537
537
  checked: ischecked,
538
538
  loose: false,
539
539
  text: itemContents,
540
- tokens: []
540
+ tokens: [],
541
541
  });
542
542
  list.raw += raw;
543
543
  }
@@ -573,7 +573,7 @@ class _Tokenizer {
573
573
  block: true,
574
574
  raw: cap[0],
575
575
  pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
576
- text: cap[0]
576
+ text: cap[0],
577
577
  };
578
578
  return token;
579
579
  }
@@ -589,7 +589,7 @@ class _Tokenizer {
589
589
  tag,
590
590
  raw: cap[0],
591
591
  href,
592
- title
592
+ title,
593
593
  };
594
594
  }
595
595
  }
@@ -610,7 +610,7 @@ class _Tokenizer {
610
610
  raw: cap[0],
611
611
  header: [],
612
612
  align: [],
613
- rows: []
613
+ rows: [],
614
614
  };
615
615
  if (headers.length !== aligns.length) {
616
616
  // header and align columns must be equal, rows can be different.
@@ -635,7 +635,7 @@ class _Tokenizer {
635
635
  text: headers[i],
636
636
  tokens: this.lexer.inline(headers[i]),
637
637
  header: true,
638
- align: item.align[i]
638
+ align: item.align[i],
639
639
  });
640
640
  }
641
641
  for (const row of rows) {
@@ -644,7 +644,7 @@ class _Tokenizer {
644
644
  text: cell,
645
645
  tokens: this.lexer.inline(cell),
646
646
  header: false,
647
- align: item.align[i]
647
+ align: item.align[i],
648
648
  };
649
649
  }));
650
650
  }
@@ -658,7 +658,7 @@ class _Tokenizer {
658
658
  raw: cap[0],
659
659
  depth: cap[2].charAt(0) === '=' ? 1 : 2,
660
660
  text: cap[1],
661
- tokens: this.lexer.inline(cap[1])
661
+ tokens: this.lexer.inline(cap[1]),
662
662
  };
663
663
  }
664
664
  }
@@ -672,7 +672,7 @@ class _Tokenizer {
672
672
  type: 'paragraph',
673
673
  raw: cap[0],
674
674
  text,
675
- tokens: this.lexer.inline(text)
675
+ tokens: this.lexer.inline(text),
676
676
  };
677
677
  }
678
678
  }
@@ -683,7 +683,7 @@ class _Tokenizer {
683
683
  type: 'text',
684
684
  raw: cap[0],
685
685
  text: cap[0],
686
- tokens: this.lexer.inline(cap[0])
686
+ tokens: this.lexer.inline(cap[0]),
687
687
  };
688
688
  }
689
689
  }
@@ -693,7 +693,7 @@ class _Tokenizer {
693
693
  return {
694
694
  type: 'escape',
695
695
  raw: cap[0],
696
- text: escape$1(cap[1])
696
+ text: escape$1(cap[1]),
697
697
  };
698
698
  }
699
699
  }
@@ -718,7 +718,7 @@ class _Tokenizer {
718
718
  inLink: this.lexer.state.inLink,
719
719
  inRawBlock: this.lexer.state.inRawBlock,
720
720
  block: false,
721
- text: cap[0]
721
+ text: cap[0],
722
722
  };
723
723
  }
724
724
  }
@@ -773,7 +773,7 @@ class _Tokenizer {
773
773
  }
774
774
  return outputLink(cap, {
775
775
  href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
776
- title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
776
+ title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title,
777
777
  }, cap[0], this.lexer);
778
778
  }
779
779
  }
@@ -788,7 +788,7 @@ class _Tokenizer {
788
788
  return {
789
789
  type: 'text',
790
790
  raw: text,
791
- text
791
+ text,
792
792
  };
793
793
  }
794
794
  return outputLink(cap, link, cap[0], this.lexer);
@@ -840,7 +840,7 @@ class _Tokenizer {
840
840
  type: 'em',
841
841
  raw,
842
842
  text,
843
- tokens: this.lexer.inlineTokens(text)
843
+ tokens: this.lexer.inlineTokens(text),
844
844
  };
845
845
  }
846
846
  // Create 'strong' if smallest delimiter has even char count. **a***
@@ -849,7 +849,7 @@ class _Tokenizer {
849
849
  type: 'strong',
850
850
  raw,
851
851
  text,
852
- tokens: this.lexer.inlineTokens(text)
852
+ tokens: this.lexer.inlineTokens(text),
853
853
  };
854
854
  }
855
855
  }
@@ -867,7 +867,7 @@ class _Tokenizer {
867
867
  return {
868
868
  type: 'codespan',
869
869
  raw: cap[0],
870
- text
870
+ text,
871
871
  };
872
872
  }
873
873
  }
@@ -876,7 +876,7 @@ class _Tokenizer {
876
876
  if (cap) {
877
877
  return {
878
878
  type: 'br',
879
- raw: cap[0]
879
+ raw: cap[0],
880
880
  };
881
881
  }
882
882
  }
@@ -887,7 +887,7 @@ class _Tokenizer {
887
887
  type: 'del',
888
888
  raw: cap[0],
889
889
  text: cap[2],
890
- tokens: this.lexer.inlineTokens(cap[2])
890
+ tokens: this.lexer.inlineTokens(cap[2]),
891
891
  };
892
892
  }
893
893
  }
@@ -912,9 +912,9 @@ class _Tokenizer {
912
912
  {
913
913
  type: 'text',
914
914
  raw: text,
915
- text
916
- }
917
- ]
915
+ text,
916
+ },
917
+ ],
918
918
  };
919
919
  }
920
920
  }
@@ -950,9 +950,9 @@ class _Tokenizer {
950
950
  {
951
951
  type: 'text',
952
952
  raw: text,
953
- text
954
- }
955
- ]
953
+ text,
954
+ },
955
+ ],
956
956
  };
957
957
  }
958
958
  }
@@ -969,7 +969,7 @@ class _Tokenizer {
969
969
  return {
970
970
  type: 'text',
971
971
  raw: cap[0],
972
- text
972
+ text,
973
973
  };
974
974
  }
975
975
  }
@@ -1053,7 +1053,7 @@ const blockNormal = {
1053
1053
  newline,
1054
1054
  paragraph,
1055
1055
  table: noopTest,
1056
- text: blockText
1056
+ text: blockText,
1057
1057
  };
1058
1058
  /**
1059
1059
  * GFM Block Grammar
@@ -1083,7 +1083,7 @@ const blockGfm = {
1083
1083
  .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1084
1084
  .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1085
1085
  .replace('tag', _tag) // pars can be interrupted by type (6) html blocks
1086
- .getRegex()
1086
+ .getRegex(),
1087
1087
  };
1088
1088
  /**
1089
1089
  * Pedantic grammar (original John Gruber's loose markdown specification)
@@ -1113,7 +1113,7 @@ const blockPedantic = {
1113
1113
  .replace('|list', '')
1114
1114
  .replace('|html', '')
1115
1115
  .replace('|tag', '')
1116
- .getRegex()
1116
+ .getRegex(),
1117
1117
  };
1118
1118
  /**
1119
1119
  * Inline-Level Grammar
@@ -1207,7 +1207,7 @@ const inlineNormal = {
1207
1207
  reflinkSearch,
1208
1208
  tag,
1209
1209
  text: inlineText,
1210
- url: noopTest
1210
+ url: noopTest,
1211
1211
  };
1212
1212
  /**
1213
1213
  * Pedantic Inline Grammar
@@ -1219,7 +1219,7 @@ const inlinePedantic = {
1219
1219
  .getRegex(),
1220
1220
  reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
1221
1221
  .replace('label', _inlineLabel)
1222
- .getRegex()
1222
+ .getRegex(),
1223
1223
  };
1224
1224
  /**
1225
1225
  * GFM Inline Grammar
@@ -1232,7 +1232,7 @@ const inlineGfm = {
1232
1232
  .getRegex(),
1233
1233
  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
1234
1234
  del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
1235
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
1235
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/,
1236
1236
  };
1237
1237
  /**
1238
1238
  * GFM + Line Breaks Inline Grammar
@@ -1243,7 +1243,7 @@ const inlineBreaks = {
1243
1243
  text: edit(inlineGfm.text)
1244
1244
  .replace('\\b_', '\\b_| {2,}\\n')
1245
1245
  .replace(/\{2,\}/g, '*')
1246
- .getRegex()
1246
+ .getRegex(),
1247
1247
  };
1248
1248
  /**
1249
1249
  * exports
@@ -1251,13 +1251,13 @@ const inlineBreaks = {
1251
1251
  const block = {
1252
1252
  normal: blockNormal,
1253
1253
  gfm: blockGfm,
1254
- pedantic: blockPedantic
1254
+ pedantic: blockPedantic,
1255
1255
  };
1256
1256
  const inline = {
1257
1257
  normal: inlineNormal,
1258
1258
  gfm: inlineGfm,
1259
1259
  breaks: inlineBreaks,
1260
- pedantic: inlinePedantic
1260
+ pedantic: inlinePedantic,
1261
1261
  };
1262
1262
 
1263
1263
  /**
@@ -1282,11 +1282,11 @@ class _Lexer {
1282
1282
  this.state = {
1283
1283
  inLink: false,
1284
1284
  inRawBlock: false,
1285
- top: true
1285
+ top: true,
1286
1286
  };
1287
1287
  const rules = {
1288
1288
  block: block.normal,
1289
- inline: inline.normal
1289
+ inline: inline.normal,
1290
1290
  };
1291
1291
  if (this.options.pedantic) {
1292
1292
  rules.block = block.pedantic;
@@ -1309,7 +1309,7 @@ class _Lexer {
1309
1309
  static get rules() {
1310
1310
  return {
1311
1311
  block,
1312
- inline
1312
+ inline,
1313
1313
  };
1314
1314
  }
1315
1315
  /**
@@ -1441,7 +1441,7 @@ class _Lexer {
1441
1441
  else if (!this.tokens.links[token.tag]) {
1442
1442
  this.tokens.links[token.tag] = {
1443
1443
  href: token.href,
1444
- title: token.title
1444
+ title: token.title,
1445
1445
  };
1446
1446
  }
1447
1447
  continue;
@@ -1757,7 +1757,7 @@ class _Renderer {
1757
1757
  item.tokens.unshift({
1758
1758
  type: 'text',
1759
1759
  raw: checkbox + ' ',
1760
- text: checkbox + ' '
1760
+ text: checkbox + ' ',
1761
1761
  });
1762
1762
  }
1763
1763
  }
@@ -1993,7 +1993,7 @@ class _Parser {
1993
1993
  type: 'paragraph',
1994
1994
  raw: body,
1995
1995
  text: body,
1996
- tokens: [{ type: 'text', raw: body, text: body }]
1996
+ tokens: [{ type: 'text', raw: body, text: body }],
1997
1997
  });
1998
1998
  }
1999
1999
  else {
@@ -2097,7 +2097,7 @@ class _Hooks {
2097
2097
  static passThroughHooks = new Set([
2098
2098
  'preprocess',
2099
2099
  'postprocess',
2100
- 'processAllTokens'
2100
+ 'processAllTokens',
2101
2101
  ]);
2102
2102
  /**
2103
2103
  * Process markdown before marked
@@ -2252,13 +2252,13 @@ class Marked {
2252
2252
  }
2253
2253
  const rendererProp = prop;
2254
2254
  let rendererFunc = pack.renderer[rendererProp];
2255
+ if (!pack.useNewRenderer) {
2256
+ // TODO: Remove this in next major version
2257
+ rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer);
2258
+ }
2255
2259
  const prevRenderer = renderer[rendererProp];
2256
2260
  // Replace renderer with func to run extension, but fall back if false
2257
2261
  renderer[rendererProp] = (...args) => {
2258
- if (!pack.useNewRenderer) {
2259
- // TODO: Remove this in next major version
2260
- rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer);
2261
- }
2262
2262
  let ret = rendererFunc.apply(renderer, args);
2263
2263
  if (ret === false) {
2264
2264
  ret = prevRenderer.apply(renderer, args);
@@ -2385,7 +2385,7 @@ class Marked {
2385
2385
  text: token.header[j].text,
2386
2386
  tokens: token.header[j].tokens,
2387
2387
  header: true,
2388
- align: token.align[j]
2388
+ align: token.align[j],
2389
2389
  });
2390
2390
  }
2391
2391
  header += this.tablerow({ text: cell });
@@ -2398,7 +2398,7 @@ class Marked {
2398
2398
  text: row[k].text,
2399
2399
  tokens: row[k].tokens,
2400
2400
  header: false,
2401
- align: token.align[k]
2401
+ align: token.align[k],
2402
2402
  });
2403
2403
  }
2404
2404
  body += this.tablerow({ text: cell });
@@ -2443,7 +2443,7 @@ class Marked {
2443
2443
  else {
2444
2444
  item.tokens.unshift({
2445
2445
  type: 'text',
2446
- text: checkbox + ' '
2446
+ text: checkbox + ' ',
2447
2447
  });
2448
2448
  }
2449
2449
  }
@@ -2459,7 +2459,7 @@ class Marked {
2459
2459
  task,
2460
2460
  checked: !!checked,
2461
2461
  loose,
2462
- tokens: item.tokens
2462
+ tokens: item.tokens,
2463
2463
  });
2464
2464
  }
2465
2465
  return func.call(this, body, ordered, start);