Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
markdown-it-container
Advanced tools
Plugin to create block-level custom containers for markdown-it markdown parser
The markdown-it-container package is a plugin for the markdown-it Markdown parser that allows you to create custom containers in your Markdown content. These containers can be used to add custom styling, notes, warnings, or any other block-level content that you want to differentiate from the rest of your Markdown content.
Custom Containers
This feature allows you to define custom containers in your Markdown content. In this example, a 'warning' container is created, which can be used to highlight warning messages.
```javascript
const md = require('markdown-it')();
const container = require('markdown-it-container');
md.use(container, 'warning');
const result = md.render(`
::: warning
*Warning*: This is a custom warning container.
:::
`);
console.log(result);
```
Custom Rendering
This feature allows you to customize the rendering of the containers. In this example, a 'note' container is created with custom rendering logic to include additional HTML structure and styling.
```javascript
const md = require('markdown-it')();
const container = require('markdown-it-container');
md.use(container, 'note', {
render: function (tokens, idx) {
var m = tokens[idx].info.trim().match(/^note\s+(.*)$/);
if (tokens[idx].nesting === 1) {
return '<div class="note">' + md.utils.escapeHtml(m[1]) + '\n';
} else {
return '</div>\n';
}
}
});
const result = md.render(`
::: note This is a custom note
*Note*: This is a custom note container.
:::
`);
console.log(result);
```
The markdown-it-attrs package allows you to add attributes to Markdown elements. While it doesn't create custom containers, it provides a way to add classes, IDs, and other attributes to elements, which can be used for styling and customization similar to markdown-it-container.
The markdown-it-admonition package provides a way to create admonition blocks (notes, warnings, tips, etc.) in Markdown. It is similar to markdown-it-container in that it allows for custom block-level content, but it is specifically designed for admonitions.
The markdown-it-div package allows you to create custom <div> containers in your Markdown content. It is similar to markdown-it-container but focuses specifically on <div> elements, providing a simpler API for creating custom containers.
Plugin for creating block-level custom containers for markdown-it markdown parser.
v2.+ requires markdown-it
v5.+, see changelog.
With this plugin you can create block containers like:
::: warning
*here be dragons*
:::
.... and specify how they should be rendered. If no renderer defined, <div>
with
container name class will be created:
<div class="warning">
<em>here be dragons</em>
</div>
Markup is the same as for fenced code blocks. Difference is, that marker use another character and content is rendered as markdown markup.
node.js, browser:
$ npm install markdown-it-container --save
$ bower install markdown-it-container --save
var md = require('markdown-it')()
.use(require('markdown-it-container'), name [, options]);
Params:
true
on success.:
), character to use in delimiter.var md = require('markdown-it')();
md.use(require('markdown-it-container'), 'spoiler', {
validate: function(params) {
return params.trim().match(/^spoiler\s+(.*)$/);
},
render: function (tokens, idx) {
var m = tokens[idx].info.trim().match(/^spoiler\s+(.*)$/);
if (tokens[idx].nesting === 1) {
// opening tag
return '<details><summary>' + md.utils.escapeHtml(m[1]) + '</summary>\n';
} else {
// closing tag
return '</details>\n';
}
}
});
console.log(md.render('::: spoiler click me\n*content*\n:::\n'));
// Output:
//
// <details><summary>click me</summary>
// <p><em>content</em></p>
// </details>
FAQs
Plugin to create block-level custom containers for markdown-it markdown parser
The npm package markdown-it-container receives a total of 207,029 weekly downloads. As such, markdown-it-container popularity was classified as popular.
We found that markdown-it-container demonstrated a not healthy version release cadence and project activity because the last version was released 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.