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

Support for nested tags in transformTags #598

Closed seanhexl closed 1 year ago

seanhexl commented 1 year ago

My use case is for supporting parsing of nested tags inside <video> embed tags specifically, but there could be other uses for this. These include, but are not limited to, <source> and tags (though it looks like the fallback content can be any valid HTML element to render).

The closest I can get currently is to enable source as a transformable tag, but this doubles the results if an a tag also exists inside the embed (as a fallback for the source element not being supported).

I can of course disable the source tag, but that can result in a scenario where video embeds with one or more sources and no static content to fall back on aren't transformed correctly.

I've had a quick crawl of the open and closed issues and can't see anything here about this already. I've updated to 2.8.1 (with half a day of fun with htmlparser2 dependency issues 😅); previously I was using 1.23.0.

BoDonkey commented 1 year ago

Can you add a "test case". So outline the input and the desired output so we can better understand what you are proposing. Thanks! 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.