Closed IsraelSanabriaMx closed 6 years ago
Why did you remove so many test cases?
Thank you for contributing this feature idea, and my sincerest apologies for taking so long to review it.
I like the idea of using configuration options to allow certain HTML tags and attributes to be preserved, but I'm not 100% convinced this is the best approach.
IMHO, I think we should provide two different options with similar semantics - let's call them whitelist
(replacing what you suggested) and blacklist
(replacing remove_nodes
and possibly strip_tags
) for now. Both would take an array of tag and attribute selectors like this:
array('address', 'a[href]', '[src]', 'meta[charset=utf-8]')
This would match:
<address>
elements<a>
) containing an href
property (thus excluding things like anchors)src
attribute<meta charset="utf-8">
(not convinced we need it to be this complex)I think this approach would give much better control as it would also allow us to match/keep/discard certain attributes only on certain elements, but of course it would also be more complex to implement.
So while I do appreciate the work you've put into this, I would prefer to see something a little more unified and powerful. Thank you though!
Changes
HtmlConverterTest
adding adataProvider
into unit testing.white_tags
property to establish an Array of allowed white tags.white_tag_wildcard
to mark only the allowed tags.documentation
of how to use this new functionality.Default Values
white_tags
=> array(),//Empty array
white_tag_wildcard
=> '|',//Pipe character