tree-sitter-hast
Version:
Convert tree-sitter parsed trees to syntax-highlighted HAST
30 lines (29 loc) • 695 B
TypeScript
import * as Unist from 'unist';
export interface Parent extends Unist.Parent {
children: (Element | Doctype | Comment | Text)[];
}
export interface Literal extends Unist.Literal {
value: string;
}
export interface Root extends Parent {
type: 'root';
}
export interface Element extends Parent {
type: 'element';
tagName: string;
properties?: unknown;
content?: Root;
children: (Element | Comment | Text)[];
}
export interface Doctype extends Unist.Node {
type: 'doctype';
name: string;
public?: string;
system?: string;
}
export interface Comment extends Literal {
type: 'comment';
}
export interface Text extends Literal {
type: 'text';
}