Functions to convert unified-latex Abstract Syntax Tree (AST) to a MDAST (Markdown-like)
tree.
If you want to convert LaTeX to Markdown.
npm install @unified-latex/unified-latex-to-mdast
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.
unifiedLatexToMdastUnified plugin to convert a unified-latex AST into a mdast AST.
unified().use(unifiedLatexToMdast[, options])
PluginOptions
Plugin<PluginOptions[], Ast.Root, Mdast.Root>
function unifiedLatexToMdast(
options: PluginOptions
): (tree: Ast.Root, file: VFile) => Mdast.Root;
convertToMarkdown(tree, options)Convert the unified-latex AST tree into a Markdown string. If you need
more precise control or further processing, consider using unified
directly with the unifiedLatexToMdast plugin.
For example,
unified()
.use(unifiedLatexFromString)
.use(unifiedLatexToMdast)
.use(remarkStringify)
.processSync("\\LaTeX to convert")
function convertToMarkdown(
tree: Ast.Node | Ast.Node[],
options: PluginOptions
): string;
Parameters
| Param | Type |
|---|---|
| tree | Ast.Node | Ast.Node[] |
| options | PluginOptions |
PluginOptionsexport type PluginOptions = HtmlLikePluginOptions & RehypeRemarkOptions;
Generated using TypeDoc