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/bin/main.js CHANGED
@@ -28,13 +28,12 @@ export async function main(nodeProcess) {
28
28
  const options = {
29
29
  cwd: nodeProcess.cwd(),
30
30
  env: nodeProcess.env,
31
- stdio: 'inherit'
31
+ stdio: 'inherit',
32
32
  };
33
33
 
34
34
  const __dirname = dirname(fileURLToPath(import.meta.url));
35
35
  const helpText = await readFile(resolve(__dirname, '../man/marked.1.md'), 'utf8');
36
36
 
37
- // eslint-disable-next-line promise/param-names
38
37
  await new Promise(res => {
39
38
  spawn('man', [resolve(__dirname, '../man/marked.1')], options)
40
39
  .on('error', () => {
@@ -128,7 +127,7 @@ export async function main(nodeProcess) {
128
127
  default:
129
128
  if (arg.indexOf('--') === 0) {
130
129
  opt = camelize(arg.replace(/^--(no-)?/, ''));
131
- if (!marked.defaults.hasOwnProperty(opt)) {
130
+ if (!(opt in marked.defaults)) {
132
131
  continue;
133
132
  }
134
133
  if (arg.indexOf('--no-') === 0) {
@@ -205,7 +204,7 @@ export async function main(nodeProcess) {
205
204
  const defaultConfig = [
206
205
  '~/.marked.json',
207
206
  '~/.marked.js',
208
- '~/.marked/index.js'
207
+ '~/.marked/index.js',
209
208
  ];
210
209
 
211
210
  for (const configFile of defaultConfig) {
package/lib/marked.cjs 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
  */
@@ -25,7 +25,7 @@ function _getDefaults() {
25
25
  renderer: null,
26
26
  silent: false,
27
27
  tokenizer: null,
28
- walkTokens: null
28
+ walkTokens: null,
29
29
  };
30
30
  }
31
31
  exports.defaults = _getDefaults();
@@ -45,7 +45,7 @@ const escapeReplacements = {
45
45
  '<': '&lt;',
46
46
  '>': '&gt;',
47
47
  '"': '&quot;',
48
- "'": '&#39;'
48
+ "'": '&#39;',
49
49
  };
50
50
  const getEscapeReplacement = (ch) => escapeReplacements[ch];
51
51
  function escape$1(html, encode) {
@@ -89,7 +89,7 @@ function edit(regex, opt) {
89
89
  },
90
90
  getRegex: () => {
91
91
  return new RegExp(source, opt);
92
- }
92
+ },
93
93
  };
94
94
  return obj;
95
95
  }
@@ -97,7 +97,7 @@ function cleanUrl(href) {
97
97
  try {
98
98
  href = encodeURI(href).replace(/%25/g, '%');
99
99
  }
100
- catch (e) {
100
+ catch {
101
101
  return null;
102
102
  }
103
103
  return href;
@@ -208,7 +208,7 @@ function outputLink(cap, link, raw, lexer) {
208
208
  href,
209
209
  title,
210
210
  text,
211
- tokens: lexer.inlineTokens(text)
211
+ tokens: lexer.inlineTokens(text),
212
212
  };
213
213
  lexer.state.inLink = false;
214
214
  return token;
@@ -218,7 +218,7 @@ function outputLink(cap, link, raw, lexer) {
218
218
  raw,
219
219
  href,
220
220
  title,
221
- text: escape$1(text)
221
+ text: escape$1(text),
222
222
  };
223
223
  }
224
224
  function indentCodeCompensation(raw, text) {
@@ -257,7 +257,7 @@ class _Tokenizer {
257
257
  if (cap && cap[0].length > 0) {
258
258
  return {
259
259
  type: 'space',
260
- raw: cap[0]
260
+ raw: cap[0],
261
261
  };
262
262
  }
263
263
  }
@@ -271,7 +271,7 @@ class _Tokenizer {
271
271
  codeBlockStyle: 'indented',
272
272
  text: !this.options.pedantic
273
273
  ? rtrim(text, '\n')
274
- : text
274
+ : text,
275
275
  };
276
276
  }
277
277
  }
@@ -284,7 +284,7 @@ class _Tokenizer {
284
284
  type: 'code',
285
285
  raw,
286
286
  lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
287
- text
287
+ text,
288
288
  };
289
289
  }
290
290
  }
@@ -308,7 +308,7 @@ class _Tokenizer {
308
308
  raw: cap[0],
309
309
  depth: cap[1].length,
310
310
  text,
311
- tokens: this.lexer.inline(text)
311
+ tokens: this.lexer.inline(text),
312
312
  };
313
313
  }
314
314
  }
@@ -317,7 +317,7 @@ class _Tokenizer {
317
317
  if (cap) {
318
318
  return {
319
319
  type: 'hr',
320
- raw: rtrim(cap[0], '\n')
320
+ raw: rtrim(cap[0], '\n'),
321
321
  };
322
322
  }
323
323
  }
@@ -394,7 +394,7 @@ class _Tokenizer {
394
394
  type: 'blockquote',
395
395
  raw,
396
396
  tokens,
397
- text
397
+ text,
398
398
  };
399
399
  }
400
400
  }
@@ -409,7 +409,7 @@ class _Tokenizer {
409
409
  ordered: isordered,
410
410
  start: isordered ? +bull.slice(0, -1) : '',
411
411
  loose: false,
412
- items: []
412
+ items: [],
413
413
  };
414
414
  bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
415
415
  if (this.options.pedantic) {
@@ -539,7 +539,7 @@ class _Tokenizer {
539
539
  checked: ischecked,
540
540
  loose: false,
541
541
  text: itemContents,
542
- tokens: []
542
+ tokens: [],
543
543
  });
544
544
  list.raw += raw;
545
545
  }
@@ -575,7 +575,7 @@ class _Tokenizer {
575
575
  block: true,
576
576
  raw: cap[0],
577
577
  pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
578
- text: cap[0]
578
+ text: cap[0],
579
579
  };
580
580
  return token;
581
581
  }
