marked 7.0.0 → 7.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.d.ts CHANGED
@@ -1,624 +1,725 @@
1
- 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) & {
2
- loose?: boolean;
3
- tokens?: Token[];
4
- };
5
- declare namespace Tokens {
6
- interface Space {
7
- type: 'space';
8
- raw: string;
9
- }
10
- interface Code {
11
- type: 'code';
12
- raw: string;
13
- codeBlockStyle?: 'indented' | undefined;
14
- lang?: string | undefined;
15
- text: string;
16
- escaped?: boolean;
17
- }
18
- interface Heading {
19
- type: 'heading';
20
- raw: string;
21
- depth: number;
22
- text: string;
23
- tokens: Token[];
24
- }
25
- interface Table {
26
- type: 'table';
27
- raw?: string;
28
- align: Array<'center' | 'left' | 'right' | null>;
29
- header: TableCell[];
30
- rows: TableCell[][];
31
- }
32
- interface TableCell {
33
- text: string;
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;
34
4
  tokens?: Token[];
5
+ };
6
+ export namespace Tokens {
7
+ interface Space {
8
+ type: 'space';
9
+ raw: string;
10
+ }
11
+ interface Code {
12
+ type: 'code';
13
+ raw: string;
14
+ codeBlockStyle?: 'indented' | undefined;
15
+ lang?: string | undefined;
16
+ text: string;
17
+ escaped?: boolean;
18
+ }
19
+ interface Heading {
20
+ type: 'heading';
21
+ raw: string;
22
+ depth: number;
23
+ text: string;
24
+ tokens: Token[];
25
+ }
26
+ interface Table {
27
+ type: 'table';
28
+ raw: string;
29
+ align: Array<'center' | 'left' | 'right' | null>;
30
+ header: TableCell[];
31
+ rows: TableCell[][];
32
+ }
33
+ interface TableCell {
34
+ text: string;
35
+ tokens?: Token[];
36
+ }
37
+ interface Hr {
38
+ type: 'hr';
39
+ raw: string;
40
+ }
41
+ interface Blockquote {
42
+ type: 'blockquote';
43
+ raw: string;
44
+ text: string;
45
+ tokens: Token[];
46
+ }
47
+ interface List {
48
+ type: 'list';
49
+ raw: string;
50
+ ordered: boolean;
51
+ start: number | '';
52
+ loose: boolean;
53
+ items: ListItem[];
54
+ }
55
+ interface ListItem {
56
+ type: 'list_item';
57
+ raw: string;
58
+ task: boolean;
59
+ checked?: boolean | undefined;
60
+ loose: boolean;
61
+ text: string;
62
+ tokens?: Token[];
63
+ }
64
+ interface Paragraph {
65
+ type: 'paragraph';
66
+ raw: string;
67
+ pre?: boolean | undefined;
68
+ text: string;
69
+ tokens: Token[];
70
+ }
71
+ interface HTML {
72
+ type: 'html';
73
+ raw: string;
74
+ pre: boolean;
75
+ text: string;
76
+ block: boolean;
77
+ }
78
+ interface Text {
79
+ type: 'text';
80
+ raw: string;
81
+ text: string;
82
+ tokens?: Token[];
83
+ }
84
+ interface Def {
85
+ type: 'def';
86
+ raw: string;
87
+ tag: string;
88
+ href: string;
89
+ title: string;
90
+ }
91
+ interface Escape {
92
+ type: 'escape';
93
+ raw: string;
94
+ text: string;
95
+ }
96
+ interface Tag {
97
+ type: 'text' | 'html';
98
+ raw: string;
99
+ inLink: boolean;
100
+ inRawBlock: boolean;
101
+ text: string;
102
+ block: boolean;
103
+ }
104
+ interface Link {
105
+ type: 'link';
106
+ raw: string;
107
+ href: string;
108
+ title?: string | null;
109
+ text: string;
110
+ tokens: Token[];
111
+ }
112
+ interface Image {
113
+ type: 'image';
114
+ raw: string;
115
+ href: string;
116
+ title: string | null;
117
+ text: string;
118
+ }
119
+ interface Strong {
120
+ type: 'strong';
121
+ raw: string;
122
+ text: string;
123
+ tokens: Token[];
124
+ }
125
+ interface Em {
126
+ type: 'em';
127
+ raw: string;
128
+ text: string;
129
+ tokens: Token[];
130
+ }
131
+ interface Codespan {
132
+ type: 'codespan';
133
+ raw: string;
134
+ text: string;
135
+ }
136
+ interface Br {
137
+ type: 'br';
138
+ raw: string;
139
+ }
140
+ interface Del {
141
+ type: 'del';
142
+ raw: string;
143
+ text: string;
144
+ tokens: Token[];
145
+ }
146
+ interface Generic {
147
+ [index: string]: any;
148
+ type: string;
149
+ raw: string;
150
+ tokens?: Token[] | undefined;
151
+ }
35
152
  }
36
- interface Hr {
37
- type: 'hr';
38
- raw: string;
39
- }
40
- interface Blockquote {
41
- type: 'blockquote';
42
- raw: string;
43
- text: string;
44
- tokens: Token[];
45
- }
46
- interface List {
47
- type: 'list';
48
- raw: string;
49
- ordered: boolean;
50
- start: number | '';
51
- loose: boolean;
52
- items: ListItem[];
53
- }
54
- interface ListItem {
55
- type: 'list_item';
56
- raw: string;
57
- task: boolean;
58
- checked?: boolean | undefined;
59
- loose: boolean;
60
- text: string;
61
- tokens?: Token[];
153
+ export type Links = Record<string, Pick<Tokens.Link | Tokens.Image, 'href' | 'title'>>;
154
+ export type TokensList = Token[] & {
155
+ links: Links;
156
+ };
157
+ }
158
+ declare module "Tokenizer" {
159
+ import type { _Lexer } from "Lexer";
160
+ import type { Links, Tokens } from "Tokens";
161
+ import type { MarkedOptions } from "MarkedOptions";
162
+ /**
163
+ * Tokenizer
164
+ */
165
+ export class _Tokenizer {
166
+ options: MarkedOptions;
167
+ rules: any;
168
+ lexer: _Lexer;
169
+ constructor(options?: MarkedOptions);
170
+ space(src: string): Tokens.Space | undefined;
171
+ code(src: string): Tokens.Code | undefined;
172
+ fences(src: string): Tokens.Code | undefined;
173
+ heading(src: string): Tokens.Heading | undefined;
174
+ hr(src: string): Tokens.Hr | undefined;
175
+ blockquote(src: string): Tokens.Blockquote | undefined;
176
+ list(src: string): Tokens.List | undefined;
177
+ html(src: string): Tokens.HTML | Tokens.Paragraph | undefined;
178
+ def(src: string): Tokens.Def | undefined;
179
+ table(src: string): Tokens.Table | undefined;
180
+ lheading(src: string): Tokens.Heading | undefined;
181
+ paragraph(src: string): Tokens.Paragraph | undefined;
182
+ text(src: string): Tokens.Text | undefined;
183
+ escape(src: string): Tokens.Escape | undefined;
184
+ tag(src: string): Tokens.Tag | undefined;
185
+ link(src: string): Tokens.Link | Tokens.Image | undefined;
186
+ reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
187
+ emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
188
+ codespan(src: string): Tokens.Codespan | undefined;
189
+ br(src: string): Tokens.Br | undefined;
190
+ del(src: string): Tokens.Del | undefined;
191
+ autolink(src: string, mangle: (cap: string) => string): Tokens.Link | undefined;
192
+ url(src: string, mangle: (cap: string) => string): Tokens.Link | undefined;
193
+ inlineText(src: string, smartypants: (cap: string) => string): Tokens.Text | undefined;
62
194
  }
63
- interface Paragraph {
64
- type: 'paragraph';
65
- raw: string;
66
- pre?: boolean | undefined;
67
- text: string;
68
- tokens: Token[];
195
+ }
196
+ declare module "rules" {
197
+ export type Rule = RegExp | string;
198
+ export interface Rules {
199
+ [ruleName: string]: Pick<RegExp, 'exec'> | Rule | Rules;
69
200
  }
70
- interface HTML {
71
- type: 'html';
72
- raw: string;
73
- pre: boolean;
74
- text: string;
75
- block: boolean;
201
+ type BlockRuleNames = 'newline' | 'code' | 'fences' | 'hr' | 'heading' | 'blockquote' | 'list' | 'html' | 'def' | 'lheading' | '_paragraph' | 'text' | '_label' | '_title' | 'bullet' | 'listItemStart' | '_tag' | '_comment' | 'paragraph' | 'uote';
202
+ type BlockSubRuleNames = 'normal' | 'gfm' | 'pedantic';
203
+ type InlineRuleNames = 'escape' | 'autolink' | 'tag' | 'link' | 'reflink' | 'nolink' | 'reflinkSearch' | 'code' | 'br' | 'text' | '_punctuation' | 'punctuation' | 'blockSkip' | 'escapedEmSt' | '_comment' | '_escapes' | '_scheme' | '_email' | '_attribute' | '_label' | '_href' | '_title' | 'strong' | '_extended_email' | '_backpedal';
204
+ type InlineSubRuleNames = 'gfm' | 'emStrong' | 'normal' | 'pedantic' | 'breaks';
205
+ /**
206
+ * Block-Level Grammar
207
+ */
208
+ export const block: Record<BlockRuleNames, Rule> & Record<BlockSubRuleNames, Rules> & Rules;
209
+ /**
210
+ * Inline-Level Grammar
211
+ */
212
+ export const inline: Record<InlineRuleNames, Rule> & Record<InlineSubRuleNames, Rules> & Rules;
213
+ }
214
+ declare module "Lexer" {
215
+ import type { Token, TokensList } from "Tokens";
216
+ import type { MarkedOptions } from "MarkedOptions";
217
+ import type { Rules } from "rules";
218
+ /**
219
+ * Block Lexer
220
+ */
221
+ export class _Lexer {
222
+ tokens: TokensList;
223
+ options: MarkedOptions;
224
+ state: {
225
+ inLink: boolean;
226
+ inRawBlock: boolean;
227
+ top: boolean;
228
+ };
229
+ private tokenizer;
230
+ private inlineQueue;
231
+ constructor(options?: MarkedOptions);
232
+ /**
233
+ * Expose Rules
234
+ */
235
+ static get rules(): Rules;
236
+ /**
237
+ * Static Lex Method
238
+ */
239
+ static lex(src: string, options?: MarkedOptions): TokensList;
240
+ /**
241
+ * Static Lex Inline Method
242
+ */
243
+ static lexInline(src: string, options?: MarkedOptions): Token[];
244
+ /**
245
+ * Preprocessing
246
+ */
247
+ lex(src: string): TokensList;
248
+ /**
249
+ * Lexing
250
+ */
251
+ blockTokens(src: string, tokens?: Token[]): Token[];
252
+ blockTokens(src: string, tokens?: TokensList): TokensList;
253
+ inline(src: string, tokens?: Token[]): Token[];
254
+ /**
255
+ * Lexing/Compiling
256
+ */
257
+ inlineTokens(src: string, tokens?: Token[]): Token[];
76
258
  }
77
- interface Text {
78
- type: 'text';
79
- raw: string;
80
- text: string;
81
- tokens?: Token[];
259
+ }
260
+ declare module "TextRenderer" {
261
+ /**
262
+ * TextRenderer
263
+ * returns only the textual part of the token
264
+ */
265
+ export class _TextRenderer {
266
+ strong(text: string): string;
267
+ em(text: string): string;
268
+ codespan(text: string): string;
269
+ del(text: string): string;
270
+ html(text: string): string;
271
+ text(text: string): string;
272
+ link(href: string, title: string | null | undefined, text: string): string;
273
+ image(href: string, title: string | null, text: string): string;
274
+ br(): string;
82
275
  }
83
- interface Def {
84
- type: 'def';
85
- raw: string;
86
- tag: string;
87
- href: string;
88
- title: string;
276
+ }
277
+ declare module "Slugger" {
278
+ import type { SluggerOptions } from "MarkedOptions";
279
+ /**
280
+ * Slugger generates header id
281
+ */
282
+ export class _Slugger {
283
+ seen: {
284
+ [slugValue: string]: number;
285
+ };
286
+ constructor();
287
+ serialize(value: string): string;
288
+ /**
289
+ * Finds the next safe (unique) slug to use
290
+ */
291
+ getNextSafeSlug(originalSlug: string, isDryRun: boolean | undefined): string;
292
+ /**
293
+ * Convert string to unique id
294
+ */
295
+ slug(value: string, options?: SluggerOptions): string;
89
296
  }
90
- interface Escape {
91
- type: 'escape';
92
- raw: string;
93
- text: string;
297
+ }
298
+ declare module "Instance" {
299
+ import { _Lexer } from "Lexer";
300
+ import { _Parser } from "Parser";
301
+ import { _Hooks } from "Hooks";
302
+ import { _Renderer } from "Renderer";
303
+ import { _Tokenizer } from "Tokenizer";
304
+ import { _TextRenderer } from "TextRenderer";
305
+ import { _Slugger } from "Slugger";
306
+ import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
307
+ import type { Token, TokensList } from "Tokens";
308
+ export type ResultCallback = (error: Error | null, parseResult?: string) => undefined | void;
309
+ export class Marked {
310
+ #private;
311
+ defaults: MarkedOptions;
312
+ options: (opt: MarkedOptions) => this;
313
+ parse: (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
314
+ parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
315
+ Parser: typeof _Parser;
316
+ parser: typeof _Parser.parse;
317
+ Renderer: typeof _Renderer;
318
+ TextRenderer: typeof _TextRenderer;
319
+ Lexer: typeof _Lexer;
320
+ lexer: typeof _Lexer.lex;
321
+ Tokenizer: typeof _Tokenizer;
322
+ Slugger: typeof _Slugger;
323
+ Hooks: typeof _Hooks;
324
+ constructor(...args: MarkedExtension[]);
325
+ /**
326
+ * Run callback for every token
327
+ */
328
+ walkTokens<T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]): T[];
329
+ use(...args: MarkedExtension[]): this;
330
+ setOptions(opt: MarkedOptions): this;
94
331
  }
95
- interface Tag {
96
- type: 'text' | 'html';
97
- raw: string;
98
- inLink: boolean;
99
- inRawBlock: boolean;
100
- text: string;
101
- block: boolean;
332
+ }
333
+ declare module "helpers" {
334
+ import type { MarkedOptions } from "MarkedOptions";
335
+ import type { ResultCallback } from "Instance";
336
+ import type { Rule } from "rules";
337
+ export function escape(html: string, encode?: boolean): string;
338
+ export function unescape(html: string): string;
339
+ export function edit(regex: Rule, opt?: string): {
340
+ replace: (name: string | RegExp, val: string | RegExp) => any;
341
+ getRegex: () => RegExp;
342
+ };
343
+ export function cleanUrl(sanitize: boolean | undefined, base: string | undefined | null, href: string): string | null;
344
+ export function resolveUrl(base: string, href: string): string;
345
+ export const noopTest: {
346
+ exec: () => null;
347
+ };
348
+ export function splitCells(tableRow: string, count?: number): string[];
349
+ /**
350
+ * Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
351
+ * /c*$/ is vulnerable to REDOS.
352
+ *
353
+ * @param str
354
+ * @param c
355
+ * @param invert Remove suffix of non-c chars instead. Default falsey.
356
+ */
357
+ export function rtrim(str: string, c: string, invert?: boolean): string;
358
+ export function findClosingBracket(str: string, b: string): number;
359
+ export function checkDeprecations(opt: MarkedOptions, callback?: ResultCallback): void;
360
+ }
361
+ declare module "Renderer" {
362
+ import type { MarkedOptions } from "MarkedOptions";
363
+ import type { _Slugger } from "Slugger";
364
+ /**
365
+ * Renderer
366
+ */
367
+ export class _Renderer {
368
+ options: MarkedOptions;
369
+ constructor(options?: MarkedOptions);
370
+ code(code: string, infostring: string | undefined, escaped: boolean): string;
371
+ blockquote(quote: string): string;
372
+ html(html: string, block?: boolean): string;
373
+ heading(text: string, level: number, raw: string, slugger: _Slugger): string;
374
+ hr(): string;
375
+ list(body: string, ordered: boolean, start: number | ''): string;
376
+ listitem(text: string, task: boolean, checked: boolean): string;
377
+ checkbox(checked: boolean): string;
378
+ paragraph(text: string): string;
379
+ table(header: string, body: string): string;
380
+ tablerow(content: string): string;
381
+ tablecell(content: string, flags: {
382
+ header: boolean;
383
+ align: 'center' | 'left' | 'right' | null;
384
+ }): string;
385
+ /**
386
+ * span level renderer
387
+ */
388
+ strong(text: string): string;
389
+ em(text: string): string;
390
+ codespan(text: string): string;
391
+ br(): string;
392
+ del(text: string): string;
393
+ link(href: string, title: string | null | undefined, text: string): string;
394
+ image(href: string, title: string | null, text: string): string;
395
+ text(text: string): string;
102
396
  }
103
- interface Link {
104
- type: 'link';
105
- raw: string;
106
- href: string;
107
- title?: string | null;
108
- text: string;
109
- tokens: Token[];
397
+ }
398
+ declare module "Parser" {
399
+ import { _Renderer } from "Renderer";
400
+ import { _TextRenderer } from "TextRenderer";
401
+ import { _Slugger } from "Slugger";
402
+ import type { Token } from "Tokens";
403
+ import type { MarkedOptions } from "MarkedOptions";
404
+ /**
405
+ * Parsing & Compiling
406
+ */
407
+ export class _Parser {
408
+ options: MarkedOptions;
409
+ renderer: _Renderer;
410
+ textRenderer: _TextRenderer;
411
+ slugger: _Slugger;
412
+ constructor(options?: MarkedOptions);
413
+ /**
414
+ * Static Parse Method
415
+ */
416
+ static parse(tokens: Token[], options?: MarkedOptions): string;
417
+ /**
418
+ * Static Parse Inline Method
419
+ */
420
+ static parseInline(tokens: Token[], options?: MarkedOptions): string;
421
+ /**
422
+ * Parse Loop
423
+ */
424
+ parse(tokens: Token[], top?: boolean): string;
425
+ /**
426
+ * Parse Inline Tokens
427
+ */
428
+ parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
110
429
  }
111
- interface Image {
112
- type: 'image';
113
- raw: string;
114
- href: string;
115
- title: string | null;
116
- text: string;
430
+ }
431
+ declare module "MarkedOptions" {
432
+ import type { Token, Tokens, TokensList } from "Tokens";
433
+ import type { _Parser } from "Parser";
434
+ import type { _Lexer } from "Lexer";
435
+ import type { _Renderer } from "Renderer";
436
+ import type { _Tokenizer } from "Tokenizer";
437
+ export interface SluggerOptions {
438
+ /** Generates the next unique slug without updating the internal accumulator. */
439
+ dryrun?: boolean;
117
440
  }
118
- interface Strong {
119
- type: 'strong';
120
- raw: string;
121
- text: string;
122
- tokens: Token[];
441
+ export interface TokenizerThis {
442
+ lexer: _Lexer;
123
443
  }
124
- interface Em {
125
- type: 'em';
126
- raw: string;
127
- text: string;
128
- tokens: Token[];
444
+ export interface TokenizerExtension {
445
+ name: string;
446
+ level: 'block' | 'inline';
447
+ start?: ((this: TokenizerThis, src: string) => number | void) | undefined;
448
+ tokenizer: (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
449
+ childTokens?: string[] | undefined;
129
450
  }
130
- interface Codespan {
131
- type: 'codespan';
132
- raw: string;
133
- text: string;
451
+ export interface RendererThis {
452
+ parser: _Parser;
134
453
  }
135
- interface Br {
136
- type: 'br';
137
- raw: string;
454
+ export type RendererExtensionFunction = (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
455
+ export interface RendererExtension {
456
+ name: string;
457
+ renderer: RendererExtensionFunction;
138
458
  }
139
- interface Del {
140
- type: 'del';
141
- raw: string;
142
- text: string;
143
- tokens: Token[];
459
+ export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
460
+ type RendererApi = Omit<_Renderer, 'constructor' | 'options'>;
461
+ type RendererObject = {
462
+ [K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
463
+ };
464
+ type TokenizerApi = Omit<_Tokenizer, 'constructor' | 'options' | 'rules' | 'lexer'>;
465
+ type TokenizerObject = {
466
+ [K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
467
+ };
468
+ export interface MarkedExtension {
469
+ /**
470
+ * True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
471
+ */
472
+ async?: boolean;
473
+ /**
474
+ * A prefix URL for any relative link.
475
+ * @deprecated Deprecated in v5.0.0 use marked-base-url to prefix url for any relative link.
476
+ */
477
+ baseUrl?: string | undefined | null;
478
+ /**
479
+ * Enable GFM line breaks. This option requires the gfm option to be true.
480
+ */
481
+ breaks?: boolean | undefined;
482
+ /**
483
+ * Add tokenizers and renderers to marked
484
+ */
485
+ extensions?: TokenizerAndRendererExtension[] | undefined | null;
486
+ /**
487
+ * Enable GitHub flavored markdown.
488
+ */
489
+ gfm?: boolean | undefined;
490
+ /**
491
+ * Include an id attribute when emitting headings.
492
+ * @deprecated Deprecated in v5.0.0 use marked-gfm-heading-id to include an id attribute when emitting headings (h1, h2, h3, etc).
493
+ */
494
+ headerIds?: boolean | undefined;
495
+ /**
496
+ * Set the prefix for header tag ids.
497
+ * @deprecated Deprecated in v5.0.0 use marked-gfm-heading-id to add a string to prefix the id attribute when emitting headings (h1, h2, h3, etc).
498
+ */
499
+ headerPrefix?: string | undefined;
500
+ /**
501
+ * A function to highlight code blocks. The function can either be
502
+ * synchronous (returning a string) or asynchronous (callback invoked
503
+ * with an error if any occurred during highlighting and a string
504
+ * if highlighting was successful)
505
+ * @deprecated Deprecated in v5.0.0 use marked-highlight to add highlighting to code blocks.
506
+ */
507
+ highlight?: ((code: string, lang: string | undefined, callback?: (error: Error, code?: string) => void) => string | void) | null;
508
+ /**
509
+ * Hooks are methods that hook into some part of marked.
510
+ * preprocess is called to process markdown before sending it to marked.
511
+ * postprocess is called to process html after marked has finished parsing.
512
+ */
513
+ hooks?: {
514
+ preprocess: (markdown: string) => string | Promise<string>;
515
+ postprocess: (html: string) => string | Promise<string>;
516
+ options?: MarkedOptions;
517
+ } | null;
518
+ /**
519
+ * Set the prefix for code block classes.
520
+ * @deprecated Deprecated in v5.0.0 use marked-highlight to prefix the className in a <code> block. Useful for syntax highlighting.
521
+ */
522
+ langPrefix?: string | undefined;
523
+ /**
524
+ * Mangle autolinks (<email@domain.com>).
525
+ * @deprecated Deprecated in v5.0.0 use marked-mangle to mangle email addresses.
526
+ */
527
+ mangle?: boolean | undefined;
528
+ /**
529
+ * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
530
+ */
531
+ pedantic?: boolean | undefined;
532
+ /**
533
+ * Type: object Default: new Renderer()
534
+ *
535
+ * An object containing functions to render tokens to HTML.
536
+ */
537
+ renderer?: RendererObject | undefined | null;
538
+ /**
539
+ * Sanitize the output. Ignore any HTML that has been input. If true, sanitize the HTML passed into markdownString with the sanitizer function.
540
+ * @deprecated Warning: This feature is deprecated and it should NOT be used as it cannot be considered secure. Instead use a sanitize library, like DOMPurify (recommended), sanitize-html or insane on the output HTML!
541
+ */
542
+ sanitize?: boolean | undefined;
543
+ /**
544
+ * Optionally sanitize found HTML with a sanitizer function.
545
+ * @deprecated A function to sanitize the HTML passed into markdownString.
546
+ */
547
+ sanitizer?: ((html: string) => string) | null;
548
+ /**
549
+ * Shows an HTML error message when rendering fails.
550
+ */
551
+ silent?: boolean | undefined;
552
+ /**
553
+ * Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
554
+ */
555
+ smartLists?: boolean | undefined;
556
+ /**
557
+ * Use "smart" typograhic punctuation for things like quotes and dashes.
558
+ * @deprecated Deprecated in v5.0.0 use marked-smartypants to use "smart" typographic punctuation for things like quotes and dashes.
559
+ */
560
+ smartypants?: boolean | undefined;
561
+ /**
562
+ * The tokenizer defines how to turn markdown text into tokens.
563
+ */
564
+ tokenizer?: TokenizerObject | undefined | null;
565
+ /**
566
+ * The walkTokens function gets called with every token.
567
+ * Child tokens are called before moving on to sibling tokens.
568
+ * Each token is passed by reference so updates are persisted when passed to the parser.
569
+ * The return value of the function is ignored.
570
+ */
571
+ walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
572
+ /**
573
+ * Generate closing slash for self-closing tags (<br/> instead of <br>)
574
+ * @deprecated Deprecated in v5.0.0 use marked-xhtml to emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML.
575
+ */
576
+ xhtml?: boolean | undefined;
144
577
  }
145
- interface Generic {
146
- [index: string]: any;
147
- type: string;
148
- raw: string;
149
- tokens?: Token[] | undefined;
578
+ export interface MarkedOptions extends Omit<MarkedExtension, 'extensions' | 'renderer' | 'tokenizer' | 'walkTokens'> {
579
+ /**
580
+ * Type: object Default: new Renderer()
581
+ *
582
+ * An object containing functions to render tokens to HTML.
583
+ */
584
+ renderer?: Omit<_Renderer, 'constructor'> | undefined | null;
585
+ /**
586
+ * The tokenizer defines how to turn markdown text into tokens.
587
+ */
588
+ tokenizer?: Omit<_Tokenizer, 'constructor'> | undefined | null;
589
+ /**
590
+ * The walkTokens function gets called with every token.
591
+ * Child tokens are called before moving on to sibling tokens.
592
+ * Each token is passed by reference so updates are persisted when passed to the parser.
593
+ * The return value of the function is ignored.
594
+ */
595
+ walkTokens?: ((token: Token) => void | Promise<void> | Array<void | Promise<void>>) | undefined | null;
596
+ /**
597
+ * Add tokenizers and renderers to marked
598
+ */
599
+ extensions?: (TokenizerAndRendererExtension[] & {
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;
150
607
  }
151
608
  }
152
- type Links = Record<string, Pick<Tokens.Link | Tokens.Image, 'href' | 'title'>>;
153
- type TokensList = Token[] & {
154
- links: Links;
155
- };
156
-
157
- /**
158
- * Renderer
159
- */
160
- declare class _Renderer {
161
- options: MarkedOptions;
162
- constructor(options?: MarkedOptions);
163
- code(code: string, infostring: string | undefined, escaped: boolean): string;
164
- blockquote(quote: string): string;
165
- html(html: string, block?: boolean): string;
166
- heading(text: string, level: number, raw: string, slugger: _Slugger): string;
167
- hr(): string;
168
- list(body: string, ordered: boolean, start: number | ''): string;
169
- listitem(text: string, task: boolean, checked: boolean): string;
170
- checkbox(checked: boolean): string;
171
- paragraph(text: string): string;
172
- table(header: string, body: string): string;
173
- tablerow(content: string): string;
174
- tablecell(content: string, flags: {
175
- header: boolean;
176
- align: 'center' | 'left' | 'right' | null;
177
- }): string;
609
+ declare module "defaults" {
610
+ import type { MarkedOptions } from "MarkedOptions";
178
611
  /**
179
- * span level renderer
612
+ * Gets the original marked default options.
180
613
  */
181
- strong(text: string): string;
182
- em(text: string): string;
183
- codespan(text: string): string;
184
- br(): string;
185
- del(text: string): string;
186
- link(href: string, title: string | null | undefined, text: string): string;
187
- image(href: string, title: string | null, text: string): string;
188
- text(text: string): string;
614
+ export function _getDefaults(): MarkedOptions;
615
+ export let _defaults: MarkedOptions;
616
+ export function changeDefaults(newDefaults: MarkedOptions): void;
189
617
  }
190
-
191
- /**
192
- * TextRenderer
193
- * returns only the textual part of the token
194
- */
195
- declare class _TextRenderer {
196
- strong(text: string): string;
197
- em(text: string): string;
198
- codespan(text: string): string;
199
- del(text: string): string;
200
- html(text: string): string;
201
- text(text: string): string;
202
- link(href: string, title: string | null | undefined, text: string): string;
203
- image(href: string, title: string | null, text: string): string;
204
- br(): string;
205
- }
206
-
207
- /**
208
- * Slugger generates header id
209
- */
210
- declare class _Slugger {
211
- seen: {
212
- [slugValue: string]: number;
213
- };
214
- constructor();
215
- serialize(value: string): string;
216
- /**
217
- * Finds the next safe (unique) slug to use
218
- */
219
- getNextSafeSlug(originalSlug: string, isDryRun: boolean | undefined): string;
220
- /**
221
- * Convert string to unique id
222
- */
223
- slug(value: string, options?: SluggerOptions): string;
224
- }
225
-
226
- /**
227
- * Parsing & Compiling
228
- */
229
- declare class _Parser {
230
- options: MarkedOptions;
231
- renderer: _Renderer;
232
- textRenderer: _TextRenderer;
233
- slugger: _Slugger;
234
- constructor(options?: MarkedOptions);
235
- /**
236
- * Static Parse Method
237
- */
238
- static parse(tokens: Token[], options?: MarkedOptions): string;
239
- /**
240
- * Static Parse Inline Method
241
- */
242
- static parseInline(tokens: Token[], options?: MarkedOptions): string;
243
- /**
244
- * Parse Loop
245
- */
246
- parse(tokens: Token[], top?: boolean): string;
247
- /**
248
- * Parse Inline Tokens
249
- */
250
- parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
251
- }
252
-
253
- /**
254
- * Tokenizer
255
- */
256
- declare class _Tokenizer {
257
- options: MarkedOptions;
258
- rules: any;
259
- lexer: _Lexer;
260
- constructor(options?: MarkedOptions);
261
- space(src: string): Tokens.Space | undefined;
262
- code(src: string): Tokens.Code | undefined;
263
- fences(src: string): Tokens.Code | undefined;
264
- heading(src: string): Tokens.Heading | undefined;
265
- hr(src: string): Tokens.Hr | undefined;
266
- blockquote(src: string): Tokens.Blockquote | undefined;
267
- list(src: string): Tokens.List | undefined;
268
- html(src: string): Tokens.HTML | Tokens.Paragraph | undefined;
269
- def(src: string): Tokens.Def | undefined;
270
- table(src: string): Tokens.Table | undefined;
271
- lheading(src: string): Tokens.Heading | undefined;
272
- paragraph(src: string): Tokens.Paragraph | undefined;
273
- text(src: string): Tokens.Text | undefined;
274
- escape(src: string): Tokens.Escape | undefined;
275
- tag(src: string): Tokens.Tag | undefined;
276
- link(src: string): Tokens.Link | Tokens.Image | undefined;
277
- reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
278
- emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
279
- codespan(src: string): Tokens.Codespan | undefined;
280
- br(src: string): Tokens.Br | undefined;
281
- del(src: string): Tokens.Del | undefined;
282
- autolink(src: string, mangle: (cap: string) => string): Tokens.Link | undefined;
283
- url(src: string, mangle: (cap: string) => string): Tokens.Link | undefined;
284
- inlineText(src: string, smartypants: (cap: string) => string): Tokens.Text | undefined;
285
- }
286
-
287
- interface SluggerOptions {
288
- /** Generates the next unique slug without updating the internal accumulator. */
289
- dryrun?: boolean;
290
- }
291
- interface TokenizerThis {
292
- lexer: _Lexer;
293
- }
294
- interface TokenizerExtension {
295
- name: string;
296
- level: 'block' | 'inline';
297
- start?: ((this: TokenizerThis, src: string) => number | void) | undefined;
298
- tokenizer: (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | void;
299
- childTokens?: string[] | undefined;
300
- }
301
- interface RendererThis {
302
- parser: _Parser;
303
- }
304
- interface RendererExtension {
305
- name: string;
306
- renderer: (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
618
+ declare module "Hooks" {
619
+ import type { MarkedOptions } from "MarkedOptions";
620
+ export class _Hooks {
621
+ options: MarkedOptions;
622
+ constructor(options?: MarkedOptions);
623
+ static passThroughHooks: Set<string>;
624
+ /**
625
+ * Process markdown before marked
626
+ */
627
+ preprocess(markdown: string): string;
628
+ /**
629
+ * Process HTML after marked is finished
630
+ */
631
+ postprocess(html: string): string;
632
+ }
307
633
  }
308
- type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
309
- type RendererApi = Omit<_Renderer, 'constructor' | 'options'>;
310
- type RendererObject = {
311
- [K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
312
- };
313
- type TokenizerApi = Omit<_Tokenizer, 'constructor' | 'options' | 'rules' | 'lexer'>;
314
- type TokenizerObject = {
315
- [K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
316
- };
317
- interface MarkedExtension {
318
- /**
319
- * True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
320
- */
321
- async?: boolean;
322
- /**
323
- * A prefix URL for any relative link.
324
- * @deprecated Deprecated in v5.0.0 use marked-base-url to prefix url for any relative link.
325
- */
326
- baseUrl?: string | undefined | null;
327
- /**
328
- * Enable GFM line breaks. This option requires the gfm option to be true.
329
- */
330
- breaks?: boolean | undefined;
331
- /**
332
- * Add tokenizers and renderers to marked
333
- */
334
- extensions?: TokenizerAndRendererExtension[] | undefined | null;
335
- /**
336
- * Enable GitHub flavored markdown.
337
- */
338
- gfm?: boolean | undefined;
339
- /**
340
- * Include an id attribute when emitting headings.
341
- * @deprecated Deprecated in v5.0.0 use marked-gfm-heading-id to include an id attribute when emitting headings (h1, h2, h3, etc).
342
- */
343
- headerIds?: boolean | undefined;
344
- /**
345
- * Set the prefix for header tag ids.
346
- * @deprecated Deprecated in v5.0.0 use marked-gfm-heading-id to add a string to prefix the id attribute when emitting headings (h1, h2, h3, etc).
347
- */
348
- headerPrefix?: string | undefined;
349
- /**
350
- * A function to highlight code blocks. The function can either be
351
- * synchronous (returning a string) or asynchronous (callback invoked
352
- * with an error if any occurred during highlighting and a string
353
- * if highlighting was successful)
354
- * @deprecated Deprecated in v5.0.0 use marked-highlight to add highlighting to code blocks.
355
- */
356
- highlight?: ((code: string, lang: string | undefined, callback?: (error: Error, code?: string) => void) => string | void) | null;
357
- /**
358
- * Hooks are methods that hook into some part of marked.
359
- * preprocess is called to process markdown before sending it to marked.
360
- * postprocess is called to process html after marked has finished parsing.
361
- */
362
- hooks?: {
363
- preprocess: (markdown: string) => string;
364
- postprocess: (html: string | undefined) => string | undefined;
365
- options?: MarkedOptions;
366
- } | null;
367
- /**
368
- * Set the prefix for code block classes.
369
- * @deprecated Deprecated in v5.0.0 use marked-highlight to prefix the className in a <code> block. Useful for syntax highlighting.
370
- */
371
- langPrefix?: string | undefined;
372
- /**
373
- * Mangle autolinks (<email@domain.com>).
374
- * @deprecated Deprecated in v5.0.0 use marked-mangle to mangle email addresses.
375
- */
376
- mangle?: boolean | undefined;
377
- /**
378
- * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
379
- */
380
- pedantic?: boolean | undefined;
381
- /**
382
- * Type: object Default: new Renderer()
634
+ declare module "marked" {
635
+ import { _Lexer } from "Lexer";
636
+ import { _Parser } from "Parser";
637
+ import { _Tokenizer } from "Tokenizer";
638
+ import { _Renderer } from "Renderer";
639
+ import { _TextRenderer } from "TextRenderer";
640
+ import { _Slugger } from "Slugger";
641
+ import { _Hooks } from "Hooks";
642
+ import { _getDefaults } from "defaults";
643
+ import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
644
+ import type { Token, TokensList } from "Tokens";
645
+ import type { ResultCallback } from "Instance";
646
+ /**
647
+ * Compiles markdown to HTML asynchronously.
383
648
  *
384
- * An object containing functions to render tokens to HTML.
385
- */
386
- renderer?: RendererObject | undefined | null;
387
- /**
388
- * Sanitize the output. Ignore any HTML that has been input. If true, sanitize the HTML passed into markdownString with the sanitizer function.
389
- * @deprecated Warning: This feature is deprecated and it should NOT be used as it cannot be considered secure. Instead use a sanitize library, like DOMPurify (recommended), sanitize-html or insane on the output HTML!
390
- */
391
- sanitize?: boolean | undefined;
392
- /**
393
- * Optionally sanitize found HTML with a sanitizer function.
394
- * @deprecated A function to sanitize the HTML passed into markdownString.
395
- */
396
- sanitizer?: ((html: string) => string) | null;
397
- /**
398
- * Shows an HTML error message when rendering fails.
399
- */
400
- silent?: boolean | undefined;
401
- /**
402
- * Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
403
- */
404
- smartLists?: boolean | undefined;
405
- /**
406
- * Use "smart" typograhic punctuation for things like quotes and dashes.
407
- * @deprecated Deprecated in v5.0.0 use marked-smartypants to use "smart" typographic punctuation for things like quotes and dashes.
408
- */
409
- smartypants?: boolean | undefined;
410
- /**
411
- * The tokenizer defines how to turn markdown text into tokens.
412
- */
413
- tokenizer?: TokenizerObject | undefined | null;
414
- /**
415
- * The walkTokens function gets called with every token.
416
- * Child tokens are called before moving on to sibling tokens.
417
- * Each token is passed by reference so updates are persisted when passed to the parser.
418
- * The return value of the function is ignored.
419
- */
420
- walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
421
- /**
422
- * Generate closing slash for self-closing tags (<br/> instead of <br>)
423
- * @deprecated Deprecated in v5.0.0 use marked-xhtml to emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML.
649
+ * @param src String of markdown source to be compiled
650
+ * @param options Hash of options, having async: true
651
+ * @return Promise of string of compiled HTML
424
652
  */
425
- xhtml?: boolean | undefined;
426
- }
427
- interface MarkedOptions extends Omit<MarkedExtension, 'extensions' | 'renderer' | 'tokenizer' | 'walkTokens'> {
653
+ export function marked(src: string, options: MarkedOptions & {
654
+ async: true;
655
+ }): Promise<string>;
428
656
  /**
429
- * Type: object Default: new Renderer()
657
+ * Compiles markdown to HTML synchronously.
430
658
  *
431
- * An object containing functions to render tokens to HTML.
432
- */
433
- renderer?: Omit<_Renderer, 'constructor'> | undefined | null;
434
- /**
435
- * The tokenizer defines how to turn markdown text into tokens.
436
- */
437
- tokenizer?: Omit<_Tokenizer, 'constructor'> | undefined | null;
438
- /**
439
- * The walkTokens function gets called with every token.
440
- * Child tokens are called before moving on to sibling tokens.
441
- * Each token is passed by reference so updates are persisted when passed to the parser.
442
- * The return value of the function is ignored.
443
- */
444
- walkTokens?: ((token: Token) => void | Promise<void> | Array<void | Promise<void>>) | undefined | null;
445
- /**
446
- * Add tokenizers and renderers to marked
659
+ * @param src String of markdown source to be compiled
660
+ * @param options Optional hash of options
661
+ * @return String of compiled HTML
447
662
  */
448
- extensions?: (TokenizerAndRendererExtension[] & {
449
- renderers: Record<string, (this: RendererThis, token: Tokens.Generic) => string | false | undefined>;
450
- childTokens: Record<string, string[]>;
451
- block: any[];
452
- inline: any[];
453
- startBlock: Array<(this: TokenizerThis, src: string) => number | void>;
454
- startInline: Array<(this: TokenizerThis, src: string) => number | void>;
455
- }) | undefined | null;
456
- }
457
-
458
- type Rule = RegExp | string;
459
- interface Rules {
460
- [ruleName: string]: Pick<RegExp, 'exec'> | Rule | Rules;
461
- }
462
- type BlockRuleNames = 'newline' | 'code' | 'fences' | 'hr' | 'heading' | 'blockquote' | 'list' | 'html' | 'def' | 'lheading' | '_paragraph' | 'text' | '_label' | '_title' | 'bullet' | 'listItemStart' | '_tag' | '_comment' | 'paragraph' | 'uote';
463
- type BlockSubRuleNames = 'normal' | 'gfm' | 'pedantic';
464
- type InlineRuleNames = 'escape' | 'autolink' | 'tag' | 'link' | 'reflink' | 'nolink' | 'reflinkSearch' | 'code' | 'br' | 'text' | '_punctuation' | 'punctuation' | 'blockSkip' | 'escapedEmSt' | '_comment' | '_escapes' | '_scheme' | '_email' | '_attribute' | '_label' | '_href' | '_title' | 'strong' | '_extended_email' | '_backpedal';
465
- type InlineSubRuleNames = 'gfm' | 'emStrong' | 'normal' | 'pedantic' | 'breaks';
466
- /**
467
- * Block-Level Grammar
468
- */
469
- declare const block: Record<BlockRuleNames, Rule> & Record<BlockSubRuleNames, Rules> & Rules;
470
- /**
471
- * Inline-Level Grammar
472
- */
473
- declare const inline: Record<InlineRuleNames, Rule> & Record<InlineSubRuleNames, Rules> & Rules;
474
-
475
- /**
476
- * Block Lexer
477
- */
478
- declare class _Lexer {
479
- tokens: TokensList;
480
- options: MarkedOptions;
481
- state: {
482
- inLink: boolean;
483
- inRawBlock: boolean;
484
- top: boolean;
485
- };
486
- private tokenizer;
487
- private inlineQueue;
488
- constructor(options?: MarkedOptions);
489
- /**
490
- * Expose Rules
491
- */
492
- static get rules(): Rules;
493
- /**
494
- * Static Lex Method
495
- */
496
- static lex(src: string, options?: MarkedOptions): TokensList;
663
+ export function marked(src: string, options?: MarkedOptions): string;
497
664
  /**
498
- * Static Lex Inline Method
499
- */
500
- static lexInline(src: string, options?: MarkedOptions): Token[];
501
- /**
502
- * Preprocessing
503
- */
504
- lex(src: string): TokensList;
505
- /**
506
- * Lexing
507
- */
508
- blockTokens(src: string, tokens?: Token[]): Token[];
509
- blockTokens(src: string, tokens?: TokensList): TokensList;
510
- inline(src: string, tokens?: Token[]): Token[];
511
- /**
512
- * Lexing/Compiling
513
- */
514
- inlineTokens(src: string, tokens?: Token[]): Token[];
515
- }
516
-
517
- declare class _Hooks {
518
- options: MarkedOptions;
519
- constructor(options?: MarkedOptions);
520
- static passThroughHooks: Set<string>;
521
- /**
522
- * Process markdown before marked
665
+ * Compiles markdown to HTML asynchronously with a callback.
666
+ *
667
+ * @param src String of markdown source to be compiled
668
+ * @param callback Function called when the markdownString has been fully parsed when using async highlighting
523
669
  */
524
- preprocess(markdown: string): string;
670
+ export function marked(src: string, callback: ResultCallback): void;
525
671
  /**
526
- * Process HTML after marked is finished
672
+ * Compiles markdown to HTML asynchronously with a callback.
673
+ *
674
+ * @param src String of markdown source to be compiled
675
+ * @param options Hash of options
676
+ * @param callback Function called when the markdownString has been fully parsed when using async highlighting
527
677
  */
528
- postprocess(html: string | undefined): string | undefined;
529
- }
530
-
531
- type ResultCallback$1 = (error: Error | null, parseResult?: string) => undefined | void;
532
- declare class Marked {
533
- #private;
534
- defaults: MarkedOptions;
535
- options: (opt: any) => this;
536
- parse: (src: string, optOrCallback?: MarkedOptions | ResultCallback$1 | undefined | null, callback?: ResultCallback$1 | undefined) => string | Promise<string | undefined> | undefined;
537
- parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback$1 | undefined | null, callback?: ResultCallback$1 | undefined) => string | Promise<string | undefined> | undefined;
538
- Parser: typeof _Parser;
539
- parser: typeof _Parser.parse;
540
- Renderer: typeof _Renderer;
541
- TextRenderer: typeof _TextRenderer;
542
- Lexer: typeof _Lexer;
543
- lexer: typeof _Lexer.lex;
544
- Tokenizer: typeof _Tokenizer;
545
- Slugger: typeof _Slugger;
546
- Hooks: typeof _Hooks;
547
- constructor(...args: MarkedExtension[]);
678
+ export function marked(src: string, options: MarkedOptions, callback: ResultCallback): void;
548
679
  /**
549
- * Run callback for every token
550
- */
551
- walkTokens<T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]): T[];
552
- use(...args: MarkedExtension[]): this;
553
- setOptions(opt: any): this;
554
- }
555
-
556
- /**
557
- * Gets the original marked default options.
558
- */
559
- declare function _getDefaults(): MarkedOptions;
560
- declare let _defaults: MarkedOptions;
561
-
562
- type ResultCallback = (error: Error | null, parseResult?: string) => undefined | void;
563
- /**
564
- * Compiles markdown to HTML asynchronously.
565
- *
566
- * @param src String of markdown source to be compiled
567
- * @param options Hash of options, having async: true
568
- * @return Promise of string of compiled HTML
569
- */
570
- declare function marked(src: string, options: MarkedOptions & {
571
- async: true;
572
- }): Promise<string>;
573
- /**
574
- * Compiles markdown to HTML synchronously.
575
- *
576
- * @param src String of markdown source to be compiled
577
- * @param options Optional hash of options
578
- * @return String of compiled HTML
579
- */
580
- declare function marked(src: string, options?: MarkedOptions): string;
581
- /**
582
- * Compiles markdown to HTML asynchronously with a callback.
583
- *
584
- * @param src String of markdown source to be compiled
585
- * @param callback Function called when the markdownString has been fully parsed when using async highlighting
586
- */
587
- declare function marked(src: string, callback: ResultCallback): void;
588
- /**
589
- * Compiles markdown to HTML asynchronously with a callback.
590
- *
591
- * @param src String of markdown source to be compiled
592
- * @param options Hash of options
593
- * @param callback Function called when the markdownString has been fully parsed when using async highlighting
594
- */
595
- declare function marked(src: string, options: MarkedOptions, callback: ResultCallback): void;
596
- declare namespace marked {
597
- var options: (options: MarkedOptions) => typeof marked;
598
- var setOptions: (options: MarkedOptions) => typeof marked;
599
- var getDefaults: typeof _getDefaults;
600
- var defaults: MarkedOptions;
601
- var use: (...args: MarkedExtension[]) => typeof marked;
602
- var walkTokens: <T = void>(tokens: TokensList | Token[], callback: (token: Token) => T | T[]) => T[];
603
- var parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback$1 | null | undefined, callback?: ResultCallback$1 | undefined) => string | Promise<string | undefined> | undefined;
604
- var Parser: typeof _Parser;
605
- var parser: typeof _Parser.parse;
606
- var Renderer: typeof _Renderer;
607
- var TextRenderer: typeof _TextRenderer;
608
- var Lexer: typeof _Lexer;
609
- var lexer: typeof _Lexer.lex;
610
- var Tokenizer: typeof _Tokenizer;
611
- var Slugger: typeof _Slugger;
612
- var Hooks: typeof _Hooks;
613
- var parse: typeof marked;
680
+ * Compiles markdown to HTML asynchronously with a callback.
681
+ *
682
+ * @param src String of markdown source to be compiled
683
+ * @param options Hash of options
684
+ * @param callback Function called when the markdownString has been fully parsed when using async highlighting
685
+ */
686
+ export namespace marked {
687
+ var options: (options: MarkedOptions) => typeof marked;
688
+ var setOptions: (options: MarkedOptions) => typeof marked;
689
+ var getDefaults: typeof _getDefaults;
690
+ var defaults: MarkedOptions;
691
+ var use: (...args: MarkedExtension[]) => typeof marked;
692
+ var walkTokens: <T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]) => T[];
693
+ var parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | null | undefined, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
694
+ var Parser: typeof _Parser;
695
+ var parser: typeof _Parser.parse;
696
+ var Renderer: typeof _Renderer;
697
+ var TextRenderer: typeof _TextRenderer;
698
+ var Lexer: typeof _Lexer;
699
+ var lexer: typeof _Lexer.lex;
700
+ var Tokenizer: typeof _Tokenizer;
701
+ var Slugger: typeof _Slugger;
702
+ var Hooks: typeof _Hooks;
703
+ var parse: typeof marked;
704
+ }
705
+ export const options: (options: MarkedOptions) => typeof marked;
706
+ export const setOptions: (options: MarkedOptions) => typeof marked;
707
+ export const use: (...args: MarkedExtension[]) => typeof marked;
708
+ export const walkTokens: <T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]) => T[];
709
+ export const parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | null | undefined, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
710
+ export const parse: typeof marked;
711
+ export const parser: typeof _Parser.parse;
712
+ export const lexer: typeof _Lexer.lex;
713
+ export { _defaults as defaults, _getDefaults as getDefaults } from "defaults";
714
+ export { _Lexer as Lexer } from "Lexer";
715
+ export { _Parser as Parser } from "Parser";
716
+ export { _Tokenizer as Tokenizer } from "Tokenizer";
717
+ export { _Renderer as Renderer } from "Renderer";
718
+ export { _TextRenderer as TextRenderer } from "TextRenderer";
719
+ export { _Slugger as Slugger } from "Slugger";
720
+ export { _Hooks as Hooks } from "Hooks";
721
+ export { Marked } from "Instance";
722
+ export type * from "MarkedOptions";
723
+ export type * from "rules";
724
+ export type * from "Tokens";
614
725
  }
615
- declare const options: (options: MarkedOptions) => typeof marked;
616
- declare const setOptions: (options: MarkedOptions) => typeof marked;
617
- declare const use: (...args: MarkedExtension[]) => typeof marked;
618
- declare const walkTokens: <T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]) => T[];
619
- declare const parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback$1 | null | undefined, callback?: ResultCallback$1 | undefined) => string | Promise<string | undefined> | undefined;
620
- declare const parse: typeof marked;
621
- declare const parser: typeof _Parser.parse;
622
- declare const lexer: typeof _Lexer.lex;
623
-
624
- export { _Hooks as Hooks, _Lexer as Lexer, Links, Marked, MarkedExtension, MarkedOptions, _Parser as Parser, _Renderer as Renderer, RendererExtension, RendererThis, ResultCallback, Rule, Rules, _Slugger as Slugger, SluggerOptions, _TextRenderer as TextRenderer, Token, _Tokenizer as Tokenizer, TokenizerAndRendererExtension, TokenizerExtension, TokenizerThis, Tokens, TokensList, block, _defaults as defaults, _getDefaults as getDefaults, inline, lexer, marked, options, parse, parseInline, parser, setOptions, use, walkTokens };