Is there a good npm package that can remove unnecessary nested tags in an html string running on a nodeJS server (no browswer DOM)? I've tried sanitize-html, but it doesn't seem possible to do this.
I receive email html from the user, so I can't control the input format, and it sometimes comes with unnecessary nested tags, like so:
<div>
<div>
<div>
<div>
<div>Hey Bob:<br /></div>
<div>
I wanted to see if you had a chance to review this. Three things come to mind:<br />
</div>
<ol>
<li>blah<br /></li>
<li>blah<br /></li>
<li>blah<br /></li>
</ol>
</div>
</div>
</div>
</div>
I want to unwrap the outer divs (and any other unnecessarily wrapped tags within the string) until I just have a result that looks like:
<div>
<div>Hey Bob:<br /></div>
<div>
I wanted to see if you had a chance to review this. Three things come to mind:<br />
</div>
<ol>
<li>blah<br /></li>
<li>blah<br /></li>
<li>blah<br /></li>
</ol>
</div>
I tried using cheerio and jsdom, but neither seem to have an unwrap function like beautifulsoup does in python.