考虑到以下内容:
"这是一个段落的例子。
这是另一段。"
如果我在模板中这样渲染:
<div class='post-content'>
{{#markdown}}
{{body}}
{{/markdown}}
</div>
我得到这样的输出
<pre><code>This is the example of one paragraph.</code></pre>
<p>And this is another paragraph.
我尝试了标记和摊牌。
摆脱pre/代码的唯一方法是这样做: <div class='post-content'>
{{#markdown}}
{{body}}
{{/markdown}}
</div>
这很奇怪。如何使标记块忽略空白?
你有点自相矛盾:空白在markdown中有的含义,你显然希望body
模板中的空白被正确解释,所以你不能忽略它。
也许你更喜欢这种格式,它应该也能工作。但总的来说,这只是一个漂亮的代码格式的问题。
<div class='post-content'>
{{#markdown}}{{body}}{{/markdown}}
</div>