Registry / serialization / markdown-it-deflist

markdown-it-deflist

JSON →
library3.0.0jsnpmunverified

markdown-it-deflist is a plugin for the popular markdown-it markdown parser, enabling support for definition lists (`<dl>` HTML tags) based on the Pandoc definition list syntax. The current stable version is 3.0.0, released approximately two years ago. While `markdown-it` itself has a more frequent release cadence to address CommonMark specification updates and security fixes, its plugins like `markdown-it-deflist` typically update less often, primarily for compatibility with new `markdown-it` major versions or to introduce new features. As the official definition list plugin, its key differentiator is its seamless integration into the `markdown-it` ecosystem, providing a standardized way to render definition lists where this functionality is not included in the core parser.

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

markdownitDeflist
import markdownitDeflist from 'markdown-it-deflist';
import { markdownitDeflist } from 'markdown-it-deflist';
Since version 3.0.0, the package primarily exports its plugin function as a default export, aligning with its internal rewrite to ESM.
markdownit
import markdownit from 'markdown-it'; import markdownitDeflist from 'markdown-it-deflist'; const md = markdownit().use(markdownitDeflist);
const md = require('markdown-it')().use(require('markdown-it-deflist').markdownitDeflist);
When using ESM, both `markdown-it` and `markdown-it-deflist` should be imported as default exports. The plugin function itself is passed to `markdown-it.use()`.
require_style
const markdownit = require('markdown-it'); const markdownitDeflist = require('markdown-it-deflist'); const md = markdownit().use(markdownitDeflist);
const md = require('markdown-it').use(require('markdown-it-deflist'));
For CommonJS environments, both the `markdown-it` parser and the `markdown-it-deflist` plugin are loaded using `require()`. The plugin function is then directly passed to the `use` method.

Demonstrates how to import and register the markdown-it-deflist plugin with markdown-it, then render a sample markdown string containing definition lists to HTML.

import markdownit from 'markdown-it'; import markdownitDeflist from 'markdown-it-deflist'; const md = markdownit(); md.use(markdownitDeflist); const markdownInput = ` Term 1 : Definition 1 Term 2 : Definition 2a : Definition 2b Compact Term ~ Compact Definition ~ Another Compact Definition `; const htmlOutput = md.render(markdownInput); console.log(htmlOutput); /* Expected output: <dl> <dt>Term 1</dt> <dd>Definition 1</dd> <dt>Term 2</dt> <dd>Definition 2a</dd> <dd>Definition 2b</dd> </dl> <dl> <dt>Compact Term</dt> <dd>Compact Definition</dd> <dd>Another Compact Definition</dd> </dl> */
Debug
Known issues
breakingmarkdown-it-deflist version 3.0.0 and markdown-it version 14.0.0+ both include rewrites to ESM. While CJS fallbacks are often available, mixing ESM imports for one and CJS requires for the other in the same project can lead to unexpected behavior or errors, especially in bundler configurations.
fix
Ensure consistent module import style (ESM or CJS) across your project for markdown-it and its plugins. Prefer ESM `import` statements for modern applications.
affects: >=3.0.0 (markdown-it-deflist), >=14.0.0 (markdown-it)
gotchaThe package currently lacks official TypeScript type definitions, which can hinder type-safety and developer experience in TypeScript projects. An open GitHub issue tracks this problem.
fix
Consider creating local declaration files (`.d.ts`) for the plugin, or relying on community-provided types if available (e.g., `@types/markdown-it-deflist`), although none are officially listed.
affects: >=1.0.0
gotchamarkdown-it has undergone several internal API changes across major versions (e.g., v5.0 migration, CM spec updates), which can potentially impact external plugins. While markdown-it-deflist typically updates to maintain compatibility, users integrating older versions of the plugin with newer markdown-it versions (or vice-versa) might encounter unexpected rendering issues or errors.
fix
Always test plugin compatibility thoroughly when upgrading markdown-it or markdown-it-deflist. Refer to the changelogs of both packages for specific migration guidance.
affects: all
gotchaThe markdown-it core parser has had security vulnerabilities (e.g., ReDOS in linkify-it) in past versions. While markdown-it-deflist is a plugin, it relies on the core parser. Using an outdated markdown-it version with this plugin could expose your application to these vulnerabilities.
fix
Regularly update `markdown-it` to its latest stable version to benefit from security patches. Check `markdown-it`'s changelog and security advisories for details.
affects: all
Errors
Common errors & fixes
TypeError: markdown_it_1.default is not a function
Incorrectly importing markdown-it as a named import or using `require()` when an ESM default import is expected, or vice-versa, especially in TypeScript or bundled environments.
fix
Ensure `import markdownit from 'markdown-it';` (ESM) or `const markdownit = require('markdown-it');` (CJS) is used, as `markdown-it` provides a default export. Similarly for `markdown-it-deflist`.
Error: Cannot find module 'markdown-it-deflist'
The package was not installed or installed incorrectly, or the import/require path is wrong.
fix
Run `npm install markdown-it-deflist` or `yarn add markdown-it-deflist`. Verify the module name in your import/require statement.
Property 'use' does not exist on type 'typeof import("markdown-it")'
This TypeScript error often occurs when `markdown-it` is imported incorrectly, or if type definitions are missing/misconfigured, preventing the compiler from understanding that the imported `markdownit` function returns an instance with a `use` method.
fix
Ensure `import markdownit from 'markdown-it';` is used. If this persists, verify `markdown-it`'s type definitions are installed (e.g., `@types/markdown-it`) and correctly configured in your `tsconfig.json`. Consider initializing `markdownit()` immediately after import: `const md = markdownit();`.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
markdown-itrequiredThis package is a plugin for markdown-it and requires it as a peer dependency.
Agent activity
30 hits · last 30 days
node
30
Resources