mathup
Version:
Easy MathML authoring tool with a quick to write syntax
49 lines • 1.86 kB
TypeScript
/**
* @typedef {import("../parser/index.js").Node} ASTNode
* @typedef {object} TransformerOptions
* @property {"ltr" | "rtl" | null} [dir=null] - The reading direction of the
* output. Default is `null`
* @property {"block" | "inline" | null} [display=null] - Whether the expression
* should be in display mode. Default is `null` Default is `null` Default is
* `null` Default is `null`
* @typedef {object} Tag
* @property {string} tag
* @property {Record<string, string | number | boolean | undefined | null>} [attrs]
* @property {(Tag | null)[]} [childNodes]
* @property {string} [textContent]
*/
/**
* @template {ASTNode} [Node=ASTNode] Default is `ASTNode`
* @typedef {(
* node: Node,
* transform: (node: ASTNode) => Tag | null,
* options: Required<TransformerOptions>,
* ) => Tag | null} TransformFn
*/
/**
* @param {Required<TransformerOptions>} options
* @returns {(node: ASTNode) => Tag | null}
*/
export default function transformer(options: Required<TransformerOptions>): (node: ASTNode) => Tag | null;
export type ASTNode = import("../parser/index.js").Node;
export type TransformerOptions = {
/**
* - The reading direction of the
* output. Default is `null`
*/
dir?: "ltr" | "rtl" | null;
/**
* - Whether the expression
* should be in display mode. Default is `null` Default is `null` Default is
* `null` Default is `null`
*/
display?: "block" | "inline" | null;
};
export type Tag = {
tag: string;
attrs?: Record<string, string | number | boolean | undefined | null>;
childNodes?: (Tag | null)[];
textContent?: string;
};
export type TransformFn<Node extends ASTNode = import("../parser/index.js").Node> = (node: Node, transform: (node: ASTNode) => Tag | null, options: Required<TransformerOptions>) => Tag | null;
//# sourceMappingURL=index.d.ts.map