# markdown-it-katexx

> Fast math support for markdown-it with KaTeX

Latest version **3.2.0** (published 2020-08-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install markdown-it-katexx
pnpm add markdown-it-katexx
yarn add markdown-it-katexx
bun add markdown-it-katexx
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2020-08-24 |
| First published | 2020-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Maintainers | puritanic |
| Keywords | markdown, KaTeX, math, LaTeX, TeX, markdown-it-plugin, markdown-it |

## Links

- npm: https://www.npmjs.com/package/markdown-it-katexx
- Repository: https://github.com/Puritanic/markdown-it-katex
- Homepage: https://github.com/Puritanic/markdown-it-katex#readme
- Issues: https://github.com/Puritanic/markdown-it-katex/issues
- npm.io page: https://npm.io/package/markdown-it-katexx

## Dependencies (1)

- [katex](https://npm.io/package/katex.md) ^0.12.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

- 3.2.0 (latest) — 2020-08-24
- 3.1.7 — 2020-03-22
- 3.1.6 — 2020-03-22
- 3.1.5 — 2020-03-16
- 3.1.4 — 2020-03-16
- 3.1.3 — 2020-03-16
- 3.1.2 — 2020-03-16
- 3.1.1 — 2020-03-16
- 3.1.0 — 2020-03-16
- 3.0.1 — 2020-03-09
- 3.0.0 — 2020-03-09

## README

# markdown-it-katexx [![Build Status](https://travis-ci.org/Puritanic/markdown-it-katex.svg?branch=master)](https://travis-ci.org/Puritanic/markdown-it-katex)

![Maaath](./static/math_gif.gif)

> Add Math to your Markdown

[![NPM](https://nodei.co/npm/markdown-it-katexx.png)](https://npmjs.org/package/markdown-it-katexx)

[KaTeX](https://github.com/Khan/KaTeX) is a faster alternative to MathJax. This plugin makes it easy to support your markdown.

Need convincing?

-   Check out the comparative benchmark: [KaTeX vs MathJax](https://jsperf.com/katex-vs-mathjax/42)
-   Try it in your browser: [markdown-it-katex demo](https://puritanic.github.io/markdown-it-katex/)

## TODO

-   [x] Switch to Jest
-   [ ] Typescript
-   [x] Set up CI/CD
-   [x] Publish NPM package
-   [x] Bundler
-   [x] precommit hooks
-   [ ] Code improvements?
-   [ ] More test coverage?

## Usage

Install it and add it to your config (Vuepress):

```js
module.exports = {
	head: [
		[
			'link',
			{
				rel: 'stylesheet',
				href: 'https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css',
			},
		],
	],
	markdown: {
		extendMarkdown: md => {
			md.set({ breaks: true });
			md.use(require('markdown-it-katexx'), { throwOnError: false, errorColor: ' #cc0000' });
		},
	},
};
```

## Getting Started

Install markdown-it

```shell
npm install markdown-it
```

Install the plugin

```shell
npm install markdown-it-katexx
```

Use it in your javascript:

```javascript
var md = require('markdown-it')(),
	mk = require('markdown-it-katexx');

md.use(mk);

// double backslash is required for javascript strings, but not html input
var result = md.render('# Math Rulez! \n  $\\sqrt{3x-1}+(1+x)^2$');
```

Include the [KaTeX stylesheet](https://katex.org/docs/browser.html) in your html.

If you're using the default markdown-it parser, I also recommend the [github stylesheet](https://github.com/sindresorhus/github-markdown-css):

`KaTeX` [options](https://katex.org/docs/options.html) can be supplied with the second argument to use.

```javascript
md.use(mk, { throwOnError: false, errorColor: ' #cc0000' });
```

## Examples

### Inline Math

Surround your LaTeX with a single `$` on each side for inline rendering.

```latex
$\sqrt{3x-1}+(1+x)^2$
```

### Math Block

Use two (`$$`) for block rendering. This mode uses bigger symbols and centers the result.

```latex
$$\begin{array}{c}

\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} &
= \frac{4\pi}{c}\vec{\mathbf{j}}    \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\

\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\

\nabla \cdot \vec{\mathbf{B}} & = 0

\end{array}$$
```

## Syntax

Math parsing in markdown is designed to agree with the conventions set by pandoc:

```html
Anything between two $ characters will be treated as TeX math. The opening $ must have a non-space
character immediately to its right, while the closing $ must have a non-space character immediately
to its left, and must not be followed immediately by a digit. Thus, $20,000 and $30,000 won’t parse
as math. If for some reason you need to enclose text in literal $ characters, backslash-escape them
and they won’t be treated as math delimiters.
```

## Math Syntax Support

KaTeX is based on TeX and LaTeX. Support for both is growing. Here's a list of currently supported functions:

[Function Support in KaTeX](https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX)

---

This repo is a fork of [waylonflinn/markdown-it-katex](https://github.com/waylonflinn/markdown-it-katex), initially forked to solve my own issues with the library, but then decided to work a bit on improving the library in general.

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