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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to merge subsequent tags that are the same

mustafa0x opened this issue · comments

The problem to solve

Given <span>Hello</span> <span>World</span> or <b>Hello</b> <b>World</b> it would be nice to optionally merge the tags, so the above becomes <b>Hello World</b>.

Alternatives

Possible with regex, but not that robust.

This kind of thing is probably better done with cheerio. sanitize-html's scope doesn't extend to building a tree representation of the document.