apostrophecms / sanitize-html

Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis. Built on htmlparser2 for speed and tolerance
MIT License
3.68k stars 349 forks source link

Is it possible to transform and wrap? #591

Closed rob-rountree-cyted closed 1 year ago

rob-rountree-cyted commented 1 year ago

Say my "dirty HTML" is a <h3>Hello world!</h3> element which I'd like transformed to the following:

<p><span style="font-weight: bold;">Hello world!</span></p>

How might I achieve that with transformTags, or is there another way?

BoDonkey commented 1 year ago

There isn't a good way to do this ( I don't believe) with sanitize-html. Have you looked into the cheerio package. It can handle nested tags. Bob

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.