1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export function marked(src: string, options?: marked.MarkedOptions): string;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | export function marked(src: string, callback: (error: any, parseResult: string) => void): void;
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | export function marked(
|
40 | src: string,
|
41 | options: marked.MarkedOptions,
|
42 | callback: (error: any, parseResult: string) => void,
|
43 | ): void;
|
44 |
|
45 | export class Lexer extends marked.Lexer {}
|
46 | export class Parser extends marked.Parser {}
|
47 | export class Tokenizer<T = never> extends marked.Tokenizer<T> {}
|
48 | export class Renderer<T = never> extends marked.Renderer<T> {}
|
49 | export class TextRenderer extends marked.TextRenderer {}
|
50 | export class Slugger extends marked.Slugger {}
|
51 |
|
52 | export namespace marked {
|
53 | const defaults: MarkedOptions;
|
54 |
|
55 | |
56 |
|
57 |
|
58 |
|
59 | function lexer(src: string, options?: MarkedOptions): TokensList;
|
60 |
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | function parse(src: string, callback: (error: any, parseResult: string) => void): string;
|
69 |
|
70 | |
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | function parse(
|
79 | src: string,
|
80 | options?: MarkedOptions,
|
81 | callback?: (error: any, parseResult: string) => void,
|
82 | ): string;
|
83 |
|
84 | |
85 |
|
86 |
|
87 |
|
88 | function parser(src: Token[] | TokensList, options?: MarkedOptions): string;
|
89 |
|
90 | |
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 | function parseInline(src: string, options?: MarkedOptions): string;
|
98 |
|
99 | |
100 |
|
101 |
|
102 |
|
103 |
|
104 | function options(options: MarkedOptions): typeof marked;
|
105 |
|
106 | |
107 |
|
108 |
|
109 |
|
110 |
|
111 | function setOptions(options: MarkedOptions): typeof marked;
|
112 |
|
113 | |
114 |
|
115 |
|
116 | function getDefaults(): MarkedOptions;
|
117 |
|
118 | function walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => void): typeof marked;
|
119 |
|
120 | |
121 |
|
122 |
|
123 |
|
124 | function use(...extensions: MarkedExtension[]): void;
|
125 |
|
126 | class Tokenizer<T = never> {
|
127 | constructor(options?: MarkedOptions);
|
128 | options: MarkedOptions;
|
129 | space(this: TokenizerThis, src: string): Tokens.Space | T;
|
130 | code(this: TokenizerThis, src: string): Tokens.Code | T;
|
131 | fences(this: TokenizerThis, src: string): Tokens.Code | T;
|
132 | heading(this: TokenizerThis, src: string): Tokens.Heading | T;
|
133 | hr(this: TokenizerThis, src: string): Tokens.Hr | T;
|
134 | blockquote(this: TokenizerThis, src: string): Tokens.Blockquote | T;
|
135 | list(this: TokenizerThis, src: string): Tokens.List | T;
|
136 | html(this: TokenizerThis, src: string): Tokens.HTML | T;
|
137 | def(this: TokenizerThis, src: string): Tokens.Def | T;
|
138 | table(this: TokenizerThis, src: string): Tokens.Table | T;
|
139 | lheading(this: TokenizerThis, src: string): Tokens.Heading | T;
|
140 | paragraph(this: TokenizerThis, src: string): Tokens.Paragraph | T;
|
141 | text(this: TokenizerThis, src: string): Tokens.Text | T;
|
142 | escape(this: TokenizerThis, src: string): Tokens.Escape | T;
|
143 | tag(this: TokenizerThis, src: string): Tokens.Tag | T;
|
144 | link(this: TokenizerThis, src: string): Tokens.Image | Tokens.Link | T;
|
145 | reflink(
|
146 | this: TokenizerThis,
|
147 | src: string,
|
148 | links: Tokens.Link[] | Tokens.Image[],
|
149 | ): Tokens.Link | Tokens.Image | Tokens.Text | T;
|
150 | emStrong(this: TokenizerThis, src: string, maskedSrc: string, prevChar: string): Tokens.Em | Tokens.Strong | T;
|
151 | codespan(this: TokenizerThis, src: string): Tokens.Codespan | T;
|
152 | br(this: TokenizerThis, src: string): Tokens.Br | T;
|
153 | del(this: TokenizerThis, src: string): Tokens.Del | T;
|
154 | autolink(this: TokenizerThis, src: string, mangle: (cap: string) => string): Tokens.Link | T;
|
155 | url(this: TokenizerThis, src: string, mangle: (cap: string) => string): Tokens.Link | T;
|
156 | inlineText(this: TokenizerThis, src: string, smartypants: (cap: string) => string): Tokens.Text | T;
|
157 | }
|
158 |
|
159 | type TokenizerObject = Partial<Omit<Tokenizer<false>, 'constructor' | 'options'>>;
|
160 |
|
161 | class Renderer<T = never> {
|
162 | constructor(options?: MarkedOptions);
|
163 | options: MarkedOptions;
|
164 | code(this: RendererThis, code: string, language: string | undefined, isEscaped: boolean): string | T;
|
165 | blockquote(this: RendererThis, quote: string): string | T;
|
166 | html(this: RendererThis, html: string): string | T;
|
167 | heading(
|
168 | this: RendererThis,
|
169 | text: string,
|
170 | level: 1 | 2 | 3 | 4 | 5 | 6,
|
171 | raw: string,
|
172 | slugger: Slugger,
|
173 | ): string | T;
|
174 | hr(this: RendererThis): string | T;
|
175 | list(this: RendererThis, body: string, ordered: boolean, start: number): string | T;
|
176 | listitem(this: RendererThis, text: string, task: boolean, checked: boolean): string | T;
|
177 | checkbox(this: RendererThis, checked: boolean): string | T;
|
178 | paragraph(this: RendererThis, text: string): string | T;
|
179 | table(this: RendererThis, header: string, body: string): string | T;
|
180 | tablerow(this: RendererThis, content: string): string | T;
|
181 | tablecell(
|
182 | this: RendererThis,
|
183 | content: string,
|
184 | flags: {
|
185 | header: boolean;
|
186 | align: 'center' | 'left' | 'right' | null;
|
187 | },
|
188 | ): string | T;
|
189 | strong(this: RendererThis, text: string): string | T;
|
190 | em(this: RendererThis, text: string): string | T;
|
191 | codespan(this: RendererThis, code: string): string | T;
|
192 | br(this: RendererThis): string | T;
|
193 | del(this: RendererThis, text: string): string | T;
|
194 | link(this: RendererThis, href: string | null, title: string | null, text: string): string | T;
|
195 | image(this: RendererThis, href: string | null, title: string | null, text: string): string | T;
|
196 | text(this: RendererThis, text: string): string | T;
|
197 | }
|
198 |
|
199 | type RendererObject = Partial<Omit<Renderer<false>, 'constructor' | 'options'>>;
|
200 |
|
201 | class TextRenderer {
|
202 | strong(text: string): string;
|
203 | em(text: string): string;
|
204 | codespan(text: string): string;
|
205 | del(text: string): string;
|
206 | text(text: string): string;
|
207 | link(href: string | null, title: string | null, text: string): string;
|
208 | image(href: string | null, title: string | null, text: string): string;
|
209 | br(): string;
|
210 | html(text: string): string;
|
211 | }
|
212 |
|
213 | class Parser {
|
214 | constructor(options?: MarkedOptions);
|
215 | tokens: Token[] | TokensList;
|
216 | token: Token | null;
|
217 | options: MarkedOptions;
|
218 | renderer: Renderer;
|
219 | textRenderer: TextRenderer;
|
220 | slugger: Slugger;
|
221 | static parse(src: Token[] | TokensList, options?: MarkedOptions): string;
|
222 | static parseInline(src: Token[], options?: MarkedOptions): string;
|
223 | parse(src: Token[] | TokensList): string;
|
224 | parseInline(src: Token[], renderer: Renderer): string;
|
225 | next(): Token;
|
226 | }
|
227 |
|
228 | class Lexer {
|
229 | constructor(options?: MarkedOptions);
|
230 | tokens: TokensList;
|
231 | options: MarkedOptions;
|
232 | rules: Rules;
|
233 | static rules: Rules;
|
234 | static lex(src: string, options?: MarkedOptions): TokensList;
|
235 | static lexInline(src: string, options?: MarkedOptions): Token[];
|
236 | lex(src: string): TokensList;
|
237 | blockTokens(src: string, tokens: Token[]): Token[];
|
238 | blockTokens(src: string, tokens: TokensList): TokensList;
|
239 | inline(src: string, tokens: Token[]): void;
|
240 | inlineTokens(src: string, tokens: Token[]): Token[];
|
241 | state: {
|
242 | inLink: boolean;
|
243 | inRawBlock: boolean;
|
244 | top: boolean;
|
245 | };
|
246 | }
|
247 |
|
248 | class Slugger {
|
249 | seen: { [slugValue: string]: number };
|
250 | slug(value: string, options?: SluggerOptions): string;
|
251 | }
|
252 |
|
253 | interface SluggerOptions {
|
254 | dryrun: boolean;
|
255 | }
|
256 |
|
257 | interface Rules {
|
258 | [ruleName: string]: RegExp | Rules;
|
259 | }
|
260 |
|
261 | type TokensList = Token[] & {
|
262 | links: {
|
263 | [key: string]: { href: string | null; title: string | null };
|
264 | };
|
265 | };
|
266 |
|
267 | type Token =
|
268 | | Tokens.Space
|
269 | | Tokens.Code
|
270 | | Tokens.Heading
|
271 | | Tokens.Table
|
272 | | Tokens.Hr
|
273 | | Tokens.Blockquote
|
274 | | Tokens.List
|
275 | | Tokens.ListItem
|
276 | | Tokens.Paragraph
|
277 | | Tokens.HTML
|
278 | | Tokens.Text
|
279 | | Tokens.Def
|
280 | | Tokens.Escape
|
281 | | Tokens.Tag
|
282 | | Tokens.Image
|
283 | | Tokens.Link
|
284 | | Tokens.Strong
|
285 | | Tokens.Em
|
286 | | Tokens.Codespan
|
287 | | Tokens.Br
|
288 | | Tokens.Del;
|
289 |
|
290 | namespace Tokens {
|
291 | interface Space {
|
292 | type: 'space';
|
293 | raw: string;
|
294 | }
|
295 |
|
296 | interface Code {
|
297 | type: 'code';
|
298 | raw: string;
|
299 | codeBlockStyle?: 'indented' | undefined;
|
300 | lang?: string | undefined;
|
301 | text: string;
|
302 | }
|
303 |
|
304 | interface Heading {
|
305 | type: 'heading';
|
306 | raw: string;
|
307 | depth: number;
|
308 | text: string;
|
309 | tokens: Token[];
|
310 | }
|
311 |
|
312 | interface Table {
|
313 | type: 'table';
|
314 | raw: string;
|
315 | align: Array<'center' | 'left' | 'right' | null>;
|
316 | header: TableCell[];
|
317 | rows: TableCell[][];
|
318 | }
|
319 |
|
320 | interface TableCell {
|
321 | text: string;
|
322 | tokens: Token[];
|
323 | }
|
324 |
|
325 | interface Hr {
|
326 | type: 'hr';
|
327 | raw: string;
|
328 | }
|
329 |
|
330 | interface Blockquote {
|
331 | type: 'blockquote';
|
332 | raw: string;
|
333 | text: string;
|
334 | tokens: Token[];
|
335 | }
|
336 |
|
337 | interface List {
|
338 | type: 'list';
|
339 | raw: string;
|
340 | ordered: boolean;
|
341 | start: number | '';
|
342 | loose: boolean;
|
343 | items: ListItem[];
|
344 | }
|
345 |
|
346 | interface ListItem {
|
347 | type: 'list_item';
|
348 | raw: string;
|
349 | task: boolean;
|
350 | checked?: boolean | undefined;
|
351 | loose: boolean;
|
352 | text: string;
|
353 | tokens: Token[];
|
354 | }
|
355 |
|
356 | interface Paragraph {
|
357 | type: 'paragraph';
|
358 | raw: string;
|
359 | pre?: boolean | undefined;
|
360 | text: string;
|
361 | tokens: Token[];
|
362 | }
|
363 |
|
364 | interface HTML {
|
365 | type: 'html';
|
366 | raw: string;
|
367 | pre: boolean;
|
368 | text: string;
|
369 | }
|
370 |
|
371 | interface Text {
|
372 | type: 'text';
|
373 | raw: string;
|
374 | text: string;
|
375 | tokens?: Token[] | undefined;
|
376 | }
|
377 |
|
378 | interface Def {
|
379 | type: 'def';
|
380 | raw: string;
|
381 | tag: string;
|
382 | href: string;
|
383 | title: string;
|
384 | }
|
385 |
|
386 | interface Escape {
|
387 | type: 'escape';
|
388 | raw: string;
|
389 | text: string;
|
390 | }
|
391 |
|
392 | interface Tag {
|
393 | type: 'text' | 'html';
|
394 | raw: string;
|
395 | inLink: boolean;
|
396 | inRawBlock: boolean;
|
397 | text: string;
|
398 | }
|
399 |
|
400 | interface Link {
|
401 | type: 'link';
|
402 | raw: string;
|
403 | href: string;
|
404 | title: string;
|
405 | text: string;
|
406 | tokens: Token[];
|
407 | }
|
408 |
|
409 | interface Image {
|
410 | type: 'image';
|
411 | raw: string;
|
412 | href: string;
|
413 | title: string;
|
414 | text: string;
|
415 | }
|
416 |
|
417 | interface Strong {
|
418 | type: 'strong';
|
419 | raw: string;
|
420 | text: string;
|
421 | tokens: Token[];
|
422 | }
|
423 |
|
424 | interface Em {
|
425 | type: 'em';
|
426 | raw: string;
|
427 | text: string;
|
428 | tokens: Token[];
|
429 | }
|
430 |
|
431 | interface Codespan {
|
432 | type: 'codespan';
|
433 | raw: string;
|
434 | text: string;
|
435 | }
|
436 |
|
437 | interface Br {
|
438 | type: 'br';
|
439 | raw: string;
|
440 | }
|
441 |
|
442 | interface Del {
|
443 | type: 'del';
|
444 | raw: string;
|
445 | text: string;
|
446 | tokens: Token[];
|
447 | }
|
448 |
|
449 | interface Generic {
|
450 | [index: string]: any;
|
451 | type: string;
|
452 | raw: string;
|
453 | tokens?: Token[] | undefined;
|
454 | }
|
455 | }
|
456 |
|
457 | interface TokenizerThis {
|
458 | lexer: Lexer;
|
459 | }
|
460 |
|
461 | interface TokenizerExtension {
|
462 | name: string;
|
463 | level: 'block' | 'inline';
|
464 | start?: ((this: TokenizerThis, src: string) => number) | undefined;
|
465 | tokenizer: (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | void;
|
466 | childTokens?: string[] | undefined;
|
467 | }
|
468 |
|
469 | interface RendererThis {
|
470 | parser: Parser;
|
471 | }
|
472 |
|
473 | interface RendererExtension {
|
474 | name: string;
|
475 | renderer: (this: RendererThis, token: Tokens.Generic) => string | false;
|
476 | }
|
477 |
|
478 | interface MarkedExtension {
|
479 | |
480 |
|
481 |
|
482 | baseUrl?: string | undefined;
|
483 |
|
484 | |
485 |
|
486 |
|
487 | breaks?: boolean | undefined;
|
488 |
|
489 | |
490 |
|
491 |
|
492 | extensions?:
|
493 | | Array<TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension)>
|
494 | | undefined;
|
495 |
|
496 | |
497 |
|
498 |
|
499 | gfm?: boolean | undefined;
|
500 |
|
501 | |
502 |
|
503 |
|
504 | headerIds?: boolean | undefined;
|
505 |
|
506 | |
507 |
|
508 |
|
509 | headerPrefix?: string | undefined;
|
510 |
|
511 | |
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 | highlight?(
|
518 | code: string,
|
519 | lang: string,
|
520 | callback?: (error: any, code?: string) => void,
|
521 | ): string | void;
|
522 |
|
523 | |
524 |
|
525 |
|
526 | langPrefix?: string | undefined;
|
527 |
|
528 | |
529 |
|
530 |
|
531 | mangle?: boolean | undefined;
|
532 |
|
533 | |
534 |
|
535 |
|
536 | pedantic?: boolean | undefined;
|
537 |
|
538 | |
539 |
|
540 |
|
541 |
|
542 |
|
543 | renderer?: Renderer | RendererObject | undefined;
|
544 |
|
545 | |
546 |
|
547 |
|
548 | sanitize?: boolean | undefined;
|
549 |
|
550 | |
551 |
|
552 |
|
553 | sanitizer?(html: string): string;
|
554 |
|
555 | |
556 |
|
557 |
|
558 | silent?: boolean | undefined;
|
559 |
|
560 | |
561 |
|
562 |
|
563 | smartLists?: boolean | undefined;
|
564 |
|
565 | |
566 |
|
567 |
|
568 | smartypants?: boolean | undefined;
|
569 |
|
570 | |
571 |
|
572 |
|
573 | tokenizer?: Tokenizer | TokenizerObject | undefined;
|
574 |
|
575 | |
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 | walkTokens?: ((token: Token) => void) | undefined;
|
582 | /**
|
583 | * Generate closing slash for self-closing tags (<br/> instead of <br>)
|
584 | */
|
585 | xhtml?: boolean | undefined;
|
586 | }
|
587 |
|
588 | interface MarkedOptions extends Omit<MarkedExtension, 'extensions'> {
|
589 | /**
|
590 | * Type: object Default: new Renderer()
|
591 | *
|
592 | * An object containing functions to render tokens to HTML.
|
593 | */
|
594 | renderer?: Renderer | undefined;
|
595 |
|
596 | /**
|
597 | * The tokenizer defines how to turn markdown text into tokens.
|
598 | */
|
599 | tokenizer?: Tokenizer | undefined;
|
600 | }
|
601 | }
|
602 |
|
\ | No newline at end of file |