import Nearley from 'nearley'; interface IMathVdom { tag: string; attr?: Record; children?: IMathVdom[] | string; } declare class MathVdom implements IMathVdom { tag: string; attr?: Record; children?: MathVdom[] | string; constructor({ tag, attr, children }: IMathVdom); toString(): string; replace(from: string, to: Ast): this; static before(left: string, tag?: string): IMathVdom; static after(right: string, tag?: string): IMathVdom; static brace(left: string, right: string, tag?: string): IMathVdom; static binary(first: string, second: string, tag: string): IMathVdom; static table(rows: string[][]): IMathVdom; } type StripType = (boolean | undefined) | (boolean | undefined)[]; interface SymbolConfig { tex: string; mathml?: IMathVdom; alias?: string | string[]; limits?: boolean; strip?: StripType; mid?: string; } interface Symbols { keyword?: Record; opOA?: Record; opOAB?: Record; lp?: Record; rp?: Record; limits?: Record; sub?: Record; sup?: Record; align?: Record; part?: Record; opAO?: Record; opAOB?: Record; pipe?: Record; } type Ast = any; type ReplaceLaw = [RegExp | string, string | ((substring: string, ...args: any[]) => string)]; interface ToTexConfig { display?: boolean; } interface AsciiMathConfig { /** * @default true * enable displayMode in KaTeX */ display?: boolean; /** * @default false * throws error on parse */ throws?: boolean; /** * Add custom symbols. * * For example: * { * keyword: { * dx: { tex: '{\\text{d}x}' }, * dy: { tex: '{\\text{d}y}' }, * dz: { tex: '{\\text{d}z}' }, * dt: { tex: '{\\text{d}t}' }, * ee: { tex: '\\text{e}' }, * ii: { tex: '\\text{i}' }, * } * } */ symbols?: Symbols; /** * Replace target expressions before tokenizing * * For example: * [ * [/&#(x?[0-9a-fA-F]+);/g, (match, $1) => * String.fromCodePoint($1[0] === 'x' ? '0' + $1 : $1) * ], * ... * ] */ replaceBeforeTokenizing?: ReplaceLaw[]; } declare class AsciiMath { display: boolean; throws: boolean; replaceBeforeTokenizing: ReplaceLaw[]; lexer: Nearley.Lexer; parser: Nearley.Parser; private genTex; private genMathML; private initState; constructor(config?: AsciiMathConfig); private parse; private handleError; toTex(code: string, config?: ToTexConfig): string; toMathML(code: string, config?: ToTexConfig): MathVdom; } export { AsciiMath, type AsciiMathConfig, type Ast };