KaTeX transform plugin for rehype
npm install rehype-katex-cocalcKaTeX transformer plugin for rehype.
It transfroms html content of element nodes with math and inlineMath class with KaTeX.
> If you are trying to process from Markdown source, using remark-math and remark-rehype is highly recommended.
``sh`
npm i -S katex remark remark-math remark-rehype rehype-stringify
npm i -S rehype-katex
`js
const remark = require('remark')
const math = require('remark-math')
const remark2rehype = require('remark-rehype')
const katex = require('rehype-katex')
const stringify = require('rehype-stringify')
// Raw String => MDAST => HAST => transformed HAST => HTML
const processor = remark()
.use(math)
.use(remark2rehype)
.use(katex)
.use(stringify)
// https://en.wikipedia.org/wiki/Lift_(force)#Lift_coefficient
const rawString = Lift($L$) can be determined by Lift Coeeficient ($C_L$) like the following equation.
$$
L = \\frac{1}{2} \\rho v^2 S C_L
$$
const result = processor.processSync(rawString).toString()
/* result
Lift(...) can be determined by Lift Coeeficient (...) like the following equation.
Don't forget to include the CSS file for Katex.
Check remark-math for more information.
MIT © Junyoung Choi