How to replace replace an string HTML non-whitelist tag with P tag ?
Example whitelist is p br tag
String Before
<p>hello</p>
<div class="test">hello world <br>
     <div>First LI</div>
     <div>Second LI <a href="">link</a></div>
</div>
<div class="fw">
     <p>shareeditflag <span>test</span></p>
</div>
<table>
     <tbody>
     </tbody>
</table>
String Expect
<p>hello</p>
<p class="test">hello world <br>
     <p>First LI</p>
     <p>Second LI <a href="">link</a></p>
</p>
<p class="fw">
     <p>shareeditflag <p>test</p></p>
</p>
<p>
     <p>
     </p>
</p>
In jquery way it can not be done because when the deep node has problem it require looping until no have non-whitelist ?
$('*:not(p,br)').replaceWith($('<p>' + this.innerHTML + '</p>'));