1 | import LinkifyIt = require("linkify-it");
|
2 | import mdurl = require("mdurl");
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | declare class Token {
|
8 | |
9 |
|
10 |
|
11 | constructor(type: string, tag: string, nesting: MarkdownIt.Token.Nesting);
|
12 |
|
13 | /**
|
14 | * Type of the token, e.g. "paragraph_open"
|
15 | */
|
16 | type: string;
|
17 |
|
18 | /**
|
19 | * HTML tag name, e.g. "p"
|
20 | */
|
21 | tag: string;
|
22 |
|
23 | /**
|
24 | * HTML attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
|
25 | */
|
26 | attrs: Array<[string, string]> | null;
|
27 |
|
28 | /**
|
29 | * Source map info. Format: `[ line_begin, line_end ]`
|
30 | */
|
31 | map: [number, number] | null;
|
32 |
|
33 | /**
|
34 | * Level change (number in {-1, 0, 1} set), where:
|
35 | *
|
36 | * - `1` means the tag is opening
|
37 | * - `0` means the tag is self-closing
|
38 | * - `-1` means the tag is closing
|
39 | */
|
40 | nesting: MarkdownIt.Token.Nesting;
|
41 |
|
42 | /**
|
43 | * Nesting level, the same as `state.level`
|
44 | */
|
45 | level: number;
|
46 |
|
47 | /**
|
48 | * An array of child nodes (inline and img tokens)
|
49 | */
|
50 | children: Token[] | null;
|
51 |
|
52 | /**
|
53 | * In a case of self-closing tag (code, html, fence, etc.),
|
54 | * it has contents of this tag.
|
55 | */
|
56 | content: string;
|
57 |
|
58 | /**
|
59 | * '*' or '_' for emphasis, fence string for fence, etc.
|
60 | */
|
61 | markup: string;
|
62 |
|
63 | /**
|
64 | * - Info string for "fence" tokens
|
65 | * - The value "auto" for autolink "link_open" and "link_close" tokens
|
66 | * - The string value of the item marker for ordered-list "list_item_open" tokens
|
67 | */
|
68 | info: string;
|
69 |
|
70 | /**
|
71 | * A place for plugins to store an arbitrary data
|
72 | */
|
73 | meta: any;
|
74 |
|
75 | /**
|
76 | * True for block-level tokens, false for inline tokens.
|
77 | * Used in renderer to calculate line breaks
|
78 | */
|
79 | block: boolean;
|
80 |
|
81 | /**
|
82 | * If it's true, ignore this element when rendering. Used for tight lists
|
83 | * to hide paragraphs.
|
84 | */
|
85 | hidden: boolean;
|
86 |
|
87 | /**
|
88 | * Search attribute index by name.
|
89 | */
|
90 | attrIndex(name: string): number;
|
91 |
|
92 | /**
|
93 | * Add `[ name, value ]` attribute to list. Init attrs if necessary
|
94 | */
|
95 | attrPush(attrData: [string, string]): void;
|
96 |
|
97 | /**
|
98 | * Set `name` attribute to `value`. Override old value if exists.
|
99 | */
|
100 | attrSet(name: string, value: string): void;
|
101 |
|
102 | /**
|
103 | * Get the value of attribute `name`, or null if it does not exist.
|
104 | */
|
105 | attrGet(name: string): string | null;
|
106 |
|
107 | /**
|
108 | * Join value to existing attribute via space. Or create new attribute if not
|
109 | * exists. Useful to operate with token classes.
|
110 | */
|
111 | attrJoin(name: string, value: string): void;
|
112 | }
|
113 |
|
114 | type Token_ = Token;
|
115 |
|
116 | // lib/renderer.mjs
|
117 |
|
118 | declare class Renderer {
|
119 | |
120 |
|
121 |
|
122 | constructor();
|
123 |
|
124 | /**
|
125 | * Contains render rules for tokens. Can be updated and extended.
|
126 | *
|
127 | * ##### Example
|
128 | *
|
129 | * ```javascript
|
130 | * var md = require('markdown-it')();
|
131 | *
|
132 | * md.renderer.rules.strong_open = function () { return '<b>'; };
|
133 | * md.renderer.rules.strong_close = function () { return '</b>'; };
|
134 | *
|
135 | * var result = md.renderInline(...);
|
136 | * ```
|
137 | *
|
138 | * Each rule is called as independent static function with fixed signature:
|
139 | *
|
140 | * ```javascript
|
141 | * function my_token_render(tokens, idx, options, env, renderer) {
|
142 | *
|
143 | * return renderedHTML;
|
144 | * }
|
145 | * ```
|
146 | *
|
147 | * @see https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.mjs
|
148 | */
|
149 | rules: MarkdownIt.Renderer.RenderRuleRecord;
|
150 |
|
151 | /**
|
152 | * Render token attributes to string.
|
153 | */
|
154 | renderAttrs(token: Token): string;
|
155 |
|
156 | /**
|
157 | * Default token renderer. Can be overriden by custom function
|
158 | * in {@link Renderer#rules}.
|
159 | *
|
160 | * @param tokens list of tokens
|
161 | * @param idx token index to render
|
162 | * @param options params of parser instance
|
163 | */
|
164 | renderToken(tokens: Token[], idx: number, options: MarkdownIt.Options): string;
|
165 |
|
166 | /**
|
167 | * The same as {@link Renderer.render}, but for single token of `inline` type.
|
168 | *
|
169 | * @param tokens list of block tokens to render
|
170 | * @param options params of parser instance
|
171 | * @param env additional data from parsed input (references, for example)
|
172 | */
|
173 | renderInline(tokens: Token[], options: MarkdownIt.Options, env: any): string;
|
174 |
|
175 | /**
|
176 | * Special kludge for image `alt` attributes to conform CommonMark spec.
|
177 | * Don't try to use it! Spec requires to show `alt` content with stripped markup,
|
178 | * instead of simple escaping.
|
179 | *
|
180 | * @param tokens list of block tokens to render
|
181 | * @param options params of parser instance
|
182 | * @param env additional data from parsed input (references, for example)
|
183 | */
|
184 | renderInlineAsText(tokens: Token[], options: MarkdownIt.Options, env: any): string;
|
185 |
|
186 | /**
|
187 | * Takes token stream and generates HTML. Probably, you will never need to call
|
188 | * this method directly.
|
189 | *
|
190 | * @param tokens list of block tokens to render
|
191 | * @param options params of parser instance
|
192 | * @param env additional data from parsed input (references, for example)
|
193 | */
|
194 | render(tokens: Token[], options: MarkdownIt.Options, env: any): string;
|
195 | }
|
196 |
|
197 | type Renderer_ = Renderer;
|
198 |
|
199 | // lib/ruler.mjs
|
200 |
|
201 | /**
|
202 | * Helper class, used by {@link MarkdownIt#core}, {@link MarkdownIt#block} and
|
203 | * {@link MarkdownIt#inline} to manage sequences of functions (rules):
|
204 | *
|
205 | * - keep rules in defined order
|
206 | * - assign the name to each rule
|
207 | * - enable/disable rules
|
208 | * - add/replace rules
|
209 | * - allow assign rules to additional named chains (in the same)
|
210 | * - caching lists of active rules
|
211 | *
|
212 | * You will not need use this class directly until write plugins. For simple
|
213 | * rules control use {@link MarkdownIt.disable}, {@link MarkdownIt.enable} and
|
214 | * {@link MarkdownIt.use}.
|
215 | */
|
216 | declare class Ruler<T> {
|
217 | constructor();
|
218 |
|
219 | /**
|
220 | * Replace rule by name with new function & options. Throws error if name not
|
221 | * found.
|
222 | *
|
223 | * ##### Example
|
224 | *
|
225 | * Replace existing typographer replacement rule with new one:
|
226 | *
|
227 | * ```javascript
|
228 | * var md = require('markdown-it')();
|
229 | *
|
230 | * md.core.ruler.at('replacements', function replace(state) {
|
231 | *
|
232 | * });
|
233 | * ```
|
234 | *
|
235 | * @param name rule name to replace.
|
236 | * @param fn new rule function.
|
237 | * @param options new rule options (not mandatory).
|
238 | */
|
239 | at(name: string, fn: T, options?: MarkdownIt.Ruler.RuleOptions): void;
|
240 |
|
241 | /**
|
242 | * Add new rule to chain before one with given name.
|
243 | *
|
244 | * ##### Example
|
245 | *
|
246 | * ```javascript
|
247 | * var md = require('markdown-it')();
|
248 | *
|
249 | * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
|
250 | *
|
251 | * });
|
252 | * ```
|
253 | *
|
254 | * @see {@link Ruler.after}, {@link Ruler.push}
|
255 | *
|
256 | * @param beforeName new rule will be added before this one.
|
257 | * @param ruleName name of added rule.
|
258 | * @param fn rule function.
|
259 | * @param options rule options (not mandatory).
|
260 | */
|
261 | before(beforeName: string, ruleName: string, fn: T, options?: MarkdownIt.Ruler.RuleOptions): void;
|
262 |
|
263 | /**
|
264 | * Add new rule to chain after one with given name.
|
265 | *
|
266 | * ##### Example
|
267 | *
|
268 | * ```javascript
|
269 | * var md = require('markdown-it')();
|
270 | *
|
271 | * md.inline.ruler.after('text', 'my_rule', function replace(state) {
|
272 | *
|
273 | * });
|
274 | * ```
|
275 | *
|
276 | * @see {@link Ruler.before}, {@link Ruler.push}
|
277 | *
|
278 | * @param afterName new rule will be added after this one.
|
279 | * @param ruleName name of added rule.
|
280 | * @param fn rule function.
|
281 | * @param options rule options (not mandatory).
|
282 | */
|
283 | after(afterName: string, ruleName: string, fn: T, options?: MarkdownIt.Ruler.RuleOptions): void;
|
284 |
|
285 | /**
|
286 | * Push new rule to the end of chain.
|
287 | *
|
288 | * ##### Example
|
289 | *
|
290 | * ```javascript
|
291 | * var md = require('markdown-it')();
|
292 | *
|
293 | * md.core.ruler.push('my_rule', function replace(state) {
|
294 | *
|
295 | * });
|
296 | * ```
|
297 | *
|
298 | * @see {@link Ruler.before}, {@link Ruler.after}
|
299 | *
|
300 | * @param ruleName name of added rule.
|
301 | * @param fn rule function.
|
302 | * @param options rule options (not mandatory).
|
303 | */
|
304 | push(ruleName: string, fn: T, options?: MarkdownIt.Ruler.RuleOptions): void;
|
305 |
|
306 | /**
|
307 | * Enable rules with given names. If any rule name not found - throw Error.
|
308 | * Errors can be disabled by second param.
|
309 | *
|
310 | * Returns list of found rule names (if no exception happened).
|
311 | *
|
312 | * @see {@link Ruler.disable}, {@link Ruler.enableOnly}
|
313 | *
|
314 | * @param list list of rule names to enable.
|
315 | * @param ignoreInvalid set `true` to ignore errors when rule not found.
|
316 | */
|
317 | enable(list: string | string[], ignoreInvalid?: boolean): string[];
|
318 |
|
319 | /**
|
320 | * Enable rules with given names, and disable everything else. If any rule name
|
321 | * not found - throw Error. Errors can be disabled by second param.
|
322 | *
|
323 | * @see {@link Ruler.disable}, {@link Ruler.enable}
|
324 | *
|
325 | * @param list list of rule names to enable (whitelist).
|
326 | * @param ignoreInvalid set `true` to ignore errors when rule not found.
|
327 | */
|
328 | enableOnly(list: string | string[], ignoreInvalid?: boolean): void;
|
329 |
|
330 | /**
|
331 | * Disable rules with given names. If any rule name not found - throw Error.
|
332 | * Errors can be disabled by second param.
|
333 | *
|
334 | * Returns list of found rule names (if no exception happened).
|
335 | *
|
336 | * @see {@link Ruler.enable}, {@link Ruler.enableOnly}
|
337 | *
|
338 | * @param list list of rule names to disable.
|
339 | * @param ignoreInvalid set `true` to ignore errors when rule not found.
|
340 | */
|
341 | disable(list: string | string[], ignoreInvalid?: boolean): string[];
|
342 |
|
343 | /**
|
344 | * Return array of active functions (rules) for given chain name. It analyzes
|
345 | * rules configuration, compiles caches if not exists and returns result.
|
346 | *
|
347 | * Default chain name is `''` (empty string). It can't be skipped. That's
|
348 | * done intentionally, to keep signature monomorphic for high speed.
|
349 | */
|
350 | getRules(chainName: string): T[];
|
351 | }
|
352 |
|
353 | type Ruler_<T> = Ruler<T>;
|
354 |
|
355 | // lib/rules_core/state_core.mjs
|
356 |
|
357 | declare class StateCore {
|
358 | constructor(src: string, md: MarkdownIt, env: any);
|
359 |
|
360 | src: string;
|
361 | env: any;
|
362 | tokens: Token[];
|
363 | inlineMode: boolean;
|
364 |
|
365 | /**
|
366 | * link to parser instance
|
367 | */
|
368 | md: MarkdownIt;
|
369 |
|
370 | Token: typeof Token;
|
371 | }
|
372 |
|
373 | type StateCore_ = StateCore;
|
374 |
|
375 | // lib/rules_block/state_block.mjs
|
376 |
|
377 | declare class StateBlock {
|
378 | constructor(src: string, md: MarkdownIt, env: any, tokens: Token[]);
|
379 |
|
380 | src: string;
|
381 |
|
382 | /**
|
383 | * link to parser instance
|
384 | */
|
385 | md: MarkdownIt;
|
386 |
|
387 | env: any;
|
388 |
|
389 | //
|
390 | // Internal state vartiables
|
391 | //
|
392 |
|
393 | tokens: Token[];
|
394 |
|
395 | /**
|
396 | * line begin offsets for fast jumps
|
397 | */
|
398 | bMarks: number[];
|
399 | /**
|
400 | * line end offsets for fast jumps
|
401 | */
|
402 | eMarks: number[];
|
403 | /**
|
404 | * offsets of the first non-space characters (tabs not expanded)
|
405 | */
|
406 | tShift: number[];
|
407 | /**
|
408 | * indents for each line (tabs expanded)
|
409 | */
|
410 | sCount: number[];
|
411 |
|
412 | /**
|
413 | * An amount of virtual spaces (tabs expanded) between beginning
|
414 | * of each line (bMarks) and real beginning of that line.
|
415 | *
|
416 | * It exists only as a hack because blockquotes override bMarks
|
417 | * losing information in the process.
|
418 | *
|
419 | * It's used only when expanding tabs, you can think about it as
|
420 | * an initial tab length, e.g. bsCount=21 applied to string `\t123`
|
421 | * means first tab should be expanded to 4-21%4 === 3 spaces.
|
422 | */
|
423 | bsCount: number[];
|
424 |
|
425 | // block parser variables
|
426 |
|
427 | /**
|
428 | * required block content indent (for example, if we are
|
429 | * inside a list, it would be positioned after list marker)
|
430 | */
|
431 | blkIndent: number;
|
432 | /**
|
433 | * line index in src
|
434 | */
|
435 | line: number;
|
436 | /**
|
437 | * lines count
|
438 | */
|
439 | lineMax: number;
|
440 | /**
|
441 | * loose/tight mode for lists
|
442 | */
|
443 | tight: boolean;
|
444 | /**
|
445 | * indent of the current dd block (-1 if there isn't any)
|
446 | */
|
447 | ddIndent: number;
|
448 | /**
|
449 | * indent of the current list block (-1 if there isn't any)
|
450 | */
|
451 | listIndent: number;
|
452 |
|
453 | /**
|
454 | * used in lists to determine if they interrupt a paragraph
|
455 | */
|
456 | parentType: MarkdownIt.StateBlock.ParentType;
|
457 |
|
458 | level: number;
|
459 |
|
460 | /**
|
461 | * Push new token to "stream".
|
462 | */
|
463 | push(type: string, tag: string, nesting: MarkdownIt.Token.Nesting): Token;
|
464 |
|
465 | isEmpty(line: number): boolean;
|
466 |
|
467 | skipEmptyLines(from: number): number;
|
468 |
|
469 | /**
|
470 | * Skip spaces from given position.
|
471 | */
|
472 | skipSpaces(pos: number): number;
|
473 |
|
474 | /**
|
475 | * Skip spaces from given position in reverse.
|
476 | */
|
477 | skipSpacesBack(pos: number, min: number): number;
|
478 |
|
479 | /**
|
480 | * Skip char codes from given position
|
481 | */
|
482 | skipChars(pos: number, code: number): number;
|
483 |
|
484 | /**
|
485 | * Skip char codes reverse from given position - 1
|
486 | */
|
487 | skipCharsBack(pos: number, code: number, min: number): number;
|
488 |
|
489 | /**
|
490 | * cut lines range from source.
|
491 | */
|
492 | getLines(begin: number, end: number, indent: number, keepLastLF: boolean): string;
|
493 |
|
494 | Token: typeof Token;
|
495 | }
|
496 |
|
497 | type StateBlock_ = StateBlock;
|
498 |
|
499 | // lib/rules_inline/state_inline.mjs
|
500 |
|
501 | declare class StateInline {
|
502 | constructor(src: string, md: MarkdownIt, env: any, outTokens: Token[]);
|
503 |
|
504 | src: string;
|
505 | env: any;
|
506 | md: MarkdownIt;
|
507 | tokens: Token[];
|
508 | tokens_meta: Array<MarkdownIt.StateInline.TokenMeta | null>;
|
509 |
|
510 | pos: number;
|
511 | posMax: number;
|
512 | level: number;
|
513 | pending: string;
|
514 | pendingLevel: number;
|
515 |
|
516 | /**
|
517 | * Stores { start: end } pairs. Useful for backtrack
|
518 | * optimization of pairs parse (emphasis, strikes).
|
519 | */
|
520 | cache: any;
|
521 |
|
522 | /**
|
523 | * List of emphasis-like delimiters for current tag
|
524 | */
|
525 | delimiters: MarkdownIt.StateInline.Delimiter[];
|
526 |
|
527 | // Stack of delimiter lists for upper level tags
|
528 | // _prev_delimiters: StateInline.Delimiter[][];
|
529 |
|
530 | /**
|
531 | * Flush pending text
|
532 | */
|
533 | pushPending(): Token;
|
534 |
|
535 | /**
|
536 | * Push new token to "stream".
|
537 | * If pending text exists - flush it as text token
|
538 | */
|
539 | push(type: string, tag: string, nesting: MarkdownIt.Token.Nesting): Token;
|
540 |
|
541 | /**
|
542 | * Scan a sequence of emphasis-like markers, and determine whether
|
543 | * it can start an emphasis sequence or end an emphasis sequence.
|
544 | *
|
545 | * @param start position to scan from (it should point at a valid marker)
|
546 | * @param canSplitWord determine if these markers can be found inside a word
|
547 | */
|
548 | scanDelims(start: number, canSplitWord: boolean): MarkdownIt.StateInline.Scanned;
|
549 |
|
550 | Token: typeof Token;
|
551 | }
|
552 |
|
553 | type StateInline_ = StateInline;
|
554 |
|
555 | // lib/parser_core.mjs
|
556 |
|
557 | declare class Core {
|
558 | /**
|
559 | * {@link Ruler} instance. Keep configuration of core rules.
|
560 | */
|
561 | ruler: Ruler<MarkdownIt.Core.RuleCore>;
|
562 |
|
563 | /**
|
564 | * Executes core chain rules.
|
565 | */
|
566 | process(state: StateCore): void;
|
567 |
|
568 | State: typeof StateCore;
|
569 | }
|
570 |
|
571 | type Core_ = Core;
|
572 |
|
573 | // lib/parser_block.mjs
|
574 |
|
575 | declare class ParserBlock {
|
576 | /**
|
577 | * {@link Ruler} instance. Keep configuration of block rules.
|
578 | */
|
579 | ruler: Ruler<MarkdownIt.ParserBlock.RuleBlock>;
|
580 |
|
581 | /**
|
582 | * Generate tokens for input range
|
583 | */
|
584 | tokenize(state: StateBlock, startLine: number, endLine: number): void;
|
585 |
|
586 | /**
|
587 | * Process input string and push block tokens into `outTokens`
|
588 | */
|
589 | parse(str: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
590 |
|
591 | State: typeof StateBlock;
|
592 | }
|
593 |
|
594 | type ParserBlock_ = ParserBlock;
|
595 |
|
596 | // lib/parser_inline.mjs
|
597 |
|
598 | declare class ParserInline {
|
599 | /**
|
600 | * {@link Ruler} instance. Keep configuration of inline rules.
|
601 | */
|
602 | ruler: Ruler<MarkdownIt.ParserInline.RuleInline>;
|
603 |
|
604 | /**
|
605 | * {@link Ruler} instance. Second ruler used for post-processing
|
606 | * (e.g. in emphasis-like rules).
|
607 | */
|
608 | ruler2: Ruler<MarkdownIt.ParserInline.RuleInline2>;
|
609 |
|
610 | /**
|
611 | * Skip single token by running all rules in validation mode;
|
612 | * returns `true` if any rule reported success
|
613 | */
|
614 | skipToken(state: StateInline): void;
|
615 |
|
616 | /**
|
617 | * Generate tokens for input range
|
618 | */
|
619 | tokenize(state: StateInline): void;
|
620 |
|
621 | /**
|
622 | * Process input string and push inline tokens into `outTokens`
|
623 | */
|
624 | parse(str: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
625 |
|
626 | State: typeof StateInline;
|
627 | }
|
628 |
|
629 | type ParserInline_ = ParserInline;
|
630 |
|
631 | declare namespace MarkdownIt {
|
632 | // lib/common/utils.mjs
|
633 |
|
634 | interface Utils {
|
635 | lib: {
|
636 | mdurl: typeof mdurl;
|
637 | ucmicro: any;
|
638 | };
|
639 |
|
640 | /**
|
641 | * Merge objects
|
642 | */
|
643 | assign(obj: any, ...from: any[]): any;
|
644 |
|
645 | isString(obj: any): obj is string;
|
646 |
|
647 | has(obj: any, key: keyof any): boolean;
|
648 |
|
649 | unescapeMd(str: string): string;
|
650 |
|
651 | unescapeAll(str: string): string;
|
652 |
|
653 | isValidEntityCode(c: number): boolean;
|
654 |
|
655 | fromCodePoint(c: number): string;
|
656 |
|
657 | escapeHtml(str: string): string;
|
658 |
|
659 | /**
|
660 | * Remove element from array and put another array at those position.
|
661 | * Useful for some operations with tokens
|
662 | */
|
663 | arrayReplaceAt<T>(src: T[], pos: number, newElements: T[]): T[];
|
664 |
|
665 | isSpace(code: number): boolean;
|
666 |
|
667 | /**
|
668 | * Zs (unicode class) || [\t\f\v\r\n]
|
669 | */
|
670 | isWhiteSpace(code: number): boolean;
|
671 |
|
672 | /**
|
673 | * Markdown ASCII punctuation characters.
|
674 | *
|
675 | * !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
|
676 | *
|
677 | * Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
|
678 | *
|
679 | * @see http:
|
680 | */
|
681 | isMdAsciiPunct(code: number): boolean;
|
682 |
|
683 | |
684 |
|
685 |
|
686 | isPunctChar(ch: string): boolean;
|
687 |
|
688 | escapeRE(str: string): string;
|
689 |
|
690 | |
691 |
|
692 |
|
693 | normalizeReference(str: string): string;
|
694 | }
|
695 |
|
696 |
|
697 |
|
698 | interface ParseLinkDestinationResult {
|
699 | ok: boolean;
|
700 | pos: number;
|
701 | str: string;
|
702 | }
|
703 |
|
704 | interface ParseLinkTitleResult {
|
705 | |
706 |
|
707 |
|
708 | ok: boolean;
|
709 | |
710 |
|
711 |
|
712 | can_continue: boolean;
|
713 | |
714 |
|
715 |
|
716 | pos: number;
|
717 | |
718 |
|
719 |
|
720 | str: string;
|
721 | |
722 |
|
723 |
|
724 | marker: number;
|
725 | }
|
726 |
|
727 | interface Helpers {
|
728 |
|
729 |
|
730 | parseLinkLabel(state: StateInline, start: number, disableNested?: boolean): number;
|
731 |
|
732 |
|
733 |
|
734 | parseLinkDestination(str: string, start: number, max: number): ParseLinkDestinationResult;
|
735 |
|
736 |
|
737 |
|
738 | parseLinkTitle(
|
739 | str: string,
|
740 | start: number,
|
741 | max: number,
|
742 | prev_state?: ParseLinkTitleResult,
|
743 | ): ParseLinkTitleResult;
|
744 | }
|
745 |
|
746 | |
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 | type PresetName = "default" | "zero" | "commonmark";
|
760 |
|
761 | interface Options {
|
762 | |
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 | html?: boolean | undefined;
|
769 |
|
770 | |
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 | xhtmlOut?: boolean | undefined;
|
777 |
|
778 | |
779 |
|
780 |
|
781 |
|
782 | breaks?: boolean | undefined;
|
783 |
|
784 | |
785 |
|
786 |
|
787 |
|
788 |
|
789 | langPrefix?: string | undefined;
|
790 |
|
791 | |
792 |
|
793 |
|
794 |
|
795 | linkify?: boolean | undefined;
|
796 |
|
797 | |
798 |
|
799 |
|
800 |
|
801 |
|
802 | typographer?: boolean | undefined;
|
803 |
|
804 | |
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 | quotes?: string | string[];
|
812 |
|
813 | |
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 | highlight?: ((str: string, lang: string, attrs: string) => string) | null | undefined;
|
821 | }
|
822 |
|
823 | // lib/token.mjs
|
824 |
|
825 | type Token = Token_;
|
826 | namespace Token {
|
827 | type Nesting = 1 | 0 | -1;
|
828 | }
|
829 |
|
830 | // lib/renderer.mjs
|
831 |
|
832 | type Renderer = Renderer_;
|
833 | namespace Renderer {
|
834 | type RenderRule = (tokens: Token[], idx: number, options: Options, env: any, self: Renderer) => string;
|
835 |
|
836 | interface RenderRuleRecord {
|
837 | [type: string]: RenderRule | undefined;
|
838 | code_inline?: RenderRule | undefined;
|
839 | code_block?: RenderRule | undefined;
|
840 | fence?: RenderRule | undefined;
|
841 | image?: RenderRule | undefined;
|
842 | hardbreak?: RenderRule | undefined;
|
843 | softbreak?: RenderRule | undefined;
|
844 | text?: RenderRule | undefined;
|
845 | html_block?: RenderRule | undefined;
|
846 | html_inline?: RenderRule | undefined;
|
847 | }
|
848 | }
|
849 |
|
850 |
|
851 |
|
852 | type Ruler<T> = Ruler_<T>;
|
853 | namespace Ruler {
|
854 | interface RuleOptions {
|
855 | |
856 |
|
857 |
|
858 | alt: string[];
|
859 | }
|
860 | }
|
861 |
|
862 |
|
863 |
|
864 | type StateCore = StateCore_;
|
865 |
|
866 |
|
867 |
|
868 | type StateBlock = StateBlock_;
|
869 | namespace StateBlock {
|
870 | type ParentType = "blockquote" | "list" | "root" | "paragraph" | "reference";
|
871 | }
|
872 |
|
873 |
|
874 |
|
875 | type StateInline = StateInline_;
|
876 | namespace StateInline {
|
877 | interface Scanned {
|
878 | can_open: boolean;
|
879 | can_close: boolean;
|
880 | length: number;
|
881 | }
|
882 |
|
883 | interface Delimiter {
|
884 | marker: number;
|
885 | length: number;
|
886 | token: number;
|
887 | end: number;
|
888 | open: boolean;
|
889 | close: boolean;
|
890 | }
|
891 |
|
892 | interface TokenMeta {
|
893 | delimiters: Delimiter[];
|
894 | }
|
895 | }
|
896 |
|
897 |
|
898 |
|
899 | type Core = Core_;
|
900 | namespace Core {
|
901 | type RuleCore = (state: StateCore) => void;
|
902 | }
|
903 |
|
904 |
|
905 |
|
906 | type ParserBlock = ParserBlock_;
|
907 | namespace ParserBlock {
|
908 | type RuleBlock = (state: StateBlock, startLine: number, endLine: number, silent: boolean) => boolean;
|
909 | }
|
910 |
|
911 |
|
912 |
|
913 | type ParserInline = ParserInline_;
|
914 | namespace ParserInline {
|
915 | type RuleInline = (state: StateInline, silent: boolean) => boolean;
|
916 | type RuleInline2 = (state: StateInline) => boolean;
|
917 | }
|
918 |
|
919 | type PluginSimple = (md: MarkdownIt) => void;
|
920 | type PluginWithOptions<T = any> = (md: MarkdownIt, options?: T) => void;
|
921 | type PluginWithParams = (md: MarkdownIt, ...params: any[]) => void;
|
922 | }
|
923 |
|
924 | interface MarkdownItConstructor {
|
925 | new(): MarkdownIt;
|
926 | new(presetName: MarkdownIt.PresetName, options?: MarkdownIt.Options): MarkdownIt;
|
927 | new(options: MarkdownIt.Options): MarkdownIt;
|
928 | (): MarkdownIt;
|
929 | (presetName: MarkdownIt.PresetName, options?: MarkdownIt.Options): MarkdownIt;
|
930 | (options: MarkdownIt.Options): MarkdownIt;
|
931 | }
|
932 |
|
933 | interface MarkdownIt {
|
934 | |
935 |
|
936 |
|
937 |
|
938 |
|
939 | readonly inline: ParserInline;
|
940 |
|
941 | |
942 |
|
943 |
|
944 |
|
945 |
|
946 | readonly block: ParserBlock;
|
947 |
|
948 | |
949 |
|
950 |
|
951 |
|
952 |
|
953 | readonly core: Core;
|
954 |
|
955 | |
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 | readonly renderer: Renderer;
|
975 |
|
976 | |
977 |
|
978 |
|
979 |
|
980 |
|
981 | readonly linkify: LinkifyIt;
|
982 |
|
983 | |
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 | validateLink(url: string): boolean;
|
997 |
|
998 | |
999 |
|
1000 |
|
1001 |
|
1002 | normalizeLink(url: string): string;
|
1003 |
|
1004 | |
1005 |
|
1006 |
|
1007 | normalizeLinkText(url: string): string;
|
1008 |
|
1009 | readonly utils: MarkdownIt.Utils;
|
1010 |
|
1011 | readonly helpers: MarkdownIt.Helpers;
|
1012 |
|
1013 | readonly options: MarkdownIt.Options;
|
1014 |
|
1015 | |
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 | set(options: MarkdownIt.Options): this;
|
1035 |
|
1036 | |
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 | configure(presets: MarkdownIt.PresetName): this;
|
1047 |
|
1048 | |
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 |
|
1066 | enable(list: string | string[], ignoreInvalid?: boolean): this;
|
1067 |
|
1068 | |
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 | disable(list: string | string[], ignoreInvalid?: boolean): this;
|
1077 |
|
1078 | |
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 | use(plugin: MarkdownIt.PluginSimple): this;
|
1095 | use<T = any>(plugin: MarkdownIt.PluginWithOptions<T>, options?: T): this;
|
1096 | use(plugin: MarkdownIt.PluginWithParams, ...params: any[]): this;
|
1097 |
|
1098 | |
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 | parse(src: string, env: any): Token[];
|
1115 |
|
1116 | |
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 | render(src: string, env?: any): string;
|
1127 |
|
1128 | |
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 | parseInline(src: string, env: any): Token[];
|
1139 |
|
1140 | |
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 | renderInline(src: string, env?: any): string;
|
1148 | }
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 |
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 | declare const MarkdownIt: MarkdownItConstructor;
|
1235 |
|
1236 | export = MarkdownIt;
|