# rehype-asciimath

> A rehype plugin for ASCIIMath

Latest version **1.0.0** (published 2020-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install rehype-asciimath
pnpm add rehype-asciimath
yarn add rehype-asciimath
bun add rehype-asciimath
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-12-30 |
| First published | 2020-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 51 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Megh Parikh |
| Maintainers | meghprkh |
| Keywords | ReHype, Markdown, ASCIIMath, Katex, Latex |

## Links

- npm: https://www.npmjs.com/package/rehype-asciimath
- Repository: https://github.com/meghprkh/rehype-asciimath
- Homepage: https://github.com/meghprkh/rehype-asciimath#readme
- Issues: https://github.com/meghprkh/rehype-asciimath/issues
- npm.io page: https://npm.io/package/rehype-asciimath

## Dependencies (3)

- [asciimath](https://npm.io/package/asciimath.md) git+ssh://git@github.com/meghprkh/asciimathml.git#commonjs
- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^2.0.0
- [hast-util-to-text](https://npm.io/package/hast-util-to-text.md) ^2.0.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-12-30

## README

# rehype-asciimath

[ASCIIMath](http://asciimath.org/) plugin for [Rehype](https://github.com/rehypejs/rehype)

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](https://github.com/asciimath/asciimathml/pull/118)

## Example markdown

Wrap your code in backticks (`` ` ``) inside the dollars (`$`) for rendering the block using ASCIIMath

```plain
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:

![example_output](example_output.png)

## Usage

- Add this plugin to your dependencies `npm i -s rehype-asciimath`
- Add the [`remark-math`](https://github.com/remarkjs/remark-math/tree/main/packages/remark-math) and [`rehype-katex`](https://github.com/remarkjs/remark-math/tree/main/packages/rehype-katex) (or [rehype-mathjax](https://github.com/remarkjs/remark-math/tree/main/packages/rehype-mathjax)) plugins to your dependencies
- Use the `rehype-asciimath` plugin before the `rehype-katex` plugin
- Example config

```js
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 meghprkh@gmail.com

---
_Source: https://npm.io/package/rehype-asciimath · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
