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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
iterator
✓ import iterator from 'markdown-it-for-inline';
✗ import { iterator } from 'markdown-it-for-inline';
The package exports a default function for use with `markdown-it.use()`. The README examples use a CommonJS `require` call, assigning the result to a variable like `iterator`.
iterator
✓ const iterator = require('markdown-it-for-inline');
This is the CommonJS `require` syntax as shown in the package's README for Node.js environments.
markdownitForInline
✓ const iterator = window.markdownitForInline;
✗ const iterator = require('markdown-it-for-inline'); // In browser
When loaded directly in a browser without a package system, the module exposes itself globally as `window.markdownitForInline`.
Demonstrates how to use markdown-it-for-inline to add 'target="_blank"' to all generated links, making them open in a new browser tab or window.
import MarkdownIt from 'markdown-it';
import markdownitForInline from 'markdown-it-for-inline';
// Initialize markdown-it with linkify enabled to ensure links are parsed
const md = new MarkdownIt({
linkify: true
});
// Use the plugin to modify 'link_open' tokens
// This example makes all links open in a new window by adding target="_blank"
md.use(markdownitForInline, 'url_new_win', 'link_open', function (tokens, idx) {
// `attrPush` adds a new attribute array or pushes to an existing one
tokens[idx].attrPush([ 'target', '_blank' ]);
});
const markdownContent = `
Check out my [website](https://example.com) and another link: https://another.org.
This should also have target='_blank'.
`;
const htmlResult = md.render(markdownContent);
console.log(htmlResult);
// Expected output would have <a href="..." target="_blank">...</a> for links.
Debug
Known issues
gotchaThe plugin's README explicitly states that its speed 'will be not fastest of possible'. For very large documents or high-performance requirements, direct rule manipulation in markdown-it might be more efficient, though more complex.fixFor critical performance paths, consider implementing custom markdown-it rules directly via `md.core.ruler.after` or `md.inline.ruler.after` for fine-grained control, rather than iterating through tokens.
affects: >=0.1.0
breakingWhile markdown-it-for-inline itself has a stable API, major version changes in its host library, `markdown-it`, can introduce breaking changes in token structures or parsing pipelines that might affect how this plugin interacts with tokens.fixAlways test `markdown-it-for-inline` thoroughly when upgrading `markdown-it` to a new major version. Refer to `markdown-it`'s migration guides for specific token changes. If issues arise, check the plugin's GitHub issues for compatibility updates or workarounds.
affects: >=0.1.0 (with certain markdown-it versions)
gotchaEach rule registered with `md.use(iterator, 'rule_name', ...)` must have a unique rule name. Reusing a rule name will overwrite the previous rule or cause unexpected behavior without a clear error message.fixEnsure that the `rule name` parameter (the second argument to `md.use(iterator, 'rule_name', ...)`) is unique across all `markdown-it-for-inline` plugin instances and other markdown-it plugins.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: md.use is not a function
The markdown-it instance (`md`) has not been correctly initialized, or `md.use` is being called on a non-markdown-it object.
fixEnsure you `import MarkdownIt from 'markdown-it';` and initialize it as `const md = new MarkdownIt();` before calling `.use()`.
Plugin does not appear to be loading or applying changes.
The specified token type for the iterator might be incorrect, or the logic within the iterator function is not correctly identifying or modifying tokens.
fixVerify the `token type` (e.g., 'text', 'link_open') against the markdown-it token documentation. Use `console.log(tokens[idx])` inside the iterator function to inspect the token structure and confirm it matches expectations.
Audit
Dependencies
markdown-itrequiredThis package is a plugin for markdown-it and requires it to function. It should be installed alongside markdown-it.