Open mistyn8 opened 5 years ago
This is a valid request, but unfortunately I believe this is currently not so easy to implement. One method would be to implement this handling in a dedicated virtual method, which can be overridden.
Would you want this rule to be able to treat non breaking spaces separately? In other words should an element which includes only white space, but of which at least part of the white space are non breaking spaces, also be removed?
Maybe follow String.IsNullOrEmpty and String.IsNullOrWhiteSpace ??
A solution based on Char.IsWhiteSpace()
, which backs String.IsNulOrWhiteSpace
, might work if it is an option. I however found some detailed documentation at MDN https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace which suggest things are not that straight forward.
sanitizer.Tag("p").RemoveEmpty();
<p> </p>
results in<p> </p>
Could RemoveEmpty() be extended to cover RemoveEmptyOrWhitespace() ??