Micromark extension for subscript (_{...}) and superscript (^{...}) syntax
npm install micromark-extension-sub-supMicromark extension for subscript (_{...}) and superscript (^{...}) syntax.
``bash`
npm install micromark-extension-sub-sup
`javascript
import { micromark } from 'micromark'
import { subSup } from 'micromark-extension-sub-sup'
const html = micromark('H_{2}O and x^{2}', {
extensions: [subSup()]
})
`
`markdown`
H_{2}O subscript
x^{2} superscript
_{a{b}c} nested braces preserved
_{a\}b} escaped closing brace
- Starts with _{ or ^{}
- Ends with (with brace balancing)
- Cannot span multiple lines
- \} → escaped } (doesn't close)\{
- → escaped { (doesn't affect brace depth)\\
- → escaped \
This extension creates the following tokens:
- subscript — whole subscriptsubscriptMarker
- — the _{ and }subscriptData
- — content between markerssuperscript
- — whole superscriptsuperscriptMarker
- — the ^{ and }superscriptData
- — content between markers
- mdast-util-sub-sup — mdast utilities
- remark-sub-sup` — remark plugin
MIT