Functions 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.
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.
createMatchers()
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) => { ...; }[]; }
expandUnicodeLigatures(tree)
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.
function expandUnicodeLigatures(tree: Ast.Ast): void;
Parameters
Param | Type |
---|---|
tree | Ast.Ast |
parseLigatures(ast)
Parse for recognized ligatures like ---
and \:o
, etc. These are
replaced with string nodes with the appropriate unicode character subbed in.
function parseLigatures(ast: Ast.Node[]): Ast.Node[];
Parameters
Param | Type |
---|---|
ast | Ast.Node[] |
Generated using TypeDoc