marked 13.0.1 → 13.0.2

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.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v13.0.1 - a markdown parser
2
+ * marked v13.0.2 - a markdown parser
3
3
  * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -417,12 +417,12 @@ class _Tokenizer {
417
417
  }
418
418
  // Get next list item
419
419
  const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
420
- let raw = '';
421
- let itemContents = '';
422
420
  let endsWithBlankLine = false;
423
421
  // Check if current bullet point can start a new List Item
424
422
  while (src) {
425
423
  let endEarly = false;
424
+ let raw = '';
425
+ let itemContents = '';
426
426
  if (!(cap = itemRegex.exec(src))) {
427
427
  break;
428
428
  }
@@ -433,19 +433,22 @@ class _Tokenizer {
433
433
  src = src.substring(raw.length);
434
434
  let line = cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length));
435
435
  let nextLine = src.split('\n', 1)[0];
436
+ let blankLine = !line.trim();
436
437
  let indent = 0;
437
438
  if (this.options.pedantic) {
438
439
  indent = 2;
439
440
  itemContents = line.trimStart();
440
441
  }
442
+ else if (blankLine) {
443
+ indent = cap[1].length + 1;
444
+ }
441
445
  else {
442
446
  indent = cap[2].search(/[^ ]/); // Find first non-space char
443
447
  indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
444
448
  itemContents = line.slice(indent);
445
449
  indent += cap[1].length;
446
450
  }
447
- let blankLine = false;
448
- if (!line && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
451
+ if (blankLine && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
449
452
  raw += nextLine + '\n';
450
453
  src = src.substring(nextLine.length + 1);
451
454
  endEarly = true;
@@ -541,8 +544,8 @@ class _Tokenizer {
541
544
  list.raw += raw;
542
545
  }
543
546
  // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
544
- list.items[list.items.length - 1].raw = raw.trimEnd();
545
- (list.items[list.items.length - 1]).text = itemContents.trimEnd();
547
+ list.items[list.items.length - 1].raw = list.items[list.items.length - 1].raw.trimEnd();
548
+ list.items[list.items.length - 1].text = list.items[list.items.length - 1].text.trimEnd();
546
549
  list.raw = list.raw.trimEnd();
547
550
  // Item child tokens handled here at end because we needed to have the final item to trim it first
548
551
  for (let i = 0; i < list.items.length; i++) {