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