
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
markdown-it-admonitions
Advanced tools
A markdown-it plugin for rendering admonitions (callouts/alerts).
npm install markdown-it-admonitions
import MarkdownIt from 'markdown-it';
import admonitionPlugin from 'markdown-it-admonitions';
const md = new MarkdownIt();
md.use(admonitionPlugin);
const result = md.render(`
:::note Custom Title
This is a note admonition with a custom title.
:::
:::warning
This is a warning with the default title.
:::
`);
The plugin supports two syntax styles:
:::note Optional Title
Content goes here
:::
> [!note] Optional Title
> Content goes here
> More content
Both styles can be enabled or disabled independently via options.
note 📝tip 💡warning ⚠️danger 🚨info ℹ️success ✅md.use(admonitionPlugin, {
// Custom types to register
types: ['note', 'tip', 'warning', 'danger', 'info', 'custom'],
// Custom emoji icons for types (used when lucideIcons is false)
icons: {
custom: '✨',
note: '📌'
},
// Use Lucide icons instead of emojis (default: false)
// See "Lucide Icons" section below for details
lucideIcons: false,
// Custom marker for Docusaurus style (default is ":")
marker: ':',
// Enable/disable syntax styles
// NOTE: At least one must be enabled (default: both true)
obsidianStyle: true, // Enable > [!type] syntax (default: true)
docusaurusStyle: true, // Enable ::: type syntax (default: true)
// Custom render functions per type
// IMPORTANT: Both 'open' and 'close' must be provided together for symmetric rendering
customRenders: {
custom: {
open: (tokens, idx, options, env, slf) => {
tokens[idx].attrJoin('class', 'my-custom-class');
return slf.renderToken(tokens, idx, options);
},
close: (tokens, idx, options, env, slf) => {
return slf.renderToken(tokens, idx, options);
}
}
}
});
The plugin supports Lucide icons via react-icons. When enabled, the plugin renders icon placeholders with data-lucide-icon attributes that you can hydrate with your preferred icon library.
Installation:
npm install react-icons
Enable Lucide icons:
// Use default Lucide icon mappings
md.use(admonitionPlugin, {
lucideIcons: true
});
// Or provide custom icon name mappings
md.use(admonitionPlugin, {
lucideIcons: {
note: 'LuPencil', // Override default
tip: 'LuZap', // Override default
custom: 'LuSparkles' // Add new type
}
});
Default Lucide icon mappings:
| Type | Icon Name | Icon |
|---|---|---|
| note | LuStickyNote | 📄 |
| tip | LuLightbulb | 💡 |
| warning | LuTriangleAlert | ⚠️ |
| danger | LuCircleAlert | 🚨 |
| info | LuInfo | ℹ️ |
| success | LuCircleCheck | ✅ |
React example (hydrating icons):
import { useEffect } from 'react';
import * as LucideIcons from 'react-icons/lu';
import { createRoot } from 'react-dom/client';
function hydrateAdmonitionIcons() {
const iconElements = document.querySelectorAll('[data-lucide-icon]');
iconElements.forEach((el) => {
const iconName = el.getAttribute('data-lucide-icon');
const IconComponent = LucideIcons[iconName];
if (IconComponent) {
const root = createRoot(el);
root.render(<IconComponent />);
}
});
}
// Call after rendering markdown
useEffect(() => {
hydrateAdmonitionIcons();
}, [markdownContent]);
HTML output with Lucide icons enabled:
<div class="admonition admonition-note">
<div class="admonition-title">
<span class="admonition-icon admonition-icon-lucide" data-lucide-icon="LuStickyNote"></span>
Note
</div>
<div class="admonition-content">
Content here
</div>
</div>
This plugin enforces symmetry principles to ensure proper HTML structure and consistent behaviour:
open and close together. Providing only one will result in a validation error.obsidianStyle or docusaurusStyle must be enabled. Both are enabled by default.// ✅ Correct: Both open and close provided
customRenders: {
note: {
open: (tokens, idx, options, env, slf) => '<div class="custom">',
close: (tokens, idx, options, env, slf) => '</div>'
}
}
// ❌ Invalid: Only open provided (will throw TypeError)
customRenders: {
note: {
open: (tokens, idx, options, env, slf) => '<div class="custom">'
}
}
The package includes default CSS files with attractive styling for all admonition types. Two versions are available:
admonitions.css - Full version with comments and formatting (recommended for development)admonitions.min.css - Minified version for production use<!-- Development -->
<link rel="stylesheet" href="node_modules/markdown-it-admonitions/admonitions.css">
<!-- Production -->
<link rel="stylesheet" href="node_modules/markdown-it-admonitions/admonitions.min.css">
// Development
import 'markdown-it-admonitions/admonitions.css';
// Production
import 'markdown-it-admonitions/admonitions.min.css';
The default stylesheet includes:
prefers-color-schemeYou can preview all admonition styles by opening demo.html in your browser. The demo includes:
You can override the default styles by adding your own CSS rules:
/* Example: Custom styling for note admonitions */
.admonition-note {
border-left-color: #0066cc;
}
.admonition-note .admonition-title {
background-colour: #e6f2ff;
colour: #0066cc;
}
The plugin is written in TypeScript and includes full type definitions:
import type { AdmonitionPluginOptions } from 'markdown-it-admonitions';
const options: AdmonitionPluginOptions = {
types: ['note', 'warning'],
icons: {
note: '📝'
}
};
# Install dependencies
npm install
# Build the package (includes CSS minification)
npm run build
# Build just the CSS (generates minified version)
npm run build:css
# Watch mode for development
npm run dev
The minified CSS file (admonitions.min.css) is automatically generated from the source file (admonitions.css) during the build process.
Important: Only edit admonitions.css. The minified version is auto-generated and tracked in .gitignore.
When you make changes to admonitions.css:
npm run build:css to regenerate the minified version (or npm run build for full build)MIT
FAQs
A markdown-it plugin for rendering admonitions
The npm package markdown-it-admonitions receives a total of 9 weekly downloads. As such, markdown-it-admonitions popularity was classified as not popular.
We found that markdown-it-admonitions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.