# mhchemparser

> Parser to convert mhchem syntax to LaTeX syntax, for downstream inclusion in MathJax, KaTeX and similar projects.

Latest version **4.2.1** (published 2023-05-24) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install mhchemparser
pnpm add mhchemparser
yarn add mhchemparser
bun add mhchemparser
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.1 |
| Published | 2023-05-24 |
| First published | 2021-04-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 270.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | Martin Hensel |
| Maintainers | mhchem |
| Keywords | mhchem, MathJax, LaTeX, chemistry |

## Links

- npm: https://www.npmjs.com/package/mhchemparser
- Repository: https://github.com/mhchem/mhchemParser
- Issues: https://github.com/mhchem/mhchemParser/issues
- npm.io page: https://npm.io/package/mhchemparser

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 4.2.1 (latest) — 2023-05-24
- 4.2.0 — 2023-05-22
- 4.1.1 — 2021-07-06
- 4.1.0 — 2021-05-17
- 4.0.0 — 2021-04-21

## README

# mhchem Parser

mhchem is an input syntax for typesetting chemical equations and physical units.

This is the parser to convert mhchem syntax to LaTeX syntax, for downstream inclusion in [MathJax](https://mathjax.org), [KaTeX](https://katex.org) and similar projects.


## Usage

Users of MathJax and KaTex can write

    \ce{CO2 + C -> 2 CO}
    \pu{123 kJ*mol-1}

For a hundred more features and how to configure MathJax or KaTeX, see
[the manual](https://mhchem.github.io/MathJax-mhchem/).


## Usage for Downstream Software

For "translating" the `\ce` syntax, make a call like

    mhchemParser.toTex("CO2 + C -> 2 CO", "ce");

This will return

    "{\mathrm{CO}{\vphantom{A}}_{\smash[t]{2}} {}+{} \mathrm{C} {}\mathrel{\longrightarrow}{} 2\,\mathrm{CO}}"

For the `\pu` command, call

    mhchemParser.toTex("123 kJ*mol-1", "pu");

You could also insert a TeX string. All instances of `\ce` and `\pu` will be replaced in the returned value. This might make integration easier, because the mhchem parser does not need to be called from the TeX parser.

    mhchemParser.toTex("m_{\\ce{H2O}}", "tex");

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