rehype-asciimath
v1.0.0
Published
A rehype plugin for ASCIIMath
Downloads
11
Maintainers
Readme
rehype-asciimath
To be used in conjunction with Katex or MathJAX
This uses the ASCIIMathTeXImg.js
from the ASCIIMath repo with a patch which is yet to be merged
Example markdown
Wrap your code in backticks (`
) inside the dollars ($
) for rendering the block using ASCIIMath
ASCIIMath Inline (Use $`...`$), e.g. $`sqrt(x)`$
ASCIIMath Block (Use $$`...`$$), e.g.
$$
`x / (y+z) = \frac{a}{b+c}`
$$
LaTeX inside ASCIIMath should stay as it is
Normal math (without backticks) will render as it is $sqrt(x)$ (LaTeX but no ASCIIMath)
To not parse it as ASCIIMath and still use backticks (at the start or the end), start or end your LaTeX code with empty braces (`{}`), e.g. $`sqrt(x)`{}$
$$
{}`x / (y+z) = \frac{a}{b+c}`
$$
Renders as:
Usage
- Add this plugin to your dependencies
npm i -s rehype-asciimath
- Add the
remark-math
andrehype-katex
(or rehype-mathjax) plugins to your dependencies - Use the
rehype-asciimath
plugin before therehype-katex
plugin - Example config
const remarkMath = require("remark-math");
const rehypeASCIIMath = require("rehype-asciimath");
const rehypeKatex = require("rehype-katex");
const config = {
remarkPlugins: [remarkMath],
rehypePlugins: [
rehypeAsciiMath,
rehypeKatex,
]
}
License
The MIT License https://meghprkh.mit-license.org/
Copyright © 2020 Megh Parikh [email protected]