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