@unified-latex/unified-latex-util-ligatures
TypeScript icon, indicating that this package has built-in type declarations

1.7.1 • Public • Published

unified-latex-util-ligatures

What is this?

Functions to find and replace ligatures in a unified-latex Abstract Syntax Tree (AST) with their Unicode equivalents.

When should I use this?

If you are converting LaTeX to plain text or HTML.

Install

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.

Functions

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[]

Package Sidebar

Install

npm i @unified-latex/unified-latex-util-ligatures

Weekly Downloads

47

Version

1.7.1

License

MIT

Unpacked Size

81.7 kB

Total Files

7

Last publish

Collaborators

  • siefkenj