Package Exports
- rehype-katex
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rehype-katex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Rehype Katex
KaTeX 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
andremark-rehype
is highly recommended.
Usage
npm i -S remark remark-math remark-rehype rehype-stringify
npm i -S rehype-katex
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
<p>
Lift(<span class="inlineMath"><span class="katex">...</span></span>) can be determined by Lift Coeeficient (<span class="inlineMath"><span class="katex">...</span></span>) like the following equation.
</p>
<div class="math">
<span class="katex-display"><span class="katex">...</span></span>
</div>
*/
Check remark-math for more information.
License
MIT © Junyoung Choi