marked 14.1.0 → 14.1.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 +27 -22
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.esm.js +27 -22
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +27 -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.2 - 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;
|
|
@@ -443,13 +443,19 @@ class _Tokenizer {
|
|
|
443
443
|
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
444
444
|
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
|
|
445
445
|
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
|
|
446
|
+
const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, 'i');
|
|
446
447
|
// Check if following lines should be included in List Item
|
|
447
448
|
while (src) {
|
|
448
449
|
const rawLine = src.split('\n', 1)[0];
|
|
450
|
+
let nextLineWithoutTabs;
|
|
449
451
|
nextLine = rawLine;
|
|
450
452
|
// Re-align to follow commonmark nesting rules
|
|
451
453
|
if (this.options.pedantic) {
|
|
452
454
|
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
|
|
455
|
+
nextLineWithoutTabs = nextLine;
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
nextLineWithoutTabs = nextLine.replace(/\t/g, ' ');
|
|
453
459
|
}
|
|
454
460
|
// End list item if found code fences
|
|
455
461
|
if (fencesBeginRegex.test(nextLine)) {
|
|
@@ -459,16 +465,20 @@ class _Tokenizer {
|
|
|
459
465
|
if (headingBeginRegex.test(nextLine)) {
|
|
460
466
|
break;
|
|
461
467
|
}
|
|
468
|
+
// End list item if found start of html block
|
|
469
|
+
if (htmlBeginRegex.test(nextLine)) {
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
462
472
|
// End list item if found start of new bullet
|
|
463
473
|
if (nextBulletRegex.test(nextLine)) {
|
|
464
474
|
break;
|
|
465
475
|
}
|
|
466
476
|
// Horizontal rule found
|
|
467
|
-
if (hrRegex.test(
|
|
477
|
+
if (hrRegex.test(nextLine)) {
|
|
468
478
|
break;
|
|
469
479
|
}
|
|
470
|
-
if (
|
|
471
|
-
itemContents += '\n' +
|
|
480
|
+
if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible
|
|
481
|
+
itemContents += '\n' + nextLineWithoutTabs.slice(indent);
|
|
472
482
|
}
|
|
473
483
|
else {
|
|
474
484
|
// not enough indentation
|
|
@@ -476,7 +486,7 @@ class _Tokenizer {
|
|
|
476
486
|
break;
|
|
477
487
|
}
|
|
478
488
|
// paragraph continuation unless last line was a different block level element
|
|
479
|
-
if (line.search(/[^ ]/) >= 4) { // indented code block
|
|
489
|
+
if (line.replace(/\t/g, ' ').search(/[^ ]/) >= 4) { // indented code block
|
|
480
490
|
break;
|
|
481
491
|
}
|
|
482
492
|
if (fencesBeginRegex.test(line)) {
|
|
@@ -495,7 +505,7 @@ class _Tokenizer {
|
|
|
495
505
|
}
|
|
496
506
|
raw += rawLine + '\n';
|
|
497
507
|
src = src.substring(rawLine.length + 1);
|
|
498
|
-
line =
|
|
508
|
+
line = nextLineWithoutTabs.slice(indent);
|
|
499
509
|
}
|
|
500
510
|
}
|
|
501
511
|
if (!list.loose) {
|
|
@@ -503,7 +513,7 @@ class _Tokenizer {
|
|
|
503
513
|
if (endsWithBlankLine) {
|
|
504
514
|
list.loose = true;
|
|
505
515
|
}
|
|
506
|
-
else if (/\n *\n *$/.test(raw)) {
|
|
516
|
+
else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
|
|
507
517
|
endsWithBlankLine = true;
|
|
508
518
|
}
|
|
509
519
|
}
|
|
@@ -965,15 +975,15 @@ class _Tokenizer {
|
|
|
965
975
|
/**
|
|
966
976
|
* Block-Level Grammar
|
|
967
977
|
*/
|
|
968
|
-
const newline = /^(?: *(?:\n|$))+/;
|
|
969
|
-
const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
|
|
978
|
+
const newline = /^(?:[ \t]*(?:\n|$))+/;
|
|
979
|
+
const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
970
980
|
const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
971
981
|
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
972
982
|
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
973
983
|
const bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
974
984
|
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
|
|
975
985
|
.replace(/bull/g, bullet) // lists can interrupt
|
|
976
|
-
.replace(/blockCode/g, / {4}/) // indented code blocks can interrupt
|
|
986
|
+
.replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
|
|
977
987
|
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
|
|
978
988
|
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
|
|
979
989
|
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
|
|
@@ -982,7 +992,7 @@ const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|
|
|
|
982
992
|
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
983
993
|
const blockText = /^[^\n]+/;
|
|
984
994
|
const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
985
|
-
const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/)
|
|
995
|
+
const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/)
|
|
986
996
|
.replace('label', _blockLabel)
|
|
987
997
|
.replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/)
|
|
988
998
|
.getRegex();
|
|
@@ -1002,9 +1012,9 @@ const html = edit('^ {0,3}(?:' // optional indentation
|
|
|
1002
1012
|
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
1003
1013
|
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
1004
1014
|
+ '|<!\\[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
|
|
1015
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
|
|
1016
|
+
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
|
|
1017
|
+
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
|
|
1008
1018
|
+ ')', 'i')
|
|
1009
1019
|
.replace('comment', _comment)
|
|
1010
1020
|
.replace('tag', _tag)
|
|
@@ -1051,7 +1061,7 @@ const gfmTable = edit('^ *([^\\n ].*)\\n' // Header
|
|
|
1051
1061
|
.replace('hr', hr)
|
|
1052
1062
|
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
|
1053
1063
|
.replace('blockquote', ' {0,3}>')
|
|
1054
|
-
.replace('code', ' {4}[^\\n]')
|
|
1064
|
+
.replace('code', '(?: {4}| {0,3}\t)[^\\n]')
|
|
1055
1065
|
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
1056
1066
|
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
1057
1067
|
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
@@ -1331,11 +1341,6 @@ class _Lexer {
|
|
|
1331
1341
|
if (this.options.pedantic) {
|
|
1332
1342
|
src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
|
|
1333
1343
|
}
|
|
1334
|
-
else {
|
|
1335
|
-
src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
|
|
1336
|
-
return leading + ' '.repeat(tabs.length);
|
|
1337
|
-
});
|
|
1338
|
-
}
|
|
1339
1344
|
let token;
|
|
1340
1345
|
let lastToken;
|
|
1341
1346
|
let cutSrc;
|