この単純なマークダウンを 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>
最初のレベルのリスト内の段落は、ネストされたリストの 2 番目のリスト項目の一部です。
この段落は、ネストされたリストの兄弟であると予想します。別のオンライン エディターでテストしたところ、期待どおりにレンダリングされ、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)