Registry / serialization / markdown-it-mark

markdown-it-mark

JSON →
library4.0.0jsnpmunverified

The `markdown-it-mark` package is a plugin for the `markdown-it` markdown parser, designed to extend its functionality by adding support for the HTML `<mark>` tag. It enables users to highlight text within their Markdown documents using the `==text==` syntax, which is then rendered as `<mark>text</mark>`. The current stable version is 4.0.0, last published approximately two years ago, indicating a mature and stable project likely in maintenance mode rather than rapid feature development. This plugin is highly focused, providing a straightforward implementation for text highlighting that adheres to similar rules as CommonMark emphasis. Its key differentiator is its seamless integration with the `markdown-it` ecosystem, offering a lightweight solution for a common formatting need without introducing complex parsing behaviors.

npm install markdown-it-mark
INSTALL
IMPORT
SIG · MARKDOWN-IT-MARK
M
markdown-it-mark
serializationjavascriptv4.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

markdownitMark
✓ import markdownit from 'markdown-it'; import markdownitMark from 'markdown-it-mark'; const md = markdownit().use(markdownitMark);
✗ import { markdownitMark } from 'markdown-it-mark';
Since v4, `markdown-it-mark` provides both CommonJS and ESM exports. The default ESM export is the plugin function itself. `markdown-it` also supports ESM imports.
markdownitMark (CommonJS)
✓ const markdownit = require('markdown-it'); const markdownitMark = require('markdown-it-mark'); const md = markdownit().use(markdownitMark);
✗ const { markdownitMark } = require('markdown-it-mark');
This is the documented CommonJS `require` pattern for both `markdown-it` and the plugin, as shown in the README examples.
window.markdownitMark
✓ // When loaded directly in a browser via <script> tag: const md = window.markdownit().use(window.markdownitMark);
For browser environments where the script is loaded directly without a package manager, the plugin attaches itself globally to `window.markdownitMark`. `markdown-it` itself similarly attaches to `window.markdownit`.

This quickstart demonstrates how to initialize `markdown-it` and register `markdown-it-mark` to parse and render `==marked==` syntax into `<mark>` HTML tags.

import markdownit from 'markdown-it'; import markdownitMark from 'markdown-it-mark'; // Initialize markdown-it with the mark plugin const md = markdownit(); md.use(markdownitMark); // Markdown input with mark syntax const markdownInput = 'This is ==marked== text and also ==important== content.'; // Render to HTML const htmlOutput = md.render(markdownInput); console.log(htmlOutput); // Expected output: <p>This is <mark>marked</mark> text and also <mark>important</mark> content.</p>
Debug
Known issues
breakingVersion 3.0.0 and subsequent major versions of `markdown-it-mark` (including 4.0.0) introduced a breaking change that requires `markdown-it` version 10.0.0 or higher. Older versions of `markdown-it-mark` may work with older `markdown-it` versions, but for v3.x and v4.x, ensure `markdown-it` is updated.
fix
Upgrade `markdown-it` to at least version 10.0.0: `npm install markdown-it@^10.0.0` (or the latest compatible version).
affects: >=3.0.0
gotchaThe `==text==` syntax for marking text strictly follows the same conditions as CommonMark emphasis rules. This means that the delimiters `==` must be balanced and not contain whitespace immediately inside them to correctly parse. For instance, `== mark ==` will not render as `<mark> mark </mark>`.
fix
Ensure that `==` delimiters directly surround the text to be marked, without leading or trailing spaces within the delimiters (e.g., `==marked==`, not `== marked ==`).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: md.use is not a function
This error typically occurs if `markdown-it` has not been correctly initialized or imported, or if `md` is not an instance of `MarkdownIt` before calling `.use()`.
fix
Ensure `markdownit` is imported and instantiated correctly (e.g., `const markdownit = require('markdown-it'); const md = markdownit();` or `import markdownit from 'markdown-it'; const md = markdownit();`).
Error: Cannot find module 'markdown-it-mark'
The `markdown-it-mark` package is not installed or the `require`/`import` path is incorrect.
fix
Run `npm install markdown-it-mark` to install the package. Verify the import/require path matches your module system configuration.
Text enclosed in '==' is not being rendered as <mark> tags.
The plugin might not be registered with `markdown-it`, or the input Markdown syntax for marking is incorrect (e.g., contains spaces inside `==` delimiters or has unbalanced delimiters).
fix
Ensure `md.use(markdownitMark)` is called after `markdown-it` initialization. Check that the markdown syntax is `==text==` with no internal spaces, similar to CommonMark emphasis rules.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
markdown-itrequiredThis package is a plugin for `markdown-it` and requires a compatible version of the core parser. Version 3.x and later of `markdown-it-mark` specifically require `markdown-it` version 10.x or higher for proper functionality.
Agent activity
10 hits · last 30 days
node
10
Resources
markdown-it-mark — npm install markdown-it-mark · libregistry