امتداد Markdown الخاص بي يعمل في المعاينة لكنه لا يعمل على المحتوى المُعالَج

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’ve had this happen due to importing modules using Javascript import statement, and the differences in paths between the browser and the mini_racer.

Can you share your plugin code so we can help you to debug?

إعجابَين (2)

Thank you for the reply Rafael.

The plugin’s code is here:

As you can see it is very simple. I am using ES Module imports, but only for adding a button to the editing bar. The Markdown extension (https://gitlab.com/textblaze/discourse-snippets/blob/master/assets/javascripts/lib/markdown-it/snippets.js.es6) doesn’t import anything.

I think this is simple naming issue due to:

Move it from markdown-it to the discourse-markdown directory.

6 إعجابات

That fixed it. Thank you Sam.

3 إعجابات

لدي نفس المشكلة عند محاولة تجاوز مُرسّم السور (md.renderer.rules.fence) — فهو يعمل في نافذة المعاينة، لكن بعد الإرسال يظهر مُرسّم Discourse الافتراضي.

إليك الكود:

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">انسخ هذا الكود والصقه في n8n لتجربة سير العمل</div>' +
               tokens[idx].content +
             '</div>'
    };
  });

}

يمكنك أيضًا الاطلاع على بنية الإضافة الكاملة هنا. أي مساعدة ستكون مُقدَّرة جدًا!

إعجاب واحد (1)

هل نجح الأمر معك من قبل؟
في حالتي، لدي الملف في المجلد الصحيح /assets/javascripts/discourse-markdown ولا يزال يظهر فقط في المعاينة.
بالنسبة لبعض الأشخاص الآخرين، نجح الأمر بعد فترة، مما يجعلني أعتقد أنهم قاموا بإعادة تحميل الخادم. لقد فعلت ذلك أيضًا ولم أنجح.