marked 15.0.3 → 15.0.5

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,6 +1,6 @@
1
1
  /**
2
- * marked v15.0.3 - a markdown parser
3
- * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
2
+ * marked v15.0.5 - a markdown parser
3
+ * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
6
6
 
@@ -258,23 +258,33 @@ const _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
258
258
  const _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
259
259
  const punctuation = edit(/^((?![*_])punctSpace)/, 'u')
260
260
  .replace(/punctSpace/g, _punctuationOrSpace).getRegex();
261
+ // GFM allows ~ inside strong and em for strikethrough
262
+ const _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
263
+ const _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
264
+ const _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
261
265
  // sequences em should skip over [title](link), `code`, <html>
262
266
  const blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
263
267
  const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, 'u')
264
268
  .replace(/punct/g, _punctuation)
265
269
  .getRegex();
266
- const emStrongRDelimAst = edit('^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
270
+ const emStrongRDelimAstCore = '^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
267
271
  + '|[^*]+(?=[^*])' // Consume to delim
268
272
  + '|(?!\\*)punct(\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
269
273
  + '|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)' // (2) a***#, a*** can only be a Right Delimiter
270
274
  + '|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)' // (3) #***a, ***a can only be Left Delimiter
271
275
  + '|[\\s](\\*+)(?!\\*)(?=punct)' // (4) ***# can only be Left Delimiter
272
276
  + '|(?!\\*)punct(\\*+)(?!\\*)(?=punct)' // (5) #***# can be either Left or Right Delimiter
273
- + '|notPunctSpace(\\*+)(?=notPunctSpace)', 'gu') // (6) a***a can be either Left or Right Delimiter
277
+ + '|notPunctSpace(\\*+)(?=notPunctSpace)'; // (6) a***a can be either Left or Right Delimiter
278
+ const emStrongRDelimAst = edit(emStrongRDelimAstCore, 'gu')
274
279
  .replace(/notPunctSpace/g, _notPunctuationOrSpace)
275
280
  .replace(/punctSpace/g, _punctuationOrSpace)
276
281
  .replace(/punct/g, _punctuation)
277
282
  .getRegex();
283
+ const emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, 'gu')
284
+ .replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm)
285
+ .replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm)
286
+ .replace(/punct/g, _punctuationGfmStrongEm)
287
+ .getRegex();
278
288
  // (6) Not allowed for _
279
289
  const emStrongRDelimUnd = edit('^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong
280
290
  + '|[^_]+(?=[^_])' // Consume to delim
@@ -362,7 +372,7 @@ const inlinePedantic = {
362
372
  */
363
373
  const inlineGfm = {
364
374
  ...inlineNormal,
365
- escape: edit(escape$1).replace('])', '~|])').getRegex(),
375
+ emStrongRDelimAst: emStrongRDelimAstGfm,
366
376
  url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i')
367
377
  .replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
368
378
  .getRegex(),
@@ -491,9 +501,6 @@ function rtrim(str, c, invert) {
491
501
  if (currChar === c && !invert) {
492
502
  suffLen++;
493
503
  }
494
- else if (currChar !== c && invert) {
495
- suffLen++;
496
- }
497
504
  else {
498
505
  break;
499
506
  }
@@ -885,6 +892,10 @@ class _Tokenizer {
885
892
  lastItem.raw = lastItem.raw.trimEnd();
886
893
  lastItem.text = lastItem.text.trimEnd();
887
894
  }
895
+ else {
896
+ // not a list since there were no items
897
+ return;
898
+ }
888
899
  list.raw = list.raw.trimEnd();
889
900
  // Item child tokens handled here at end because we needed to have the final item to trim it first
890
901
  for (let i = 0; i < list.items.length; i++) {