Registry / serialization / markdown-it-abbr

markdown-it-abbr

JSON →
library2.0.0jsnpmunverified

This package provides an abbreviation (`<abbr>`) tag plugin for the `markdown-it` markdown parser. It allows users to define abbreviations in their markdown content using a syntax similar to PHP Markdown Extra (e.g., `*[HTML]: Hyper Text Markup Language`), which are then rendered into proper HTML `<abbr>` tags with `title` attributes. The current stable version is 2.0.0. As a specific-purpose plugin for `markdown-it`, its release cadence is typically tied to `markdown-it`'s own updates or specific feature additions/bug fixes for the abbreviation parsing itself. Its key differentiator is its seamless integration with the `markdown-it` ecosystem, offering a standardized way to extend markdown parsing functionality without manual HTML manipulation. It does not support multi-line abbreviation definitions. The package is actively maintained, ensuring compatibility with newer `markdown-it` versions and addressing reported issues.

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

markdownitAbbr
import markdownitAbbr from 'markdown-it-abbr';
import { markdownitAbbr } from 'markdown-it-abbr'; // Incorrect as it's a default export const markdownitAbbr = require('markdown-it-abbr'); // Incorrect in an ESM context
For modern JavaScript/TypeScript projects using ES Modules, the package exports its plugin function as a default export.
markdownitAbbr
const markdownitAbbr = require('markdown-it-abbr');
import markdownitAbbr from 'markdown-it-abbr'; // Incorrect in a CommonJS context
Standard CommonJS import for Node.js environments. The imported value is the plugin function itself.
markdownitAbbr
window.markdownitAbbr
When the script is loaded directly in a browser without a module bundler, the plugin function attaches itself globally to the `window` object as `markdownitAbbr`.

Demonstrates initializing a markdown-it instance, registering the abbreviation plugin, and rendering markdown content that includes abbreviation definitions to HTML.

import MarkdownIt from 'markdown-it'; import markdownitAbbr from 'markdown-it-abbr'; const md = new MarkdownIt().use(markdownitAbbr); const markdownContent = ` *[HTML]: Hyper Text Markup Language *[W3C]: World Wide Web Consortium The HTML specification is maintained by the W3C. `; const htmlOutput = md.render(markdownContent); console.log(htmlOutput); /* <p>The <abbr title="Hyper Text Markup Language">HTML</abbr> specification is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.</p> */
Debug
Known issues
breakingUpgrading `markdown-it-abbr` to `v1.0.0` or higher requires `markdown-it` version `4.0.0` or greater. Older `markdown-it` versions are incompatible due to breaking API changes in `markdown-it`.
fix
Ensure your project's `markdown-it` dependency is `^4.0.0` or newer (e.g., `npm install markdown-it@^4.0.0`). Review `markdown-it`'s changelog for specific compatibility details.
affects: >=1.0.0
gotchaThis plugin strictly adheres to a single-line abbreviation definition syntax, consistent with a subset of PHP Markdown Extra. It does not support multi-line abbreviation definitions, which can be a point of confusion for users accustomed to other markdown processors.
fix
Ensure all abbreviation definitions (e.g., `*[TERM]: Full Definition`) are concise and entirely contained on a single line without line breaks.
affects: >=1.0.0
gotchaAbbreviation definitions are only recognized when they appear at the beginning of a line and follow the precise `*[TERM]: Definition` format. Incorrect syntax, missing the colon, or embedding definitions within paragraphs will prevent them from being parsed.
fix
Always place abbreviation definitions on their own line, typically at the top or bottom of the document, and strictly adhere to the `*[TERM]: Full Definition` pattern, including the asterisk, brackets, and colon.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: md.use is not a function
The `markdown-it` instance was not correctly initialized or the `markdown-it` library itself was not imported properly, leading to `md` not being a valid `MarkdownIt` object.
fix
Ensure `markdown-it` is correctly imported (e.g., `import MarkdownIt from 'markdown-it';` or `const MarkdownIt = require('markdown-it');`) and instantiated before calling `.use()` (e.g., `const md = new MarkdownIt();`).
Abbreviated terms in markdown are not rendering as <abbr> HTML tags; they appear as plain text.
The `markdown-it-abbr` plugin has been imported but not registered with your `markdown-it` instance, meaning the parser isn't aware of how to process abbreviation syntax.
fix
After initializing your `markdown-it` instance, you must explicitly register the plugin by calling `md.use(markdownitAbbr);`. Verify that `markdownitAbbr` is correctly imported and available.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
markdown-itrequiredRequired as the host parser for this plugin. Version 1.0.0+ of this plugin requires markdown-it v4.0.0+ for compatibility with its API.
Agent activity
48 hits · last 30 days
node
48
Resources
markdown-it-abbr — npm install markdown-it-abbr · libregistry