marked 14.1.0 → 14.1.1

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 v14.1.0 - a markdown parser
2
+ * marked v14.1.1 - a markdown parser
3
3
  * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -247,7 +247,7 @@ class _Tokenizer {
247
247
  code(src) {
248
248
  const cap = this.rules.block.code.exec(src);
249
249
  if (cap) {
250
- const text = cap[0].replace(/^ {1,4}/gm, '');
250
+ const text = cap[0].replace(/^(?: {1,4}| {0,3}\t)/gm, '');
251
251
  return {
252
252
  type: 'code',
253
253
  raw: cap[0],
@@ -431,7 +431,7 @@ class _Tokenizer {
431
431
  itemContents = line.slice(indent);
432
432
  indent += cap[1].length;
433
433
  }
434
- if (blankLine && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
434
+ if (blankLine && /^[ \t]*$/.test(nextLine)) { // Items begin with at most one blank line
435
435
  raw += nextLine + '\n';
436
436
  src = src.substring(nextLine.length + 1);
437
437
  endEarly = true;
@@ -444,10 +444,15 @@ class _Tokenizer {
444
444
  // Check if following lines should be included in List Item
445
445
  while (src) {
446
446
  const rawLine = src.split('\n', 1)[0];
447
+ let nextLineWithoutTabs;
447
448
  nextLine = rawLine;
448
449
  // Re-align to follow commonmark nesting rules
449
450
  if (this.options.pedantic) {
450
451
  nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
452
+ nextLineWithoutTabs = nextLine;
453
+ }
454
+ else {
455
+ nextLineWithoutTabs = nextLine.replace(/\t/g, ' ');
451
456
  }
452
457
  // End list item if found code fences
453
458
  if (fencesBeginRegex.test(nextLine)) {
@@ -462,11 +467,11 @@ class _Tokenizer {
462
467
  break;
463
468
  }
464
469
  // Horizontal rule found
465
- if (hrRegex.test(src)) {
470
+ if (hrRegex.test(nextLine)) {
466
471
  break;
467
472
  }
468
- if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible
469
- itemContents += '\n' + nextLine.slice(indent);
473
+ if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible
474
+ itemContents += '\n' + nextLineWithoutTabs.slice(indent);
470
475
  }
471
476
  else {
472
477
  // not enough indentation
@@ -474,7 +479,7 @@ class _Tokenizer {
474
479
  break;
475
480
  }
476
481
  // paragraph continuation unless last line was a different block level element
477
- if (line.search(/[^ ]/) >= 4) { // indented code block
482
+ if (line.replace(/\t/g, ' ').search(/[^ ]/) >= 4) { // indented code block
478
483
  break;
479
484
  }
480
485
  if (fencesBeginRegex.test(line)) {
@@ -493,7 +498,7 @@ class _Tokenizer {
493
498
  }
494
499
  raw += rawLine + '\n';
495
500
  src = src.substring(rawLine.length + 1);
496
- line = nextLine.slice(indent);
501
+ line = nextLineWithoutTabs.slice(indent);
497
502
  }
498
503
  }
499
504
  if (!list.loose) {
@@ -501,7 +506,7 @@ class _Tokenizer {
501
506
  if (endsWithBlankLine) {
502
507
  list.loose = true;
503
508
  }
504
- else if (/\n *\n *$/.test(raw)) {
509
+ else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
505
510
  endsWithBlankLine = true;
506
511
  }
507
512
  }
@@ -963,15 +968,15 @@ class _Tokenizer {
963
968
  /**
964
969
  * Block-Level Grammar
965
970
  */
966
- const newline = /^(?: *(?:\n|$))+/;
967
- const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
971
+ const newline = /^(?:[ \t]*(?:\n|$))+/;
972
+ const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
968
973
  const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
969
974
  const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
970
975
  const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
971
976
  const bullet = /(?:[*+-]|\d{1,9}[.)])/;
972
977
  const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
973
978
  .replace(/bull/g, bullet) // lists can interrupt
974
- .replace(/blockCode/g, / {4}/) // indented code blocks can interrupt
979
+ .replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
975
980
  .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
976
981
  .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
977
982
  .replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
@@ -980,7 +985,7 @@ const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|
980
985
  const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
981
986
  const blockText = /^[^\n]+/;
982
987
  const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
983
- const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/)
988
+ const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/)
984
989
  .replace('label', _blockLabel)
985
990
  .replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/)
986
991
  .getRegex();
@@ -1000,9 +1005,9 @@ const html = edit('^ {0,3}(?:' // optional indentation
1000
1005
  + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
1001
1006
  + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
1002
1007
  + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
1003
- + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
1004
- + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
1005
- + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
1008
+ + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
1009
+ + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
1010
+ + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
1006
1011
  + ')', 'i')
1007
1012
  .replace('comment', _comment)
1008
1013
  .replace('tag', _tag)
@@ -1049,7 +1054,7 @@ const gfmTable = edit('^ *([^\\n ].*)\\n' // Header
1049
1054
  .replace('hr', hr)
1050
1055
  .replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
1051
1056
  .replace('blockquote', ' {0,3}>')
1052
- .replace('code', ' {4}[^\\n]')
1057
+ .replace('code', '(?: {4}| {0,3}\t)[^\\n]')
1053
1058
  .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
1054
1059
  .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1055
1060
  .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
@@ -1329,11 +1334,6 @@ class _Lexer {
1329
1334
  if (this.options.pedantic) {
1330
1335
  src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
1331
1336
  }
1332
- else {
1333
- src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
1334
- return leading + ' '.repeat(tabs.length);
1335
- });
1336
- }
1337
1337
  let token;
1338
1338
  let lastToken;
1339
1339
  let cutSrc;