marked 13.0.1 → 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 +10 -7
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.cts +2 -2
- package/lib/marked.d.ts +2 -2
- package/lib/marked.esm.js +10 -7
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +10 -7
- 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.d.cts
CHANGED
|
@@ -636,7 +636,7 @@ export declare namespace marked {
|
|
|
636
636
|
var defaults: MarkedOptions;
|
|
637
637
|
var use: (...args: MarkedExtension[]) => typeof marked;
|
|
638
638
|
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
639
|
-
var parseInline: (src: string, options?: MarkedOptions |
|
|
639
|
+
var parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
|
640
640
|
var Parser: typeof _Parser;
|
|
641
641
|
var parser: typeof _Parser.parse;
|
|
642
642
|
var Renderer: typeof _Renderer;
|
|
@@ -651,7 +651,7 @@ export declare const options: (options: MarkedOptions) => typeof marked;
|
|
|
651
651
|
export declare const setOptions: (options: MarkedOptions) => typeof marked;
|
|
652
652
|
export declare const use: (...args: MarkedExtension[]) => typeof marked;
|
|
653
653
|
export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
654
|
-
export declare const parseInline: (src: string, options?: MarkedOptions |
|
|
654
|
+
export declare const parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
|
655
655
|
export declare const parse: typeof marked;
|
|
656
656
|
export declare const parser: typeof _Parser.parse;
|
|
657
657
|
export declare const lexer: typeof _Lexer.lex;
|
package/lib/marked.d.ts
CHANGED
|
@@ -636,7 +636,7 @@ export declare namespace marked {
|
|
|
636
636
|
var defaults: MarkedOptions;
|
|
637
637
|
var use: (...args: MarkedExtension[]) => typeof marked;
|
|
638
638
|
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
639
|
-
var parseInline: (src: string, options?: MarkedOptions |
|
|
639
|
+
var parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
|
640
640
|
var Parser: typeof _Parser;
|
|
641
641
|
var parser: typeof _Parser.parse;
|
|
642
642
|
var Renderer: typeof _Renderer;
|
|
@@ -651,7 +651,7 @@ export declare const options: (options: MarkedOptions) => typeof marked;
|
|
|
651
651
|
export declare const setOptions: (options: MarkedOptions) => typeof marked;
|
|
652
652
|
export declare const use: (...args: MarkedExtension[]) => typeof marked;
|
|
653
653
|
export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
654
|
-
export declare const parseInline: (src: string, options?: MarkedOptions |
|
|
654
|
+
export declare const parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
|
655
655
|
export declare const parse: typeof marked;
|
|
656
656
|
export declare const parser: typeof _Parser.parse;
|
|
657
657
|
export declare const lexer: typeof _Lexer.lex;
|
package/lib/marked.esm.js
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
|
*/
|
|
@@ -415,12 +415,12 @@ class _Tokenizer {
|
|
|
415
415
|
}
|
|
416
416
|
// Get next list item
|
|
417
417
|
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
|
|
418
|
-
let raw = '';
|
|
419
|
-
let itemContents = '';
|
|
420
418
|
let endsWithBlankLine = false;
|
|
421
419
|
// Check if current bullet point can start a new List Item
|
|
422
420
|
while (src) {
|
|
423
421
|
let endEarly = false;
|
|
422
|
+
let raw = '';
|
|
423
|
+
let itemContents = '';
|
|
424
424
|
if (!(cap = itemRegex.exec(src))) {
|
|
425
425
|
break;
|
|
426
426
|
}
|
|
@@ -431,19 +431,22 @@ class _Tokenizer {
|
|
|
431
431
|
src = src.substring(raw.length);
|
|
432
432
|
let line = cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length));
|
|
433
433
|
let nextLine = src.split('\n', 1)[0];
|
|
434
|
+
let blankLine = !line.trim();
|
|
434
435
|
let indent = 0;
|
|
435
436
|
if (this.options.pedantic) {
|
|
436
437
|
indent = 2;
|
|
437
438
|
itemContents = line.trimStart();
|
|
438
439
|
}
|
|
440
|
+
else if (blankLine) {
|
|
441
|
+
indent = cap[1].length + 1;
|
|
442
|
+
}
|
|
439
443
|
else {
|
|
440
444
|
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
441
445
|
indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
|
|
442
446
|
itemContents = line.slice(indent);
|
|
443
447
|
indent += cap[1].length;
|
|
444
448
|
}
|
|
445
|
-
|
|
446
|
-
if (!line && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
|
|
449
|
+
if (blankLine && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
|
|
447
450
|
raw += nextLine + '\n';
|
|
448
451
|
src = src.substring(nextLine.length + 1);
|
|
449
452
|
endEarly = true;
|
|
@@ -539,8 +542,8 @@ class _Tokenizer {
|
|
|
539
542
|
list.raw += raw;
|
|
540
543
|
}
|
|
541
544
|
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
542
|
-
list.items[list.items.length - 1].raw = raw.trimEnd();
|
|
543
|
-
|
|
545
|
+
list.items[list.items.length - 1].raw = list.items[list.items.length - 1].raw.trimEnd();
|
|
546
|
+
list.items[list.items.length - 1].text = list.items[list.items.length - 1].text.trimEnd();
|
|
544
547
|
list.raw = list.raw.trimEnd();
|
|
545
548
|
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
546
549
|
for (let i = 0; i < list.items.length; i++) {
|