site/node_modules/rehype-mathjax/lib/chtml.js

25 lines
726 B
JavaScript
Raw Permalink Normal View History

2024-10-14 06:09:33 +00:00
import {CHTML} from 'mathjax-full/js/output/chtml.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 CHTML.
*
* @param options
* Configuration (`options.chtml.fontURL` is required).
* @returns
* Transform.
*/
const rehypeMathJaxCHtml = createPlugin(function (options) {
if (!options.chtml || !options.chtml.fontURL) {
throw new Error(
'rehype-mathjax: missing `fontURL` in options, which must be set to a URL to reach MathJaX fonts'
)
}
return createRenderer(options, new CHTML(options.chtml))
})
export default rehypeMathJaxCHtml