Remark plugin for adding support for pandoc-style superscript and subscript syntax to Markdown.
Adds two new node types to MDAST: superscript
and subscript
.
When using rehype, these will be stringified as sup
and sub
respectively.
Syntax
21^st^ Century
H~2~O
AST
The example above will yield:
{
type: 'paragraph',
children: [
{
type: 'text',
value: '21'
},
{
type: 'superscript',
children: [{
type: 'text',
value: 'st'
}]
},
{
type: 'text',
value: ' Century'
}
]
}
...
{
type: 'paragraph',
children: [
{
type: 'text',
value: 'H'
},
{
type: 'subscript',
children: [{
type: 'text',
value: '2'
}]
},
{
type: 'text',
value: 'O'
}
]
}
Installation
npm install --save remark-supersub
Usage
import unified from 'unified'
import markdown from 'remark-parse'
import html from 'rehype-stringify'
import remark2rehype from 'remark-rehype'
import supersub from 'remark-supersub'
unified()
.use(markdown)
.use(supersub)
.use(remark2rehype)
.use(html)
License
MIT © Alex Shaw