marked 15.0.2 → 15.0.4

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 v15.0.2 - a markdown parser
2
+ * marked v15.0.4 - a markdown parser
3
3
  * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -253,35 +253,41 @@ const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
253
253
  const br = /^( {2,}|\\)\n(?!\s*$)/;
254
254
  const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
255
255
  // list of unicode punctuation marks, plus any missing characters from CommonMark spec
256
- const _punctuation = /\p{P}\p{S}/u;
257
- const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u')
258
- .replace(/punctuation/g, _punctuation).getRegex();
256
+ const _punctuation = /[\p{P}\p{S}]/u;
257
+ const _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
258
+ const _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
259
+ const punctuation = edit(/^((?![*_])punctSpace)/, 'u')
260
+ .replace(/punctSpace/g, _punctuationOrSpace).getRegex();
259
261
  // sequences em should skip over [title](link), `code`, <html>
260
262
  const blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
261
- const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u')
263
+ const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, 'u')
262
264
  .replace(/punct/g, _punctuation)
263
265
  .getRegex();
264
266
  const emStrongRDelimAst = edit('^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
265
267
  + '|[^*]+(?=[^*])' // Consume to delim
266
- + '|(?!\\*)[punct](\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
267
- + '|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)' // (2) a***#, a*** can only be a Right Delimiter
268
- + '|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])' // (3) #***a, ***a can only be Left Delimiter
269
- + '|[\\s](\\*+)(?!\\*)(?=[punct])' // (4) ***# can only be Left Delimiter
270
- + '|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])' // (5) #***# can be either Left or Right Delimiter
271
- + '|[^punct\\s](\\*+)(?=[^punct\\s])', 'gu') // (6) a***a can be either Left or Right Delimiter
268
+ + '|(?!\\*)punct(\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
269
+ + '|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)' // (2) a***#, a*** can only be a Right Delimiter
270
+ + '|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)' // (3) #***a, ***a can only be Left Delimiter
271
+ + '|[\\s](\\*+)(?!\\*)(?=punct)' // (4) ***# can only be Left Delimiter
272
+ + '|(?!\\*)punct(\\*+)(?!\\*)(?=punct)' // (5) #***# can be either Left or Right Delimiter
273
+ + '|notPunctSpace(\\*+)(?=notPunctSpace)', 'gu') // (6) a***a can be either Left or Right Delimiter
274
+ .replace(/notPunctSpace/g, _notPunctuationOrSpace)
275
+ .replace(/punctSpace/g, _punctuationOrSpace)
272
276
  .replace(/punct/g, _punctuation)
273
277
  .getRegex();
274
278
  // (6) Not allowed for _
275
279
  const emStrongRDelimUnd = edit('^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong
276
280
  + '|[^_]+(?=[^_])' // Consume to delim
277
- + '|(?!_)[punct](_+)(?=[\\s]|$)' // (1) #___ can only be a Right Delimiter
278
- + '|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)' // (2) a___#, a___ can only be a Right Delimiter
279
- + '|(?!_)[punct\\s](_+)(?=[^punct\\s])' // (3) #___a, ___a can only be Left Delimiter
280
- + '|[\\s](_+)(?!_)(?=[punct])' // (4) ___# can only be Left Delimiter
281
- + '|(?!_)[punct](_+)(?!_)(?=[punct])', 'gu') // (5) #___# can be either Left or Right Delimiter
281
+ + '|(?!_)punct(_+)(?=[\\s]|$)' // (1) #___ can only be a Right Delimiter
282
+ + '|notPunctSpace(_+)(?!_)(?=punctSpace|$)' // (2) a___#, a___ can only be a Right Delimiter
283
+ + '|(?!_)punctSpace(_+)(?=notPunctSpace)' // (3) #___a, ___a can only be Left Delimiter
284
+ + '|[\\s](_+)(?!_)(?=punct)' // (4) ___# can only be Left Delimiter
285
+ + '|(?!_)punct(_+)(?!_)(?=punct)', 'gu') // (5) #___# can be either Left or Right Delimiter
286
+ .replace(/notPunctSpace/g, _notPunctuationOrSpace)
287
+ .replace(/punctSpace/g, _punctuationOrSpace)
282
288
  .replace(/punct/g, _punctuation)
283
289
  .getRegex();
284
- const anyPunctuation = edit(/\\([punct])/, 'gu')
290
+ const anyPunctuation = edit(/\\(punct)/, 'gu')
285
291
  .replace(/punct/g, _punctuation)
286
292
  .getRegex();
287
293
  const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/)
@@ -879,6 +885,10 @@ class _Tokenizer {
879
885
  lastItem.raw = lastItem.raw.trimEnd();
880
886
  lastItem.text = lastItem.text.trimEnd();
881
887
  }
888
+ else {
889
+ // not a list since there were no items
890
+ return;
891
+ }
882
892
  list.raw = list.raw.trimEnd();
883
893
  // Item child tokens handled here at end because we needed to have the final item to trim it first
884
894
  for (let i = 0; i < list.items.length; i++) {