Is there a clever way to "repeat" this code for multiple similar containers, so I can create "note", "warning" and "important" asides?
(Currently it works only for "note"). Yes, I understand that I can simply copy and paste all this code block for "warning" and "important" containers (so it will be 30 lines of code instead of current 10), but I think there should be more compact form... Any help is appreciated.
.use(markdownitContainer, 'note', {
render: function (tokens, idx) {
var m = tokens[idx].info.trim().match(/^aside\s+(.*)$/);
if (tokens[idx].nesting === 1) {
return '<aside class="' + tokens[idx].info.trim() + '">\n';
} else {
return '</aside>\n';
}
}
})
// ::: note <aside class="note">
// Text => <p>Text</p>
// ::: </aside>
Is there a clever way to "repeat" this code for multiple similar containers, so I can create "note", "warning" and "important" asides?
(Currently it works only for "note"). Yes, I understand that I can simply copy and paste all this code block for "warning" and "important" containers (so it will be 30 lines of code instead of current 10), but I think there should be more compact form... Any help is appreciated.