markdown-it-admon-collapsible
v1.9.5
Published
Plugin to create admonitions for markdown-it markdown parser
Maintainers
Readme
markdown-it-admon-collapsible
Note: This package is a fork of markdown-it-admon with added support for collapsible blocks (???), inspired by Material for MkDocs. Plugin for creating admonitions for markdown-it markdown parser.
With this plugin you can have collapsible admonitions:
- Admonition blocks: Use !!! to create styled info/warning/note blocks
- Collapsible blocks: Use ??? to create blocks with a toggle, collapsed or expanded
- ???+ starts the block expanded
- All admonition and collapsible types from Material for MkDocs are supported
- Toggle button and styles included
Examples:
!!! note
This is an admonition
??? warning "Collapsible Warning"
This block can be expanded/collapsed
???+ info "Expanded Info"
This block starts expandedMarkdown syntax is inspired by Material for MkDocs and supports both admonition blocks (!!!) and collapsible blocks (???).
rST suggests the following "types": attention, caution, danger, error, hint, important, note, tip, and warning; however, you’re free to use whatever you want.
A styles file does support the following admonition types: Credits go to vscode-markdown-extended.
'note',
'summary', 'abstract', 'tldr',
'info', 'todo',
'tip', 'hint',
'success', 'check', 'done',
'question', 'help', 'faq',
'warning', 'attention', 'caution',
'failure', 'fail', 'missing',
'danger', 'error', 'bug',
'example', 'snippet',
'quote', 'cite'
Installation
node.js:
npm install markdown-it-admon-collapsible --saveAPI
const md = require('markdown-it')()
.use(require('markdown-it-admon-collapsible') [, options]);Plugin Options
render: (optional) Custom render function.validate: (optional) Custom validation function. If provided, this function will be used to validate the parameters for admonitions.
Example usage
const md = require('markdown-it')();
const admonitionPlugin = require('markdown-it-admon-collapsible');
md.use(admonitionPlugin, {
validate: function(params) {
// Custom validation logic
return params.startsWith('note');
}
});