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-subVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing `markdown-it` and registering the subscript plugin, then rendering a Markdown string with subscript notation.
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`).
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.
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();`.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`.