私はhtml文字列を持っています。いくつかの操作を行う必要があるため、jquery を使用する必要があります。ただし、jQuery が文字列に追加のタグを追加するという問題があります。どうすればそれを回避できますか。
var html = marked(input); //returns an html string
console.log(html); //prints: <p>test<div>Type</div></p>
var tree = $("<div>" + html + "</div>");
//generate html out of the jquery html
html = tree.html();
console.log(html); // now it is: <p>test</p><div>Type</div><p></p>
jQuery 2.0.3 と、Firefox と Chrome があるブラウザでテストしました。