rehype plugin for rendering typst math equations
npm install @myriaddreamin/rehype-typstlanguage-math class with
unified().use(rehypeTypst[, options])](#unifieduserehypetypst-options)
$C$ syntax extension.
sh
npm install @myriaddreamin/rehype-typst
`
Use
Say our document input.html contains:
`html
Lift(L) can be determined by Lift Coefficient
(C_L) like the following equation.
L = 1/2 rho v^2 S C_L
`
…and our module example.js contains:
`js
import rehypeTypst from '@myriaddreamin/rehype-typst'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
import {read, write} from 'to-vfile'
import {unified} from 'unified'
const file = await unified()
.use(rehypeParse, {fragment: true})
.use(rehypeTypst)
.use(rehypeStringify)
.process(await read('input.html'))
file.basename = 'output.html'
await write(file)
`
…then running node example.js creates an output.html and open output.html in a browser to see the rendered math.
API
This package exports no identifiers.
The default export is rehypeTypst.
$3
Render elements with a language-math (or math-display, math-inline)
class with Typst.
###### Returns
Transform ([Transformer][unified-transformer]).
Markdown
This plugin supports the syntax extension enabled by
remark-math.
It also supports math generated by using fenced code:
``markdown
`math
C_L
`
``
HTML
The content of any element with a language-math, math-inline, or
math-display class is transformed.
The elements are replaced by what Typst renders.
Either a math-display class or using ` will
result in “display” math: math that is a centered block on its own line.
[unified-transformer]: https://github.com/unifiedjs/unified#transformer