Registry / web-framework / markdown-it-sub

markdown-it-sub

JSON →
library2.0.0jsnpmunverified

markdown-it-sub is a specialized plugin designed for the popular markdown-it parser, extending its capabilities to render subscript `<sub>` HTML tags from specific Markdown syntax. It adopts a Pandoc-like markup convention, where content enclosed in tildes (e.g., `H~2~O`) is parsed and converted into a subscript element. The current stable version is 2.0.0. While an explicit release cadence is not provided, markdown-it plugins typically maintain long-term stability and are updated primarily in response to breaking changes within the core markdown-it library or critical bug fixes. Its primary differentiator is its focused functionality on subscript rendering, offering a lightweight and standards-compliant method for incorporating mathematical or chemical notations without the complexity of full-fledged LaTeX-like rendering engines. It integrates seamlessly into existing markdown-it setups, enhancing parsing capabilities with minimal overhead. The plugin does not currently support nested subscript markup.

npm install markdown-it-sub
INSTALL
IMPORT
SIG · MARKDOWN-IT-SUB
M
markdown-it-sub
web-frameworkjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

markdownitSub
import markdownitSub from 'markdown-it-sub';
import { markdownitSub } from 'markdown-it-sub';
The plugin typically exports itself as the default export for ESM usage, consistent with markdown-it plugin patterns.
markdownitSub
const markdownitSub = require('markdown-it-sub');
Standard CommonJS import for Node.js environments.
window.markdownitSub
// Include <script src="path/to/markdown-it-sub.min.js"></script>
When loaded directly in a browser without a module system, the plugin attaches itself globally to the `window` object.

Demonstrates initializing `markdown-it` and registering the subscript plugin, then rendering a Markdown string with subscript notation.

import MarkdownIt from 'markdown-it'; import markdownitSub from 'markdown-it-sub'; const md = MarkdownIt().use(markdownitSub); const markdownInput = 'H~2~O is the chemical formula for water, and E=mc~2~ is Einstein\'s famous equation.'; const htmlOutput = md.render(markdownInput); console.log(htmlOutput); // Expected output: <p>H<sub>2</sub>O is the chemical formula for water, and E=mc<sub>2</sub> is Einstein's famous equation.</p>
Debug
Known issues
breakingWhen upgrading markdown-it-sub to version 1.0.0 or higher, it is mandatory to ensure that your markdown-it core library is at least version 4.0.0. Older versions of markdown-it are incompatible with `markdown-it-sub` v1.x and above.
fix
Update your `markdown-it` dependency in `package.json` to `^4.0.0` or a newer compatible version (e.g., `npm install markdown-it@^4.0.0`).
affects: >=1.0.0
gotchaThe plugin's Pandoc-like markup (`H~2~O`) currently does not support nested subscript expressions. Only flat subscript ranges are parsed.
fix
Avoid attempting to nest subscript syntax (e.g., `A~B~C~D~`) as it will not render as intended. Simplify expressions or consider alternative rendering solutions if complex nesting is required.
affects: *
Errors
Common errors & fixes
TypeError: md.use is not a function
The `markdown-it` parser instance (`md`) was not correctly initialized before attempting to register the plugin, or `markdown-it` was imported incorrectly.
fix
Ensure `markdown-it` is imported and instantiated correctly: `const MarkdownIt = require('markdown-it'); const md = new MarkdownIt();` or `import MarkdownIt from 'markdown-it'; const md = new MarkdownIt();`.
ReferenceError: markdownitSub is not defined
The `markdown-it-sub` plugin was not correctly imported or required into the current scope.
fix
For CommonJS, use `const markdownitSub = require('markdown-it-sub');`. For ESM, use `import markdownitSub from 'markdown-it-sub';`. In browsers without a module loader, ensure the script is loaded and refer to `window.markdownitSub`.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
markdown-itrequiredRequired as the core parser for this plugin to extend.
Agent activity
4 hits · last 30 days
ahrefsbot
1
Resources
markdown-it-sub — npm install markdown-it-sub · libregistry