Hello! I’m super new to discourse, but I am trying to make a plugin that basically creates a bunch of markdown rules. I am using Developer’s Guide to Markdown Extensions as well as the discourse-markdown/quotes.js.es6 for guidance.
My goal is to make a rule that creates a wrap: <div class="callout callout--dashed>…</div>
. My problem is that whenever I add a 2nd class to an element. It stops assigning any classes to it.
Here is my code:
const rulesForCallout = {
tag: 'callout',
before: function(state, tagInfo) {
let token = state.push('div_open', 'div', 1);
token.attrs = [];
token.attrs.push(['class', 'callout callout--dashed']);
},
after: function(state) {
state.push('div_close', 'div', -1);
}
};
export function setup(helper) {
if(!helper.markdownIt) { return; }
helper.whiteList(['div.callout']);
helper.registerPlugin( md => {
md.block.bbcode.ruler.push("callout", rulesForCallout);
});
}
I have done console.log(token.attrs)
which returns what I’d expect: ( [['class', 'callout callout--dashed']]
). So I am thinking maybe I am not whitelisting properly?
Any help would be much appreciated. Thank you!