【问题标题】:Showdown doesn't parse inside html blockShowdown 不会在 html 块内解析
【发布时间】:2020-09-18 18:00:55
【问题描述】:

我正在使用Showdown

当我运行这段代码时:

const showdown = require("showdown")

converter = new showdown.Converter()
const myMarkdownText = '## Some important text'
const myHtmlText = converter.makeHtml(myMarkdownText)

我明白了

<h2 id="someimportanttext">Some important text</h2>

这是预期的结果。

但是当我运行这段代码时:

const showdown = require("showdown")

converter = new showdown.Converter()
const myMarkdownText = '<div markdown = "1"> ## Some important text </div>'
const myHtmlText = converter.makeHtml(myMarkdownText)

我明白了

<div markdown = "1"><p>## Some important text </p></div>

这意味着 Showdown 没有解析 html div 中的内容。

关于如何使它工作的任何帮助?

【问题讨论】:

    标签: node.js showdown


    【解决方案1】:

    阅读 Showdown 文档 (https://github.com/showdownjs/showdown#valid-options) 后,我的结论是您应该启用 backslashEscapesHTMLTags 选项并反斜杠 html 标记。

    【讨论】:

    • 它没有用。我不认为这个选项与将markdown转换为html有关,而是将html转换为markdown(如何处理html中的转义标签)
    猜你喜欢
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 2019-12-08
    • 1970-01-01
    • 2011-10-13
    • 2014-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多