29 lines
574 B
TypeScript
29 lines
574 B
TypeScript
type IdentifiedToken<M> = {
|
|
metadata: M;
|
|
children?: Token[];
|
|
uuid: string;
|
|
raw: string;
|
|
content: string;
|
|
rendersChildrenOnly?: boolean;
|
|
rendersContentOnly?: boolean;
|
|
};
|
|
|
|
type TokenRenderer<M> = (t: Token<M>) => ReactNode;
|
|
|
|
type TokenAttributes = {
|
|
type: string;
|
|
render: TokenRenderer;
|
|
};
|
|
|
|
type Token<M = Record<string, string>> = IdentifiedToken<M> & TokenAttributes;
|
|
|
|
type TokenMarker<M = Record<string, string>> = {
|
|
start: number;
|
|
end: number;
|
|
type: string;
|
|
parent?: TokenMarker;
|
|
token: Token<M>;
|
|
};
|
|
|
|
type FrontMatter = Record<string, string>;
|