1 | declare namespace Token {
|
2 | type Nesting = 1 | 0 | -1;
|
3 | }
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | declare class Token {
|
9 | constructor(type: string, tag: string, nesting: Token.Nesting);
|
10 |
|
11 | /**
|
12 | * Type of the token, e.g. "paragraph_open"
|
13 | */
|
14 | type: string;
|
15 |
|
16 | /**
|
17 | * HTML tag name, e.g. "p"
|
18 | */
|
19 | tag: string;
|
20 |
|
21 | /**
|
22 | * HTML attributes. Format: `[[name1, value1], [name2, value2]]`
|
23 | */
|
24 | attrs: [string, string][] | null;
|
25 |
|
26 | /**
|
27 | * Source map info. Format: `[line_begin, line_end]`
|
28 | */
|
29 | map: [number, number] | null;
|
30 |
|
31 | /**
|
32 | * Level change (number in {-1, 0, 1} set), where:
|
33 | *
|
34 | * - `1` means the tag is opening
|
35 | * - `0` means the tag is self-closing
|
36 | * - `-1` means the tag is closing
|
37 | */
|
38 | nesting: 1 | 0 | -1;
|
39 |
|
40 | /**
|
41 | * nesting level, the same as `state.level`
|
42 | */
|
43 | level: number;
|
44 |
|
45 | /**
|
46 | * An array of child nodes (inline and img tokens)
|
47 | */
|
48 | children: Token[] | null;
|
49 |
|
50 | /**
|
51 | * In a case of self-closing tag (code, html, fence, etc.),
|
52 | * it has contents of this tag.
|
53 | */
|
54 | content: string;
|
55 |
|
56 | /**
|
57 | * '*' or '_' for emphasis, fence string for fence, etc.
|
58 | */
|
59 | markup: string;
|
60 |
|
61 | /**
|
62 | * Fence info string
|
63 | */
|
64 | info: string;
|
65 |
|
66 | /**
|
67 | * A place for plugins to store an arbitrary data
|
68 | */
|
69 | meta: any;
|
70 |
|
71 | /**
|
72 | * True for block-level tokens, false for inline tokens.
|
73 | * Used in renderer to calculate line breaks
|
74 | */
|
75 | block: boolean;
|
76 |
|
77 | /**
|
78 | * If it's true, ignore this element when rendering. Used for tight lists
|
79 | * to hide paragraphs.
|
80 | */
|
81 | hidden: boolean;
|
82 |
|
83 | /**
|
84 | * Search attribute index by name.
|
85 | */
|
86 | attrIndex(name: string): number;
|
87 |
|
88 | /**
|
89 | * Add `[name, value]` attribute to list. Init attrs if necessary
|
90 | */
|
91 | attrPush(attrData: [string, string]): void;
|
92 |
|
93 | /**
|
94 | * Set `name` attribute to `value`. Override old value if exists.
|
95 | */
|
96 | attrSet(name: string, value: string): void;
|
97 |
|
98 | /**
|
99 | * Get the value of attribute `name`, or null if it does not exist.
|
100 | */
|
101 | attrGet(name: string): string | null;
|
102 |
|
103 | /**
|
104 | *
|
105 | * Join value to existing attribute via space. Or create new attribute if not
|
106 | * exists. Useful to operate with token classes.
|
107 | */
|
108 | attrJoin(name: string, value: string): void;
|
109 | }
|
110 |
|
111 | export = Token;
|