remark-sub-sup
v1.0.0
Published
Remark plugin for subscript (_{...}) and superscript (^{...}) syntax
Maintainers
Readme
remark-sub-sup
Remark plugin for subscript (_{...}) and superscript (^{...}) syntax.
Install
npm install remark-sub-supUse
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
Related
micromark-extension-sub-sup— tokenizermdast-util-sub-sup— mdast utilities
License
MIT