@@ -591,7 +591,7 @@ class _Tokenizer {
591
591
  tag,
592
592
  raw: cap[0],
593
593
  href,
594
- title
594
+ title,
595
595
  };
596
596
  }
597
597
  }
@@ -612,7 +612,7 @@ class _Tokenizer {
612
612
  raw: cap[0],
613
613
  header: [],
614
614
  align: [],
615
- rows: []
615
+ rows: [],
616
616
  };
617
617
  if (headers.length !== aligns.length) {
618
618
  // header and align columns must be equal, rows can be different.
@@ -637,7 +637,7 @@ class _Tokenizer {
637
637
  text: headers[i],
638
638
  tokens: this.lexer.inline(headers[i]),
639
639
  header: true,
640
- align: item.align[i]
640
+ align: item.align[i],
641
641
  });
642
642
  }
643
643
  for (const row of rows) {
@@ -646,7 +646,7 @@ class _Tokenizer {
646
646
  text: cell,
647
647
  tokens: this.lexer.inline(cell),
648
648
  header: false,
649
- align: item.align[i]
649
+ align: item.align[i],
650
650
  };
651
651
  }));
652
652
  }
@@ -660,7 +660,7 @@ class _Tokenizer {
660
660
  raw: cap[0],
661
661
  depth: cap[2].charAt(0) === '=' ? 1 : 2,
662
662
  text: cap[1],
663
- tokens: this.lexer.inline(cap[1])
663
+ tokens: this.lexer.inline(cap[1]),
664
664
  };
665
665
  }
666
666
  }
@@ -674,7 +674,7 @@ class _Tokenizer {
674
674
  type: 'paragraph',
675
675
  raw: cap[0],
676
676
  text,
677
- tokens: this.lexer.inline(text)
677
+ tokens: this.lexer.inline(text),
678
678
  };
679
679
  }
680
680
  }
@@ -685,7 +685,7 @@ class _Tokenizer {
685
685
  type: 'text',
686
686
  raw: cap[0],
687
687
  text: cap[0],
688
- tokens: this.lexer.inline(cap[0])
688
+ tokens: this.lexer.inline(cap[0]),
689
689
  };
690
690
  }
691
691
  }
@@ -695,7 +695,7 @@ class _Tokenizer {
695
695
  return {
696
696
  type: 'escape',
697
697
  raw: cap[0],
698
- text: escape$1(cap[1])
698
+ text: escape$1(cap[1]),
699
699
  };
700
700
  }
701
701
  }
@@ -720,7 +720,7 @@ class _Tokenizer {
720
720
  inLink: this.lexer.state.inLink,
721
721
  inRawBlock: this.lexer.state.inRawBlock,
722
722
  block: false,
723
- text: cap[0]
723
+ text: cap[0],
724
724
  };
725
725
  }
726
726
  }
@@ -775,7 +775,7 @@ class _Tokenizer {
775
775
  }
776
776
  return outputLink(cap, {
777
777
  href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
778
- title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
778
+ title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title,
779
779
  }, cap[0], this.lexer);
780
780
  }
781
781
  }
@@ -790,7 +790,7 @@ class _Tokenizer {
790
790
  return {
791
791
  type: 'text',
792
792
  raw: text,
793
- text
793
+ text,
794
794
  };
795
795
  }
796
796
  return outputLink(cap, link, cap[0], this.lexer);
@@ -842,7 +842,7 @@ class _Tokenizer {
842
842
  type: 'em',
843
843
  raw,
844
844
  text,
845
- tokens: this.lexer.inlineTokens(text)
845
+ tokens: this.lexer.inlineTokens(text),
846
846
  };
847
847
  }
848
848
  // Create 'strong' if smallest delimiter has even char count. **a***
@@ -851,7 +851,7 @@ class _Tokenizer {
851
851
  type: 'strong',
852
852
  raw,
853
853
  text,
854
- tokens: this.lexer.inlineTokens(text)
854
+ tokens: this.lexer.inlineTokens(text),
855
855
  };
856
856
  }
857
857
  }
@@ -869,7 +869,7 @@ class _Tokenizer {
869
869
  return {
870
870
  type: 'codespan',
871
871
  raw: cap[0],
872
- text
872
+ text,
873
873
  };
874
874
  }
875
875
  }
@@ -878,7 +878,7 @@ class _Tokenizer {
878
878
  if (cap) {
879
879
  return {
880
880
  type: 'br',
881
- raw: cap[0]
881
+ raw: cap[0],
882
882
  };
883
883
  }
884
884
  }
@@ -889,7 +889,7 @@ class _Tokenizer {
889
889
  type: 'del',
890
890
  raw: cap[0],
891
891
  text: cap[2],
892
- tokens: this.lexer.inlineTokens(cap[2])
892
+ tokens: this.lexer.inlineTokens(cap[2]),
893
893
  };
894
894
  }
895
895
  }
@@ -914,9 +914,9 @@ class _Tokenizer {
914
914
  {
915
915
  type: 'text',
916
916
  raw: text,
917
- text
918
- }
919
- ]
917
+ text,
918
+ },
919
+ ],
920
920
  };
921
921
  }
922
922
  }
@@ -952,9 +952,9 @@ class _Tokenizer {
952
952
  {
953
953
  type: 'text',
954
954
  raw: text,
955
- text
956
- }
957
- ]
955
+ text,
956
+ },
957
+ ],
958
958
  };
959
959
  }
960
960
  }
@@ -971,7 +971,7 @@ class _Tokenizer {
971
971
  return {
972
972
  type: 'text',
973
973
  raw: cap[0],
974
- text
974
+ text,
975
975
  };
976
976
  }
977
977
  }
@@ -1055,7 +1055,7 @@ const blockNormal = {
1055
1055
  newline,
1056
1056
  paragraph,
1057
1057
  table: noopTest,
1058
- text: blockText
1058
+ text: blockText,
1059
1059
  };
