在系统生成的帖子中包含 raw_html

我试图创建一个系统管理的帖子,该帖子在开发中的网站插件上使用原始 HTML。查看文档和各种帖子后,我认为我采取了正确的方法,但预处理器仍然将我的帖子中的各个部分转义为 <code>

实际效果如下:

预期效果如下(我在浏览器中进行了编辑):

以下是我用于创建帖子的代码:

post = PostCreator.new(Discourse.system_user,
    title: mmbill.getTitle(),
    raw: cooked,
    cooked: cooked,
    cook_methods: Post.cook_methods[:raw_html],
    archetype: 'regular',
    created_at: createdAt,
    skip_validations: true,
    category: Mmbill.getCatId(),
    is_warning: false,
    meta_data: { mm_type: 'bill', mm_id: final[:bill_id] },
    shared_draft: false,
    topic_opts: {}
 )

感谢您的任何帮助!

我以前遇到过类似的问题,其中生成原始帖子内容的代码在某些行的开头有多余的空格。由于原始输出被解释为 Markdown,行首的多余空格会被视为代码块。根据您创建原始内容的方式,您可能可以通过重新格式化 HTML 来解决问题。

Looks like unnecessary leading spaces in the lines to me. Remove the leading spaces from those lines to correct the problem.

问题解决了,谢谢!现在它已按 HTML 写入的格式显示。问题在于 Ruby 将我用于格式化代码的制表符包含在了字符串中。

它决定移除 iframe,但我认为这与管理员的 iframe 设置有关。