# remark-sub-super

> This plugin parses custom Markdown syntax to handle subscript and superscript. It adds new nodes types to the [mdast][mdast] produced by [remark][remark]:

Latest version **1.0.21** (published 2024-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install remark-sub-super
pnpm add remark-sub-super
yarn add remark-sub-super
bun add remark-sub-super
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.21 |
| Published | 2024-04-27 |
| First published | 2017-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 237 |
| Author | Victor Felder |
| Maintainers | situphen, talone |
| Keywords | remark |

## Links

- npm: https://www.npmjs.com/package/remark-sub-super
- Repository: https://github.com/zestedesavoir/zmarkdown.git#master
- Homepage: https://github.com/zestedesavoir/zmarkdown/tree/master#readme
- Issues: https://github.com/zestedesavoir/zmarkdown/issues
- npm.io page: https://npm.io/package/remark-sub-super

## 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.21 (latest) — 2024-04-27
- 1.0.20 — 2021-02-14
- 1.0.19 — 2019-07-27
- 1.0.18 — 2019-04-14
- 1.0.17 — 2019-02-04
- 1.0.16 — 2018-11-23
- 1.0.15 — 2018-10-04
- 1.0.14 — 2018-08-09
- 1.0.13 — 2018-07-22
- 1.0.12 — 2018-07-20
- 1.0.11 — 2018-03-06
- 1.0.10 — 2018-01-20
- 1.0.9 — 2018-01-19
- 1.0.8 — 2018-01-13
- 1.0.7 — 2017-08-31
- … 19 more at https://npm.io/package/remark-sub-super/versions

## README

# remark-sub-super [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status]

This plugin parses custom Markdown syntax to handle subscript and superscript.
It adds new nodes types to the [mdast][mdast] produced by [remark][remark]:

* `sub`
* `sup`

If you are using [rehype][rehype], the stringified HTML result will be `sub` or `sup`.

## Syntax

```markdown
~subscript~, e.g. a~i~

^superscript^, e.g. e^x^
```

## AST (see [mdast][mdast] specification)

`Sub` ([`Parent`][parent]) represents a subscript text.

```javascript
interface Sub <: Parent {
  type: "sub";
}
```

`Sup` ([`Parent`][parent]) represents a superscript text.

```javascript
interface Sup <: Parent {
  type: "sup";
}
```

For example, the following markdown:

```markdown
a^x^

x~i~
```

Yields:

```javascript
{
  type: 'paragraph',
  children: [{
    type: 'text',
    value: 'a',
    children: [{
      type: 'sup',
      children: [{
        type: 'text',
        value: 'x'
      }]
    }]
  }]
},
{
  type: 'paragraph',
  children: [{
    type: 'text',
    value: 'x',
    children: [{
      type: 'sub',
      children: [{
        type: 'text',
        value: 'i'
      }]
    }]
  }]
}
```

## Rehype

This plugin is compatible with [rehype][rehype]. `Sub` mdast nodes will become `<sub>contents</sub>`, `Sup` mdast nodes will become `<sup>contents</sup>`.

## Installation

[npm][npm]:

```bash
npm install remark-sub-super
```

## Usage

Dependencies:

```javascript
const unified = require('unified')
const remarkParse = require('remark-parse')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')

const remarkSubSuper = require('remark-sub-super')
```

Usage:

```javascript
unified()
  .use(remarkParse)
  .use(remarkSubSuper)
  .use(remark2rehype)
  .use(stringify)
```

## License

[MIT][license] © [Zeste de Savoir][zds]

<!-- Definitions -->

[build-badge]: https://img.shields.io/travis/zestedesavoir/zmarkdown.svg

[build-status]: https://travis-ci.org/zestedesavoir/zmarkdown

[coverage-badge]: https://img.shields.io/coveralls/zestedesavoir/zmarkdown.svg

[coverage-status]: https://coveralls.io/github/zestedesavoir/zmarkdown

[license]: https://github.com/zestedesavoir/zmarkdown/blob/master/packages/remark-sub-super/LICENSE-MIT

[zds]: https://zestedesavoir.com

[npm]: https://www.npmjs.com/package/remark-sub-super

[mdast]: https://github.com/syntax-tree/mdast/blob/master/readme.md

[remark]: https://github.com/remarkjs/remark

[rehype]: https://github.com/rehypejs/rehype

[parent]: https://github.com/syntax-tree/unist#parent

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