@tricoteuses/arbre-de-la-loi
Version:
Generate ASTs from the French bills & laws; manipulate & export them to Markdown, etc.
59 lines (58 loc) • 1.78 kB
TypeScript
import { UnistLiteral, UnistNode, UnistParent } from "./unist";
export interface XastAttributes {
[attributeName: string]: string;
}
export interface XastCdata extends XastLiteral {
type: XastType.Cdata;
}
export interface XastComment extends XastLiteral {
type: XastType.Comment;
}
export interface XastDoctype extends UnistNode {
name: string;
public?: string;
system?: string;
type: XastType.Doctype;
}
export interface XastElement extends XastParent {
attributes?: XastAttributes;
children: Array<XastCdata | XastComment | XastElement | XastInstruction | XastText>;
name: string;
type: XastType.Element;
}
export interface XastInstruction extends XastLiteral {
name: string;
type: XastType.Instruction;
}
export interface XastLineage {
index: number;
lineage?: XastLineage;
parent: XastNode;
}
export interface XastLiteral extends UnistLiteral {
value: string;
}
export declare type XastNode = XastCdata | XastComment | XastDoctype | XastElement | XastInstruction | XastRoot | XastText;
export interface XastParent extends UnistParent {
children: Array<XastCdata | XastComment | XastDoctype | XastElement | XastInstruction | XastText>;
}
export interface XastRoot extends XastParent {
type: XastType.Root;
}
export interface XastText extends XastLiteral {
type: XastType.Text;
}
export declare enum XastType {
Cdata = "cdata",
Comment = "comment",
Doctype = "doctype",
Element = "element",
Instruction = "instruction",
Root = "root",
Text = "text"
}
export declare function assertNeverXastNode(node: never): never;
export declare function iterXastNodes(node: XastNode, lineage?: XastLineage): Generator<{
lineage?: XastLineage;
node: XastNode;
}, void, unknown>;