marked 13.0.3 → 14.1.0

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.d.cts CHANGED
@@ -271,54 +271,6 @@ declare const inlineNormal: {
271
271
  url: RegExp;
272
272
  };
273
273
  export type InlineKeys = keyof typeof inlineNormal;
274
- /**
275
- * exports
276
- */
277
- export declare const block: {
278
- normal: {
279
- blockquote: RegExp;
280
- code: RegExp;
281
- def: RegExp;
282
- fences: RegExp;
283
- heading: RegExp;
284
- hr: RegExp;
285
- html: RegExp;
286
- lheading: RegExp;
287
- list: RegExp;
288
- newline: RegExp;
289
- paragraph: RegExp;
290
- table: RegExp;
291
- text: RegExp;
292
- };
293
- gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
294
- pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
295
- };
296
- export declare const inline: {
297
- normal: {
298
- _backpedal: RegExp;
299
- anyPunctuation: RegExp;
300
- autolink: RegExp;
301
- blockSkip: RegExp;
302
- br: RegExp;
303
- code: RegExp;
304
- del: RegExp;
305
- emStrongLDelim: RegExp;
306
- emStrongRDelimAst: RegExp;
307
- emStrongRDelimUnd: RegExp;
308
- escape: RegExp;
309
- link: RegExp;
310
- nolink: RegExp;
311
- punctuation: RegExp;
312
- reflink: RegExp;
313
- reflinkSearch: RegExp;
314
- tag: RegExp;
315
- text: RegExp;
316
- url: RegExp;
317
- };
318
- gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
319
- breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
320
- pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
321
- };
322
274
  export interface Rules {
323
275
  block: Record<BlockKeys, RegExp>;
324
276
  inline: Record<InlineKeys, RegExp>;
@@ -358,6 +310,7 @@ declare class _Tokenizer {
358
310
  }
359
311
  declare class _Hooks {
360
312
  options: MarkedOptions;
313
+ block: boolean | undefined;
361
314
  constructor(options?: MarkedOptions);
362
315
  static passThroughHooks: Set<string>;
363
316
  /**
@@ -372,6 +325,14 @@ declare class _Hooks {
372
325
  * Process all tokens before walk tokens
373
326
  */
374
327
  processAllTokens(tokens: Token[] | TokensList): Token[] | TokensList;
328
+ /**
329
+ * Provide function to tokenize markdown
330
+ */
331
+ provideLexer(): typeof _Lexer.lexInline;
332
+ /**
333
+ * Provide function to parse tokens
334
+ */
335
+ provideParser(): typeof _Parser.parse;
375
336
  }
376
337
  export interface TokenizerThis {
377
338
  lexer: _Lexer;
@@ -394,7 +355,7 @@ export interface RendererExtension {
394
355
  renderer: RendererExtensionFunction;
395
356
  }
396
357
  export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
397
- export type HooksApi = Omit<_Hooks, "constructor" | "options">;
358
+ export type HooksApi = Omit<_Hooks, "constructor" | "options" | "block">;
398
359
  export type HooksObject = {
399
360
  [K in keyof HooksApi]?: (this: _Hooks, ...args: Parameters<HooksApi[K]>) => ReturnType<HooksApi[K]> | Promise<ReturnType<HooksApi[K]>>;
400
361
  };
@@ -428,6 +389,8 @@ export interface MarkedExtension {
428
389
  * preprocess is called to process markdown before sending it to marked.
429
390
  * processAllTokens is called with the TokensList before walkTokens.
430
391
  * postprocess is called to process html after marked has finished parsing.
392
+ * provideLexer is called to provide a function to tokenize markdown.
393
+ * provideParser is called to provide a function to parse tokens.
431
394
  */
432
395
  hooks?: HooksObject | undefined | null;
433
396
  /**
@@ -455,13 +418,8 @@ export interface MarkedExtension {
455
418
  * The return value of the function is ignored.
456
419
  */
457
420
  walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
458
- /**
459
- * Use the new renderer that accepts an object instead of individual parameters.
460
- * This option will be removed and default to true in the next major version.
461
- */
462
- useNewRenderer?: boolean | undefined;
463
421
  }
464
- export interface MarkedOptions extends Omit<MarkedExtension, "useNewRenderer" | "hooks" | "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
422
+ export interface MarkedOptions extends Omit<MarkedExtension, "hooks" | "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
465
423
  /**
466
424
  * Hooks are methods that hook into some part of marked.
467
425
  */
@@ -590,11 +548,26 @@ declare function _getDefaults(): MarkedOptions;
590
548
  declare let _defaults: MarkedOptions;
591
549
  export type MaybePromise = void | Promise<void>;
592
550
  export declare class Marked {
593
- #private;
594
551
  defaults: MarkedOptions;
595
552
  options: (opt: MarkedOptions) => this;
596
- parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
597
- parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
553
+ parse: {
554
+ (src: string, options: MarkedOptions & {
555
+ async: true;
556
+ }): Promise<string>;
557
+ (src: string, options: MarkedOptions & {
558
+ async: false;
559
+ }): string;
560
+ (src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
561
+ };
562
+ parseInline: {
563
+ (src: string, options: MarkedOptions & {
564
+ async: true;
565
+ }): Promise<string>;
566
+ (src: string, options: MarkedOptions & {
567
+ async: false;
568
+ }): string;
569
+ (src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
570
+ };
598
571
  Parser: typeof _Parser;
599
572
  Renderer: typeof _Renderer;
600
573
  TextRenderer: typeof _TextRenderer;
@@ -610,6 +583,8 @@ export declare class Marked {
610
583
  setOptions(opt: MarkedOptions): this;
611
584
  lexer(src: string, options?: MarkedOptions): TokensList;
612
585
  parser(tokens: Token[], options?: MarkedOptions): string;
586
+ private parseMarkdown;
587
+ private onError;
613
588
  }
614
589
  /**
615
590
  * Compiles markdown to HTML asynchronously.
@@ -628,7 +603,13 @@ export declare function marked(src: string, options: MarkedOptions & {
628
603
  * @param options Optional hash of options
629
604
  * @return String of compiled HTML. Will be a Promise of string if async is set to true by any extensions.
630
605
  */
631
- export declare function marked(src: string, options?: MarkedOptions): string | Promise<string>;
606
+ export declare function marked(src: string, options: MarkedOptions & {
607
+ async: false;
608
+ }): string;
609
+ export declare function marked(src: string, options: MarkedOptions & {
610
+ async: true;
611
+ }): Promise<string>;
612
+ export declare function marked(src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
632
613
  export declare namespace marked {
633
614
  var options: (options: MarkedOptions) => typeof marked;
634
615
  var setOptions: (options: MarkedOptions) => typeof marked;
@@ -636,7 +617,15 @@ export declare namespace marked {
636
617
  var defaults: MarkedOptions;
637
618
  var use: (...args: MarkedExtension[]) => typeof marked;
638
619
  var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
639
- var parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
620
+ var parseInline: {
621
+ (src: string, options: MarkedOptions & {
622
+ async: true;
623
+ }): Promise<string>;
624
+ (src: string, options: MarkedOptions & {
625
+ async: false;
626
+ }): string;
627
+ (src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
628
+ };
640
629
  var Parser: typeof _Parser;
641
630
  var parser: typeof _Parser.parse;
642
631
  var Renderer: typeof _Renderer;
@@ -651,7 +640,15 @@ export declare const options: (options: MarkedOptions) => typeof marked;
651
640
  export declare const setOptions: (options: MarkedOptions) => typeof marked;
652
641
  export declare const use: (...args: MarkedExtension[]) => typeof marked;
653
642
  export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
654
- export declare const parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
643
+ export declare const parseInline: {
644
+ (src: string, options: MarkedOptions & {
645
+ async: true;
646
+ }): Promise<string>;
647
+ (src: string, options: MarkedOptions & {
648
+ async: false;
649
+ }): string;
650
+ (src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
651
+ };
655
652
  export declare const parse: typeof marked;
656
653
  export declare const parser: typeof _Parser.parse;
657
654
  export declare const lexer: typeof _Lexer.lex;
package/lib/marked.d.ts CHANGED
@@ -271,54 +271,6 @@ declare const inlineNormal: {
271
271
  url: RegExp;
272
272
  };
273
273
  export type InlineKeys = keyof typeof inlineNormal;
274
- /**
275
- * exports
276
- */
277
- export declare const block: {
278
- normal: {
279
- blockquote: RegExp;
280
- code: RegExp;
281
- def: RegExp;
282
- fences: RegExp;
283
- heading: RegExp;
284
- hr: RegExp;
285
- html: RegExp;
286
- lheading: RegExp;
287
- list: RegExp;
288
- newline: RegExp;
289
- paragraph: RegExp;
290
- table: RegExp;
291
- text: RegExp;
292
- };
293
- gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
294
- pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
295
- };
296
- export declare const inline: {
297
- normal: {
298
- _backpedal: RegExp;
299
- anyPunctuation: RegExp;
300
- autolink: RegExp;
301
- blockSkip: RegExp;
302
- br: RegExp;
303
- code: RegExp;
304
- del: RegExp;
305
- emStrongLDelim: RegExp;
306
- emStrongRDelimAst: RegExp;
307
- emStrongRDelimUnd: RegExp;
308
- escape: RegExp;
309
- link: RegExp;
310
- nolink: RegExp;
311
- punctuation: RegExp;
312
- reflink: RegExp;
313
- reflinkSearch: RegExp;
314
- tag: RegExp;
315
- text: RegExp;
316
- url: RegExp;
317
- };
318
- gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
319
- breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
320
- pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
321
- };
322
274
  export interface Rules {
323
275
  block: Record<BlockKeys, RegExp>;
324
276
  inline: Record<InlineKeys, RegExp>;
@@ -358,6 +310,7 @@ declare class _Tokenizer {
358
310
  }
359
311
  declare class _Hooks {
360
312
  options: MarkedOptions;
313
+ block: boolean | undefined;
361
314
  constructor(options?: MarkedOptions);
362
315
  static passThroughHooks: Set<string>;
363
316
  /**
@@ -372,6 +325,14 @@ declare class _Hooks {
372
325
  * Process all tokens before walk tokens
373
326
  */
374
327
  processAllTokens(tokens: Token[] | TokensList): Token[] | TokensList;
328
+ /**
329
+ * Provide function to tokenize markdown
330
+ */
331
+ provideLexer(): typeof _Lexer.lexInline;
332
+ /**
333
+ * Provide function to parse tokens
334
+ */
335
+ provideParser(): typeof _Parser.parse;
375
336
  }
376
337
  export interface TokenizerThis {
377
338
  lexer: _Lexer;
@@ -394,7 +355,7 @@ export interface RendererExtension {
394
355
  renderer: RendererExtensionFunction;
395
356
  }
396
357
  export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
397
- export type HooksApi = Omit<_Hooks, "constructor" | "options">;
358
+ export type HooksApi = Omit<_Hooks, "constructor" | "options" | "block">;
398
359
  export type HooksObject = {
399
360
  [K in keyof HooksApi]?: (this: _Hooks, ...args: Parameters<HooksApi[K]>) => ReturnType<HooksApi[K]> | Promise<ReturnType<HooksApi[K]>>;
400
361
  };
@@ -428,6 +389,8 @@ export interface MarkedExtension {
428
389
  * preprocess is called to process markdown before sending it to marked.
429
390
  * processAllTokens is called with the TokensList before walkTokens.
430
391
  * postprocess is called to process html after marked has finished parsing.
392
+ * provideLexer is called to provide a function to tokenize markdown.
393
+ * provideParser is called to provide a function to parse tokens.
431
394
  */
432
395
  hooks?: HooksObject | undefined | null;
433
396
  /**
@@ -455,13 +418,8 @@ export interface MarkedExtension {
455
418
  * The return value of the function is ignored.
456
419
  */
457
420
  walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
458
- /**
459
- * Use the new renderer that accepts an object instead of individual parameters.
460
- * This option will be removed and default to true in the next major version.
461
- */
462
- useNewRenderer?: boolean | undefined;
463
421
  }
464
- export interface MarkedOptions extends Omit<MarkedExtension, "useNewRenderer" | "hooks" | "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
422
+ export interface MarkedOptions extends Omit<MarkedExtension, "hooks" | "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
465
423
  /**
466
424
  * Hooks are methods that hook into some part of marked.
467
425
  */
@@ -590,11 +548,26 @@ declare function _getDefaults(): MarkedOptions;
590
548
  declare let _defaults: MarkedOptions;
591
549
  export type MaybePromise = void | Promise<void>;
592
550
  export declare class Marked {
593
- #private;
594
551
  defaults: MarkedOptions;
595
552
  options: (opt: MarkedOptions) => this;
596
- parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
597
- parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
553
+ parse: {
554
+ (src: string, options: MarkedOptions & {
555
+ async: true;
556
+ }): Promise<string>;
557
+ (src: string, options: MarkedOptions & {
558
+ async: false;
559
+ }): string;
560
+ (src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
561
+ };
562
+ parseInline: {
563
+ (src: string, options: MarkedOptions & {
564
+ async: true;
565
+ }): Promise<string>;
566
+ (src: string, options: MarkedOptions & {
567
+ async: false;
568
+ }): string;
569
+ (src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
570
+ };
598
571
  Parser: typeof _Parser;
599
572
  Renderer: typeof _Renderer;
600
573
  TextRenderer: typeof _TextRenderer;
@@ -610,6 +583,8 @@ export declare class Marked {
610
583
  setOptions(opt: MarkedOptions): this;
611
584
  lexer(src: string, options?: MarkedOptions): TokensList;
612
585
  parser(tokens: Token[], options?: MarkedOptions): string;
586
+ private parseMarkdown;
587
+ private onError;
613
588
  }
614
589
  /**
615
590
  * Compiles markdown to HTML asynchronously.
@@ -628,7 +603,13 @@ export declare function marked(src: string, options: MarkedOptions & {
628
603
  * @param options Optional hash of options
629
604
  * @return String of compiled HTML. Will be a Promise of string if async is set to true by any extensions.
630
605
  */
631
- export declare function marked(src: string, options?: MarkedOptions): string | Promise<string>;
606
+ export declare function marked(src: string, options: MarkedOptions & {
607
+ async: false;
608
+ }): string;
609
+ export declare function marked(src: string, options: MarkedOptions & {
610
+ async: true;
611
+ }): Promise<string>;
612
+ export declare function marked(src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
632
613
  export declare namespace marked {
633
614
  var options: (options: MarkedOptions) => typeof marked;
634
615
  var setOptions: (options: MarkedOptions) => typeof marked;
@@ -636,7 +617,15 @@ export declare namespace marked {
636
617
  var defaults: MarkedOptions;
637
618
  var use: (...args: MarkedExtension[]) => typeof marked;
638
619
  var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
639
- var parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
620
+ var parseInline: {
621
+ (src: string, options: MarkedOptions & {
622
+ async: true;
623
+ }): Promise<string>;
624
+ (src: string, options: MarkedOptions & {
625
+ async: false;
626
+ }): string;
627
+ (src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
628
+ };
640
629
  var Parser: typeof _Parser;
641
630
  var parser: typeof _Parser.parse;
642
631
  var Renderer: typeof _Renderer;
@@ -651,7 +640,15 @@ export declare const options: (options: MarkedOptions) => typeof marked;
651
640
  export declare const setOptions: (options: MarkedOptions) => typeof marked;
652
641
  export declare const use: (...args: MarkedExtension[]) => typeof marked;
653
642
  export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
654
- export declare const parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
643
+ export declare const parseInline: {
644
+ (src: string, options: MarkedOptions & {
645
+ async: true;
646
+ }): Promise<string>;
647
+ (src: string, options: MarkedOptions & {
648
+ async: false;
649
+ }): string;
650
+ (src: string, options?: MarkedOptions | undefined | null): string | Promise<string>;
651
+ };
655
652
  export declare const parse: typeof marked;
656
653
  export declare const parser: typeof _Parser.parse;
657
654
  export declare const lexer: typeof _Lexer.lex;