1
當嘗試這個簡單的降價轉換爲HTML:標記返回與嵌套列表列表項和段落錯誤的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)
謝謝。我打開了一個[新問題](https://github.com/chjj/marked/issues/789),讓我們看看他們說了些什麼。 –