The original poster, scottf, created a Block BBCode markdown extension for Discourse that works in preview but not after posting. Falco suspected an issue with module imports, but scottf shared the plugin code, which was found to be simple and not importing anything. sam identified the issue as a naming problem and suggested moving the markdown extension to the discourse-markdown directory, which scottf confirmed fixed the issue.
However, sirdavidoff is experiencing a similar problem when trying to override the fence renderer, and carkod also reports the issue despite having the extension in the correct directory (/assets/javascripts/discourse-markdown). carkod suspects that server reloading may be required for the changes to take effect.
I have followed these instructions to create a Block BBCode markdown extension for Discourse.
The plugin works when previewing and editing a topic. However, when I actually post the Topic, the raw BBCode mark up appears in the post completely unprocessed.
Is there something I need to do to make sure the plugin operates on posted topics?
I have the same problem when trying to override the fence renderer (md.renderer.rules.fence) — it works in the preview window, but the default Discourse render is shown after submission.
Here is the code:
export function setup(helper) {
if (!helper.markdownIt) return;
helper.allowList(['div.embedded_workflow', 'div.embedded_tip']);
helper.registerPlugin((md) => {
md.renderer.rules.fence = function (tokens, idx, options, env, slf) {
let content = tokens[idx].content;
return '<div class="embedded_workflow">' +
'<div class="embedded_tip">Copy and paste this code into n8n to play with the workflow</div>' +
tokens[idx].content +
'</div>'
};
});
}
You can also see the full plugin structure here. Any help would be greatly appreciated!