1060
1060
  /**
1061
1061
  * GFM Block Grammar
@@ -1085,7 +1085,7 @@ const blockGfm = {
1085
1085
  .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1086
1086
  .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
1087
1087
  .replace('tag', _tag) // pars can be interrupted by type (6) html blocks
1088
- .getRegex()
1088
+ .getRegex(),
1089
1089
  };
1090
1090
  /**
1091
1091
  * Pedantic grammar (original John Gruber's loose markdown specification)
@@ -1115,7 +1115,7 @@ const blockPedantic = {
1115
1115
  .replace('|list', '')
1116
1116
  .replace('|html', '')
1117
1117
  .replace('|tag', '')
1118
- .getRegex()
1118
+ .getRegex(),
1119
1119
  };
1120
1120
  /**
1121
1121
  * Inline-Level Grammar
@@ -1209,7 +1209,7 @@ const inlineNormal = {
1209
1209
  reflinkSearch,
1210
1210
  tag,
1211
1211
  text: inlineText,
1212
- url: noopTest
1212
+ url: noopTest,
1213
1213
  };
1214
1214
  /**
1215
1215
  * Pedantic Inline Grammar
@@ -1221,7 +1221,7 @@ const inlinePedantic = {
1221
1221
  .getRegex(),
1222
1222
  reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
1223
1223
  .replace('label', _inlineLabel)
1224
- .getRegex()
1224
+ .getRegex(),
1225
1225
  };
1226
1226
  /**
1227
1227
  * GFM Inline Grammar
@@ -1234,7 +1234,7 @@ const inlineGfm = {
1234
1234
  .getRegex(),
1235
1235
  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
1236
1236
  del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
1237
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
1237
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/,
1238
1238
  };
1239
1239
  /**
1240
1240
  * GFM + Line Breaks Inline Grammar
@@ -1245,7 +1245,7 @@ const inlineBreaks = {
1245
1245
  text: edit(inlineGfm.text)
1246
1246
  .replace('\\b_', '\\b_| {2,}\\n')
1247
1247
  .replace(/\{2,\}/g, '*')
1248
- .getRegex()
1248
+ .getRegex(),
1249
1249
  };
1250
1250
  /**
1251
1251
  * exports
@@ -1253,13 +1253,13 @@ const inlineBreaks = {
1253
1253
  const block = {
1254
1254
  normal: blockNormal,
1255
1255
  gfm: blockGfm,
1256
- pedantic: blockPedantic
1256
+ pedantic: blockPedantic,
1257
1257
  };
1258
1258
  const inline = {
1259
1259
  normal: inlineNormal,
1260
1260
  gfm: inlineGfm,
1261
1261
  breaks: inlineBreaks,
1262
- pedantic: inlinePedantic
1262
+ pedantic: inlinePedantic,
1263
1263
  };
1264
1264
 
1265
1265
  /**
@@ -1284,11 +1284,11 @@ class _Lexer {
1284
1284
  this.state = {
1285
1285
  inLink: false,
1286
1286
  inRawBlock: false,
1287
- top: true
1287
+ top: true,
1288
1288
  };
1289
1289
  const rules = {
1290
1290
  block: block.normal,
1291
- inline: inline.normal
1291
+ inline: inline.normal,
1292
1292
  };
1293
1293
  if (this.options.pedantic) {
1294
1294
  rules.block = block.pedantic;
@@ -1311,7 +1311,7 @@ class _Lexer {
1311
1311
  static get rules() {
1312
1312
  return {
1313
1313
  block,
1314
- inline
1314
+ inline,
1315
1315
  };
1316
1316
  }
1317
1317
  /**
@@ -1443,7 +1443,7 @@ class _Lexer {
1443
1443
  else if (!this.tokens.links[token.tag]) {
1444
1444
  this.tokens.links[token.tag] = {
1445
1445
  href: token.href,
1446
- title: token.title
1446
+ title: token.title,
1447
1447
  };
1448
1448
  }
1449
1449
  continue;
@@ -1759,7 +1759,7 @@ class _Renderer {
1759
1759
  item.tokens.unshift({
1760
1760
  type: 'text',
1761
1761
  raw: checkbox + ' ',
1762
- text: checkbox + ' '
1762
+ text: checkbox + ' ',
1763
1763
  });
1764
1764
  }
1765
1765
  }
@@ -1995,7 +1995,7 @@ class _Parser {
1995
1995
  type: 'paragraph',
1996
1996
  raw: body,
1997
1997
  text: body,
1998
- tokens: [{ type: 'text', raw: body, text: body }]
1998
+ tokens: [{ type: 'text', raw: body, text: body }],
1999
1999
  });
2000
2000
  }
2001
2001
  else {
@@ -2099,7 +2099,7 @@ class _Hooks {
2099
2099
  static passThroughHooks = new Set([
2100
2100
  'preprocess',
2101
2101
  'postprocess',
2102
- 'processAllTokens'
2102
+ 'processAllTokens',
2103
2103
  ]);
2104
2104
  /**
2105
2105
  * Process markdown before marked
@@ -2254,13 +2254,13 @@ class Marked {
2254
2254
  }
2255
2255
  const rendererProp = prop;
2256
2256
  let rendererFunc = pack.renderer[rendererProp];
2257
+ if (!pack.useNewRenderer) {
2258
+ // TODO: Remove this in next major version
2259
+ rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer);
2260
+ }
2257
2261
  const prevRenderer = renderer[rendererProp];
2258
2262
  // Replace renderer with func to run extension, but fall back if false
2259
2263
  renderer[rendererProp] = (...args) => {
2260
- if (!pack.useNewRenderer) {
2261
- // TODO: Remove this in next major version
2262
- rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer);
2263
- }
2264
2264
  let ret = rendererFunc.apply(renderer, args);
2265
2265
  if (ret === false) {
2266
2266
  ret = prevRenderer.apply(renderer, args);
@@ -2387,7 +2387,7 @@ class Marked {
2387
2387
  text: token.header[j].text,
2388
2388
  tokens: token.header[j].tokens,
2389
2389
  header: true,
2390
- align: token.align[j]
2390
+ align: token.align[j],
2391
2391
  });
2392
2392
  }
2393
2393
  header += this.tablerow({ text: cell });
@@ -2400,7 +2400,7 @@ class Marked {
2400
2400
  text: row[k].text,
2401
2401
  tokens: row[k].tokens,
2402
2402
  header: false,
2403
- align: token.align[k]
2403
+ align: token.align[k],
2404
2404
  });
2405
2405
  }
2406
2406
  body += this.tablerow({ text: cell });
@@ -2445,7 +2445,7 @@ class Marked {
2445
2445
  else {
2446
2446
  item.tokens.unshift({
2447
2447
  type: 'text',
2448
- text: checkbox + ' '
2448
+ text: checkbox + ' ',
2449
2449
  });
2450
2450
  }
2451
2451
  }
@@ -2461,7 +2461,7 @@ class Marked {
2461
2461
  task,
2462
2462
  checked: !!checked,
2463
2463
  loose,
2464
- tokens: item.tokens
2464
+ tokens: item.tokens,
2465
2465
  });
2466
2466
  }
2467
2467
  return func.call(this, body, ordered, start);