Tools for manipulating unified-latex ASTs
npm install @unified-latex/unified-latex-util-ligaturesFunctions to find and replace ligatures in a unified-latex Abstract Syntax Tree (AST) with their Unicode equivalents.
If you are converting LaTeX to plain text or HTML.
``bash`
npm install @unified-latex/unified-latex-util-ligatures
This package contains both esm and commonjs exports. To explicitly access the esm export,
import the .js file. To explicitly access the commonjs export, import the .cjs file.
`typescript`
function createMatchers(): { isMacro: (node: any) => node is Ast.Macro; isWhitespace: (node: any) => node is Ast.Whitespace; isRecognized: (nodes: Ast.Node[], whitespaceAllowed?: boolean) => Ast.String; isSplitable: (node: Ast.Node) => boolean; split: (node: Ast.String) => { ...; }[]; }
Turn all ligatures into their unicode equivalent. For example,
--- -> an em-dash and \^o to ô. This only applies in non-math mode,
since programs like katex will process math ligatures.
`typescript`
function expandUnicodeLigatures(tree: Ast.Ast): void;
Parameters
| Param | Type |
| :---- | :-------- |
| tree | Ast.Ast |
Parse for recognized ligatures like --- and \:o, etc. These are
replaced with string nodes with the appropriate unicode character subbed in.
`typescript`
function parseLigatures(ast: Ast.Node[]): Ast.Node[];
Parameters
| Param | Type |
| :---- | :----------- |
| ast | Ast.Node[]` |