Last active
December 5, 2023 16:01
-
-
Save uncenter/5db09920e8fe879c38e96e59b2367895 to your computer and use it in GitHub Desktop.
Use any class for markdown-it-container instead of just a single one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const markdownItContainer = require('markdown-it-container'); | |
const markdownIt = require('markdown-it'); | |
const md = new markdownIt().use(markdownItContainer, 'dynamic', { | |
validate: function () { | |
return true; | |
}, | |
render: function (tokens, idx) { | |
const token = tokens[idx]; | |
return token.nesting === 1 | |
? '<div class="' + token.info.trim() + '">' | |
: '</div>'; | |
}, | |
}); | |
console.log( | |
md.render(` | |
::: my-dynamic-block | |
Hello, world! | |
:::`), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got it. Thanks!