Expand description
interface Token {
type: string;
tag: string;
attrs: [name: string, value: string | number][] | null;
map: [number, number] | null;
nesting: 0 | 1 | -1;
level: number;
children: Token[] | null;
content: string;
markup: string;
info: string;
meta: Record<string, unknown> | null;
block: boolean;
hidden: boolean;
attrIndex(name: string): number;
attrPush(attrData: [name: string, value: string | number]): void;
attrSet(name: string, value: string | number): void;
attrGet(name: string): string | number | null;
attrJoin(name: string, value: string | number): void;
}
Properties§
type: string
Type of the token (string, e.g. "paragraph_open")
tag: string
html tag name, e.g. "p"
attrs: [name: string, value: string | number][] | null
Html attributes. Format: [ [ name1, value1 ], [ name2, value2 ] ]
map: [number, number] | null = null
Source map info. Format: [ line_begin, line_end ]
nesting: 0 | 1 | -1
Level change (number in {-1, 0, 1} set), where:
1means the tag is opening0means the tag is self-closing-1means the tag is closing
level: number = 0
nesting level, the same as state.level
children: Token[] | null = null
An array of child nodes (inline and img tokens)
content: string = ''
In a case of self-closing tag (code, html, fence, etc.), it has contents of this tag.
markup: string = ''
'*' or '_' for emphasis, fence string for fence, etc.
info: string = ''
Additional information:
- Info string for "fence" tokens
- The value "auto" for autolink "link_open" and "link_close" tokens
- The string value of the item marker for ordered-list "list_item_open" tokens
meta: Record<string, unknown> | null
A place for plugins to store an arbitrary data
block: boolean = false
True for block-level tokens, false for inline tokens. Used in renderer to calculate line breaks
If it's true, ignore this element when rendering. Used for tight lists to hide paragraphs.
Methods§
Source§
attrPush(attrData: [name: string, value: string | number]): void
attrPush(attrData: [name: string, value: string | number]): void
Add [ name, value ] attribute to list. Init attrs if necessary
Source§
attrSet(name: string, value: string | number): void
attrSet(name: string, value: string | number): void
Set name attribute to value. Override old value if exists.
Represents one item in the parsed token stream, storing parsed data and providing helpers for managing HTML attributes.