【发布时间】:2016-08-21 22:36:15
【问题描述】:
当尝试将这个简单的 Markdown 转换为 html 时:
* section one
* item one
* item two
This is the first section
* section two
* item one
* item two
This is the second section
我收到的 html 是:
<ul>
<li>
<p>section one</p>
<ul>
<li>item one</li>
<li>
<p>item two</p>
<p>This is the first section</p>
</li>
</ul>
</li>
<li>
<p>section two</p>
<ul>
<li>item one</li>
<li>
<p>item two</p>
<p>This is the second section</p>
</li>
</ul>
</li>
</ul>
第一级列表中的段落是嵌套列表的第二个列表项的一部分。
我希望这一段是嵌套列表的兄弟,我什至在不同的在线编辑器中对其进行了测试,它们按照我的预期呈现,而不像 marked 的结果。
我做错了什么还是marked 中的错误?
我尝试使用这些选项,但没有任何帮助。
代码如下:
const marked = require("marked");
let str = "* section one\n\t* item one\n\t* item two\n\n\tThis is the first section";
str += "\n\n* section two\n\t* item one\n\t* item two\n\n\tThis is the second section";
marked(str)
【问题讨论】:
标签: javascript markdown javascript-marked