@yozora/tokenizer-math
Version:
Tokenizer for processing fenced math block (formulas)
49 lines (43 loc) • 1.61 kB
TypeScript
import { IBaseBlockTokenizerProps, IMatchBlockHookCreator, IParseBlockHookCreator, IBlockTokenizer } from '@yozora/core-tokenizer';
import { MathType, Math } from '@yozora/ast';
import FencedBlockTokenizer, { IFencedBlockHookContext, IFencedBlockToken } from '@yozora/tokenizer-fenced-block';
type T = MathType;
type INode = Math;
declare const uniqueName = "@yozora/tokenizer-math";
type IToken = IFencedBlockToken<T>;
type IThis = IFencedBlockHookContext<T>;
type ITokenizerProps = Partial<IBaseBlockTokenizerProps>;
/**
* * single line math block:
*
* ```math
* $$x^2 + y^2=z^2$$
* ```
*
* * multiple line math block:
*
* ```math
* $$
* f(x)=\left\lbrace\begin{aligned}
* &x^2, &x < 0\\
* &0, &x = 0\\
* &x^3, &x > 0
* \end{aligned}\right.
* $$
* ```
*
* @see https://github.com/remarkjs/remark-math
*/
declare const match: IMatchBlockHookCreator<T, IToken, IThis>;
declare const parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
/**
* Lexical Analyzer for fenced math block.
* @see https://github.com/remarkjs/remark-math
*/
declare class MathTokenizer extends FencedBlockTokenizer<T, INode, IThis> implements IBlockTokenizer<T, IToken, INode, IThis> {
constructor(props?: ITokenizerProps);
readonly match: IMatchBlockHookCreator<T, IToken, IThis>;
readonly parse: IParseBlockHookCreator<T, IToken, INode, IThis>;
}
export { MathTokenizer, uniqueName as MathTokenizerName, MathTokenizer as default, match as mathMatch, parse as mathParse };
export type { IThis as IMathHookContext, IToken as IMathToken, ITokenizerProps as IMathTokenizerProps };