marked 7.0.3 → 7.0.5
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 +140 -106
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.ts +32 -31
- package/lib/marked.esm.js +140 -106
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +140 -106
- package/lib/marked.umd.js.map +1 -1
- package/marked.min.js +3 -3
- package/package.json +6 -6
package/lib/marked.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
declare module "Tokens" {
|
|
2
|
-
export type Token = (Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del | Tokens.Generic)
|
|
3
|
-
loose?: boolean;
|
|
4
|
-
tokens?: Token[];
|
|
5
|
-
};
|
|
2
|
+
export type Token = (Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del | Tokens.Generic);
|
|
6
3
|
export namespace Tokens {
|
|
7
4
|
interface Space {
|
|
8
5
|
type: 'space';
|
|
@@ -32,7 +29,7 @@ declare module "Tokens" {
|
|
|
32
29
|
}
|
|
33
30
|
interface TableCell {
|
|
34
31
|
text: string;
|
|
35
|
-
tokens
|
|
32
|
+
tokens: Token[];
|
|
36
33
|
}
|
|
37
34
|
interface Hr {
|
|
38
35
|
type: 'hr';
|
|
@@ -59,7 +56,7 @@ declare module "Tokens" {
|
|
|
59
56
|
checked?: boolean | undefined;
|
|
60
57
|
loose: boolean;
|
|
61
58
|
text: string;
|
|
62
|
-
tokens
|
|
59
|
+
tokens: Token[];
|
|
63
60
|
}
|
|
64
61
|
interface Paragraph {
|
|
65
62
|
type: 'paragraph';
|
|
@@ -306,6 +303,7 @@ declare module "Instance" {
|
|
|
306
303
|
import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
|
|
307
304
|
import type { Token, TokensList } from "Tokens";
|
|
308
305
|
export type ResultCallback = (error: Error | null, parseResult?: string) => undefined | void;
|
|
306
|
+
export type MaybePromise = void | Promise<void>;
|
|
309
307
|
export class Marked {
|
|
310
308
|
#private;
|
|
311
309
|
defaults: MarkedOptions;
|
|
@@ -325,7 +323,7 @@ declare module "Instance" {
|
|
|
325
323
|
/**
|
|
326
324
|
* Run callback for every token
|
|
327
325
|
*/
|
|
328
|
-
walkTokens
|
|
326
|
+
walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
|
|
329
327
|
use(...args: MarkedExtension[]): this;
|
|
330
328
|
setOptions(opt: MarkedOptions): this;
|
|
331
329
|
}
|
|
@@ -441,11 +439,13 @@ declare module "MarkedOptions" {
|
|
|
441
439
|
export interface TokenizerThis {
|
|
442
440
|
lexer: _Lexer;
|
|
443
441
|
}
|
|
442
|
+
export type TokenizerExtensionFunction = (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
|
|
443
|
+
export type TokenizerStartFunction = (this: TokenizerThis, src: string) => number | void;
|
|
444
444
|
export interface TokenizerExtension {
|
|
445
445
|
name: string;
|
|
446
446
|
level: 'block' | 'inline';
|
|
447
|
-
start?:
|
|
448
|
-
tokenizer:
|
|
447
|
+
start?: TokenizerStartFunction | undefined;
|
|
448
|
+
tokenizer: TokenizerExtensionFunction;
|
|
449
449
|
childTokens?: string[] | undefined;
|
|
450
450
|
}
|
|
451
451
|
export interface RendererThis {
|
|
@@ -575,35 +575,36 @@ declare module "MarkedOptions" {
|
|
|
575
575
|
*/
|
|
576
576
|
xhtml?: boolean | undefined;
|
|
577
577
|
}
|
|
578
|
-
export interface MarkedOptions extends Omit<MarkedExtension, '
|
|
578
|
+
export interface MarkedOptions extends Omit<MarkedExtension, 'renderer' | 'tokenizer' | 'extensions' | 'walkTokens'> {
|
|
579
579
|
/**
|
|
580
580
|
* Type: object Default: new Renderer()
|
|
581
581
|
*
|
|
582
582
|
* An object containing functions to render tokens to HTML.
|
|
583
583
|
*/
|
|
584
|
-
renderer?:
|
|
584
|
+
renderer?: _Renderer | undefined | null;
|
|
585
585
|
/**
|
|
586
586
|
* The tokenizer defines how to turn markdown text into tokens.
|
|
587
587
|
*/
|
|
588
|
-
tokenizer?:
|
|
589
|
-
/**
|
|
590
|
-
*
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
588
|
+
tokenizer?: _Tokenizer | undefined | null;
|
|
589
|
+
/**
|
|
590
|
+
* Custom extensions
|
|
591
|
+
*/
|
|
592
|
+
extensions?: null | {
|
|
593
|
+
renderers: {
|
|
594
|
+
[name: string]: RendererExtensionFunction;
|
|
595
|
+
};
|
|
596
|
+
childTokens: {
|
|
597
|
+
[name: string]: string[];
|
|
598
|
+
};
|
|
599
|
+
inline?: TokenizerExtensionFunction[];
|
|
600
|
+
block?: TokenizerExtensionFunction[];
|
|
601
|
+
startInline?: TokenizerStartFunction[];
|
|
602
|
+
startBlock?: TokenizerStartFunction[];
|
|
603
|
+
};
|
|
596
604
|
/**
|
|
597
|
-
*
|
|
605
|
+
* walkTokens function returns array of values for Promise.all
|
|
598
606
|
*/
|
|
599
|
-
|
|
600
|
-
renderers: Record<string, RendererExtensionFunction>;
|
|
601
|
-
childTokens: Record<string, string[]>;
|
|
602
|
-
block: any[];
|
|
603
|
-
inline: any[];
|
|
604
|
-
startBlock: Array<(this: TokenizerThis, src: string) => number | void>;
|
|
605
|
-
startInline: Array<(this: TokenizerThis, src: string) => number | void>;
|
|
606
|
-
}) | undefined | null;
|
|
607
|
+
walkTokens?: null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
|
|
607
608
|
}
|
|
608
609
|
}
|
|
609
610
|
declare module "defaults" {
|
|
@@ -642,7 +643,7 @@ declare module "marked" {
|
|
|
642
643
|
import { _getDefaults } from "defaults";
|
|
643
644
|
import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
|
|
644
645
|
import type { Token, TokensList } from "Tokens";
|
|
645
|
-
import type { ResultCallback } from "Instance";
|
|
646
|
+
import type { ResultCallback, MaybePromise } from "Instance";
|
|
646
647
|
/**
|
|
647
648
|
* Compiles markdown to HTML asynchronously.
|
|
648
649
|
*
|
|
@@ -689,7 +690,7 @@ declare module "marked" {
|
|
|
689
690
|
var getDefaults: typeof _getDefaults;
|
|
690
691
|
var defaults: MarkedOptions;
|
|
691
692
|
var use: (...args: MarkedExtension[]) => typeof marked;
|
|
692
|
-
var walkTokens:
|
|
693
|
+
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
693
694
|
var parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | null | undefined, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
|
694
695
|
var Parser: typeof _Parser;
|
|
695
696
|
var parser: typeof _Parser.parse;
|
|
@@ -705,7 +706,7 @@ declare module "marked" {
|
|
|
705
706
|
export const options: (options: MarkedOptions) => typeof marked;
|
|
706
707
|
export const setOptions: (options: MarkedOptions) => typeof marked;
|
|
707
708
|
export const use: (...args: MarkedExtension[]) => typeof marked;
|
|
708
|
-
export const walkTokens:
|
|
709
|
+
export const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
709
710
|
export const parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | null | undefined, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
|
710
711
|
export const parse: typeof marked;
|
|
711
712
|
export const parser: typeof _Parser.parse;
|