Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

remark-sub-sup

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-sub-sup

Remark plugin for subscript (_{...}) and superscript (^{...}) syntax

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

remark-sub-sup

Remark plugin for subscript (_{...}) and superscript (^{...}) syntax.

Install

npm install remark-sub-sup

Use

import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkSubSup from 'remark-sub-sup'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'

const html = await unified()
  .use(remarkParse)
  .use(remarkSubSup)
  .use(remarkRehype)
  .use(rehypeStringify)
  .process('H_{2}O and x^{2}')

// Output: <p>H<sub>2</sub>O and x<sup>2</sup></p>

Syntax

H_{2}O              → H<sub>2</sub>O
x^{2}               → x<sup>2</sup>
a_{i}^{j}           → a<sub>i</sub><sup>j</sup>

Nested Braces

f_{g(x)}            → f<sub>g(x)</sub>
_{a{b}c}            → <sub>a{b}c</sub>

Escaping

\_{not sub}         → _{not sub}
_{a\}b}             → <sub>a}b</sub>

Why _{...} / ^{...}?

  • No GFM conflict~text~ stays as strikethrough
  • Familiar — LaTeX users know _{} and ^{}
  • Unambiguous — braces clearly delimit content
  • micromark-extension-sub-sup — tokenizer
  • mdast-util-sub-sup — mdast utilities

License

MIT

Keywords

remark

FAQs

Package last updated on 13 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts