-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rehype-mathjax: change options to match
mathjax
Previously, output options for SVG and CHTML were set on the main options object. MathJax itself puts them in separate fields. Similarly, the “browser” plugin supported `inlineMath` and `displayMath` option fields that were close to `tex.inlineMath` and `tex.displayMath`. We now match MathJax’ option format: ```diff - .use(rehypeMathJaxChtml, {fontURL: 'place/to/fonts'}) + .use(rehypeMathJaxChtml, {chtml: {fontURL: 'place/to/fonts'}}) ``` ```diff - .use(rehypeMathJaxSvg, {scale: 1}) + .use(rehypeMathJaxSvg, {svg: {scale: 1}}) ``` Note that `inlineMath` and `displayMath` are now lists of pairs, instead of a single pair! ```diff - .use(rehypeMathJaxBrowser, {inlineMath: ['\\(', '\\)']}) + .use(rehypeMathJaxBrowser, {tex: {inlineMath: [['\\(', '\\)']]}}) ```
- Loading branch information
Showing
10 changed files
with
85 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
/** | ||
* @typedef {import('hast').Root} Root | ||
* @typedef {import('./lib/create-plugin').CHtmlOptions} Options | ||
* @typedef {import('mathjax-full/js/output/chtml.js').CHTML<HTMLElement, Text, Document>} CHTML_ | ||
* @typedef {import('./lib/create-plugin').Options} Options | ||
*/ | ||
|
||
import {createOutputChtml} from './lib/create-output-chtml.js' | ||
import {CHTML} from 'mathjax-full/js/output/chtml.js' | ||
import {createRenderer} from './lib/create-renderer.js' | ||
import {createPlugin} from './lib/create-plugin.js' | ||
|
||
const rehypeMathJaxCHtml = | ||
/** @type {import('unified').Plugin<[Options?]|void[], Root>} */ | ||
( | ||
createPlugin( | ||
(inputOptions, outputOptions) => | ||
createRenderer(inputOptions, createOutputChtml(outputOptions)), | ||
true | ||
const rehypeMathJaxCHtml = createPlugin((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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
/** | ||
* @typedef {import('hast').Root} Root | ||
* @typedef {import('./lib/create-plugin').SvgOptions} Options | ||
* @typedef {import('mathjax-full/js/output/svg.js').SVG<HTMLElement, Text, Document>} SVG_ | ||
* @typedef {import('./lib/create-plugin.js').Options} Options | ||
*/ | ||
|
||
import {createOutputSvg} from './lib/create-output-svg.js' | ||
import {SVG} from 'mathjax-full/js/output/svg.js' | ||
import {createRenderer} from './lib/create-renderer.js' | ||
import {createPlugin} from './lib/create-plugin.js' | ||
|
||
const rehypeMathJaxSvg = | ||
/** @type {import('unified').Plugin<[Options?]|void[], Root>} */ | ||
( | ||
createPlugin((inputOptions, outputOptions) => | ||
createRenderer(inputOptions, createOutputSvg(outputOptions)) | ||
) | ||
) | ||
const rehypeMathJaxSvg = createPlugin((options) => | ||
createRenderer(options, new SVG(options.svg)) | ||
) | ||
|
||
export default rehypeMathJaxSvg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters