Registry / serialization / markdown-it-sup

markdown-it-sup

JSON →
library2.0.0jsnpmunverified

This package provides a dedicated plugin for the popular `markdown-it` markdown parser, specifically designed to render superscript text. It utilizes a Pandoc-like `^...^` syntax; for instance, the input `29^th^` will be processed into `29<sup>th</sup>`. The current stable version is 2.0.0. As a single-feature plugin for a stable core library like `markdown-it`, its release cadence is generally infrequent, primarily driven by maintenance needs, compatibility updates with `markdown-it` itself, or bug fixes. A key characteristic is its straightforward integration with `markdown-it` and its adherence to a commonly understood markup convention for superscripts, making it easy to adopt for existing `markdown-it` projects. Notably, the plugin currently does not support nested superscript markup.

npm install markdown-it-sup
INSTALL
IMPORT
SIG · MARKDOWN-IT-SUP
M
markdown-it-sup
serializationjavascriptv2.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.

markdownitSup
import markdownitSup from 'markdown-it-sup';
import { markdownitSup } from 'markdown-it-sup';
The package exports its plugin function as a default export for ESM. Do not use named imports.
markdownitSup (CommonJS)
const markdownitSup = require('markdown-it-sup');
const { markdownitSup } = require('markdown-it-sup');
For Node.js environments using CommonJS, the module exports the plugin function directly.
window.markdownitSup
// No direct import needed if loaded via script tag in browser
import markdownitSup from 'markdown-it-sup'; // In browser, if script tag used
When loaded directly in a browser without a module bundler, the plugin becomes globally available as `window.markdownitSup`. Modern applications should use module bundlers.

This quickstart demonstrates how to initialize `markdown-it` and apply the `markdown-it-sup` plugin to process and render superscript markdown syntax.

import MarkdownIt from 'markdown-it'; import markdownitSup from 'markdown-it-sup'; function renderSuperscript(markdownContent: string): string { const md = new MarkdownIt() .use(markdownitSup); return md.render(markdownContent); } const example = 'The 29^th^ of February is a leap day. H^2^O is water.'; console.log(renderSuperscript(example)); // Expected output: <p>The 29<sup>th</sup> of February is a leap day. H<sup>2</sup>O is water.</p>
Debug
Known issues
breakingVersions 1.x and above of `markdown-it-sup` require `markdown-it` version 4.x or newer. Older versions of `markdown-it` are not compatible.
fix
Ensure your `markdown-it` dependency is at least `^4.0.0` to avoid parsing errors or plugin initialization failures. Update with `npm install markdown-it@^4.0.0`.
affects: >=1.0.0
gotchaThe plugin explicitly does not support nested superscript markup. For example, `a^b^c^` will not render correctly as `a<sup>b<sup>c</sup></sup>` but rather as `a<sup>b</sup>c^`.
fix
Avoid nesting `^...^` syntax. If complex superscript structures are needed, consider custom rendering logic or an alternative plugin that specifically supports nesting.
affects: >=1.0.0
gotchaWhen using `markdown-it-sup` in a browser environment without a module bundler (by including the script tag directly), the plugin registers itself as a global `window.markdownitSup` variable. Attempting to `import` or `require` it in such a setup will fail.
fix
For browser usage, either integrate with a module bundler (Webpack, Rollup, etc.) and use standard `import` statements, or ensure you reference `window.markdownitSup` directly after the script is loaded if not using a bundler.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: md.use is not a function
The `markdown-it` package was not correctly imported or initialized, or a different object is being treated as the `markdown-it` instance.
fix
Ensure you have `markdown-it` installed (`npm install markdown-it`) and that you are calling `.use()` on an instantiated `MarkdownIt` object, e.g., `const md = new MarkdownIt();`.
Error: Cannot find module 'markdown-it-sup'
The `markdown-it-sup` package has not been installed or there's a typo in the import/require path.
fix
Install the package using `npm install markdown-it-sup` and verify the import/require statement matches the package name exactly.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
markdown-itrequiredThis plugin extends markdown-it; it is a peer dependency required for parsing markdown.
Agent activity
34 hits · last 30 days
node
34
Resources
markdown-it-sup — npm install markdown-it-sup · libregistry