marked 13.0.0 → 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 +25 -22
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.cts +5 -5
- package/lib/marked.d.ts +5 -5
- package/lib/marked.esm.js +25 -22
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +25 -22
- package/lib/marked.umd.js.map +1 -1
- package/man/marked.1 +1 -1
- package/marked.min.js +2 -2
- package/package.json +11 -8
package/lib/marked.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* marked v13.0.
|
|
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
|
-
|
|
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
|
-
|
|
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++) {
|
|
@@ -2358,7 +2361,7 @@ class Marked {
|
|
|
2358
2361
|
// eslint-disable-next-line prefer-rest-params
|
|
2359
2362
|
return func.apply(this, arguments);
|
|
2360
2363
|
}
|
|
2361
|
-
return func(renderer.parser.parseInline(token.tokens), token.depth, unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer)));
|
|
2364
|
+
return func.call(this, renderer.parser.parseInline(token.tokens), token.depth, unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer)));
|
|
2362
2365
|
};
|
|
2363
2366
|
case 'code':
|
|
2364
2367
|
return function (token) {
|
|
@@ -2367,7 +2370,7 @@ class Marked {
|
|
|
2367
2370
|
// eslint-disable-next-line prefer-rest-params
|
|
2368
2371
|
return func.apply(this, arguments);
|
|
2369
2372
|
}
|
|
2370
|
-
return func(token.text, token.lang, !!token.escaped);
|
|
2373
|
+
return func.call(this, token.text, token.lang, !!token.escaped);
|
|
2371
2374
|
};
|
|
2372
2375
|
case 'table':
|
|
2373
2376
|
return function (token) {
|
|
@@ -2402,7 +2405,7 @@ class Marked {
|
|
|
2402
2405
|
}
|
|
2403
2406
|
body += this.tablerow({ text: cell });
|
|
2404
2407
|
}
|
|
2405
|
-
return func(header, body);
|
|
2408
|
+
return func.call(this, header, body);
|
|
2406
2409
|
};
|
|
2407
2410
|
case 'blockquote':
|
|
2408
2411
|
return function (token) {
|
|
@@ -2412,7 +2415,7 @@ class Marked {
|
|
|
2412
2415
|
return func.apply(this, arguments);
|
|
2413
2416
|
}
|
|
2414
2417
|
const body = this.parser.parse(token.tokens);
|
|
2415
|
-
return func(body);
|
|
2418
|
+
return func.call(this, body);
|
|
2416
2419
|
};
|
|
2417
2420
|
case 'list':
|
|
2418
2421
|
return function (token) {
|
|
@@ -2461,7 +2464,7 @@ class Marked {
|
|
|
2461
2464
|
tokens: item.tokens
|
|
2462
2465
|
});
|
|
2463
2466
|
}
|
|
2464
|
-
return func(body, ordered, start);
|
|
2467
|
+
return func.call(this, body, ordered, start);
|
|
2465
2468
|
};
|
|
2466
2469
|
case 'html':
|
|
2467
2470
|
return function (token) {
|
|
@@ -2470,7 +2473,7 @@ class Marked {
|
|
|
2470
2473
|
// eslint-disable-next-line prefer-rest-params
|
|
2471
2474
|
return func.apply(this, arguments);
|
|
2472
2475
|
}
|
|
2473
|
-
return func(token.text, token.block);
|
|
2476
|
+
return func.call(this, token.text, token.block);
|
|
2474
2477
|
};
|
|
2475
2478
|
case 'paragraph':
|
|
2476
2479
|
return function (token) {
|
|
@@ -2479,7 +2482,7 @@ class Marked {
|
|
|
2479
2482
|
// eslint-disable-next-line prefer-rest-params
|
|
2480
2483
|
return func.apply(this, arguments);
|
|
2481
2484
|
}
|
|
2482
|
-
return func(this.parser.parseInline(token.tokens));
|
|
2485
|
+
return func.call(this, this.parser.parseInline(token.tokens));
|
|
2483
2486
|
};
|
|
2484
2487
|
case 'escape':
|
|
2485
2488
|
return function (token) {
|
|
@@ -2488,7 +2491,7 @@ class Marked {
|
|
|
2488
2491
|
// eslint-disable-next-line prefer-rest-params
|
|
2489
2492
|
return func.apply(this, arguments);
|
|
2490
2493
|
}
|
|
2491
|
-
return func(token.text);
|
|
2494
|
+
return func.call(this, token.text);
|
|
2492
2495
|
};
|
|
2493
2496
|
case 'link':
|
|
2494
2497
|
return function (token) {
|
|
@@ -2497,7 +2500,7 @@ class Marked {
|
|
|
2497
2500
|
// eslint-disable-next-line prefer-rest-params
|
|
2498
2501
|
return func.apply(this, arguments);
|
|
2499
2502
|
}
|
|
2500
|
-
return func(token.href, token.title, this.parser.parseInline(token.tokens));
|
|
2503
|
+
return func.call(this, token.href, token.title, this.parser.parseInline(token.tokens));
|
|
2501
2504
|
};
|
|
2502
2505
|
case 'image':
|
|
2503
2506
|
return function (token) {
|
|
@@ -2506,7 +2509,7 @@ class Marked {
|
|
|
2506
2509
|
// eslint-disable-next-line prefer-rest-params
|
|
2507
2510
|
return func.apply(this, arguments);
|
|
2508
2511
|
}
|
|
2509
|
-
return func(token.href, token.title, token.text);
|
|
2512
|
+
return func.call(this, token.href, token.title, token.text);
|
|
2510
2513
|
};
|
|
2511
2514
|
case 'strong':
|
|
2512
2515
|
return function (token) {
|
|
@@ -2515,7 +2518,7 @@ class Marked {
|
|
|
2515
2518
|
// eslint-disable-next-line prefer-rest-params
|
|
2516
2519
|
return func.apply(this, arguments);
|
|
2517
2520
|
}
|
|
2518
|
-
return func(this.parser.parseInline(token.tokens));
|
|
2521
|
+
return func.call(this, this.parser.parseInline(token.tokens));
|
|
2519
2522
|
};
|
|
2520
2523
|
case 'em':
|
|
2521
2524
|
return function (token) {
|
|
@@ -2524,7 +2527,7 @@ class Marked {
|
|
|
2524
2527
|
// eslint-disable-next-line prefer-rest-params
|
|
2525
2528
|
return func.apply(this, arguments);
|
|
2526
2529
|
}
|
|
2527
|
-
return func(this.parser.parseInline(token.tokens));
|
|
2530
|
+
return func.call(this, this.parser.parseInline(token.tokens));
|
|
2528
2531
|
};
|
|
2529
2532
|
case 'codespan':
|
|
2530
2533
|
return function (token) {
|
|
@@ -2533,7 +2536,7 @@ class Marked {
|
|
|
2533
2536
|
// eslint-disable-next-line prefer-rest-params
|
|
2534
2537
|
return func.apply(this, arguments);
|
|
2535
2538
|
}
|
|
2536
|
-
return func(token.text);
|
|
2539
|
+
return func.call(this, token.text);
|
|
2537
2540
|
};
|
|
2538
2541
|
case 'del':
|
|
2539
2542
|
return function (token) {
|
|
@@ -2542,7 +2545,7 @@ class Marked {
|
|
|
2542
2545
|
// eslint-disable-next-line prefer-rest-params
|
|
2543
2546
|
return func.apply(this, arguments);
|
|
2544
2547
|
}
|
|
2545
|
-
return func(this.parser.parseInline(token.tokens));
|
|
2548
|
+
return func.call(this, this.parser.parseInline(token.tokens));
|
|
2546
2549
|
};
|
|
2547
2550
|
case 'text':
|
|
2548
2551
|
return function (token) {
|
|
@@ -2551,7 +2554,7 @@ class Marked {
|
|
|
2551
2554
|
// eslint-disable-next-line prefer-rest-params
|
|
2552
2555
|
return func.apply(this, arguments);
|
|
2553
2556
|
}
|
|
2554
|
-
return func(token.text);
|
|
2557
|
+
return func.call(this, token.text);
|
|
2555
2558
|
};
|
|
2556
2559
|
// do nothing
|
|
2557
2560
|
}
|