rehype-mathjax
Version:
rehype plugin to transform inline and block math with MathJax
20 lines (17 loc) • 561 B
JavaScript
import {SVG as Svg} from 'mathjax-full/js/output/svg.js'
import {createPlugin} from './create-plugin.js'
import {createRenderer} from './create-renderer.js'
/**
* Render elements with a `language-math` (or `math-display`, `math-inline`)
* class with MathJax using SVG.
*
* @param [options]
* Configuration (optional).
* @returns
* Transform.
*/
const rehypeMathJaxSvg = createPlugin(function (options) {
// MathJax types do not allow `null`.
return createRenderer(options, new Svg(options.svg || undefined))
})
export default rehypeMathJaxSvg