【发布时间】:2020-11-01 10:45:24
【问题描述】:
我从来没有在这里问过问题,请多多包涵。我正在开发一个需要使用 markdown2 转换 markdown 文件的 wiki 项目。
return render(request, "encyclopedia/entry.html", {
"content": markdown2.markdown(util.get_entry(title)), "title": title
})
以上是我如何将它传递给 HTML 页面并使用正确的 HTML 标记在页面上呈现,但它似乎没有使用它们。以下是它在浏览器上的显示方式。
<pre><code> # HTML
</code></pre>
<p>HTML is a markup language that can be used to define the structure of a web page. HTML elements include</p>
<ul>
<li>headings</li>
<li>paragraphs</li>
<li>lists</li>
<li>links</li>
<li>and more!
most recent major version of HTML is HTML5.</li>
</ul>
我将它直接传递给一个 Django 模板,其中包含如下所示的安全过滤器。
<textarea name="content" rows="5" cols="50" readonly>
{{ content|safe }}
</textarea><br>
提前谢谢你,我希望我提供了足够的信息来解决我的问题。
【问题讨论】: