得鹿梦鱼 得鹿梦鱼

Token

细化文档解析后的颗粒度,主要分为一下几个类型,也是说归纳AST树的节点类型

export namespace Tokens {}

Blockquote 块级引用

export interface Blockquote {  type: "blockquote";  raw: string;  text: string;  tokens: Token[];}

Br换行

export interface Blockquote {    type: 'br';    raw: string;}

CheckBox 代办事项

export interface Checkbox {    checked: boolean;}

code

export interface Code {    type: 'code';    raw: string;    codeBlockStyle?: 'indented';    lang?: string;    text: string;    escaped?: boolean;}

Codespan

export interface Code {    type: 'codespan';    raw: string;    text: string;}

Def 引用

export interface Def {    type: 'def';    raw: string;    tag: string;    href: string;    title: string;}

Del 删除

export interface Del {    type: 'del';    raw: string;    text: string;    tokens: Token[];}

Em 斜体

export interface Em {    type: 'em';    raw: string;    text: string;    tokens: Token[];}

Escape 转义

export interface Escape {    type: 'escape';    raw: string;    text: string;}

Generic 通用类型

export interface Generic {    [index: string]: any;    type: string;    raw: string;    tokens?: Token[];}

Heading 标题

export interface Heading {    type: 'heading';    raw: string;    depth: number;    text: string;    tokens: Token[];}

Hr 下划线

export interface Hr {    type: 'hr';    raw: string;}

HTML

export interface HTML {    type: 'html';    raw: string;    pre: boolean;    text: string;    block: boolean;}

Image 图片

export interface Image {    type: 'image';    raw: string;    href: string;    title: string  null;    text: string;}
export interface Link {    type: 'link';    raw: string;    href: string;    title?: string  null;    text: string;    tokens: Token[];}

List 列表

export interface ListItem {    type: 'list_item';    raw: string;    task: boolean;    checked?: boolean;    loose: boolean;    text: string;    tokens: Token[];}

Paragraph 段落

export interface Paragraph {    type: 'paragraph';    raw: string;    pre?: boolean;    text: string;    tokens: Token[];}

Space 空白

export interface Space {    type: 'space';    raw: string;}

Strong 粗体

export interface Strong {    type: 'strong';    raw: string;    text: string;    tokens: Token[];}

Table 表格

export interface Table {    type: 'table';    raw: string;    align: Array<'center'  'left'  'right'  null>;    header: TableCell[];    rows: TableCell[][];}

TableCell 单元格

export interface TableCell {    text: string;    tokens: Token[];    header: boolean;    align: 'center'  'left'  'right'  null;}

TableRow 单元行

export interface TableRow {    text: string;}

Tag 标签

export interface Tag {    type: 'html';    raw: string;    inLink: boolean;    inRawBlock: boolean;    text: string;    block: boolean;}

Text 文本

export interface Text {    type: 'text';    raw: string;    text: string;    tokens?: Token[];    escaped?: boolean;}