Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanitizer.Tag("p").RemoveEmpty(); <p> </p> results in <p>&#160;</p> #21

Open
mistyn8 opened this issue Jul 4, 2019 · 3 comments
Open

Comments

@mistyn8
Copy link

mistyn8 commented Jul 4, 2019

sanitizer.Tag("p").RemoveEmpty();
<p> </p> results in <p>&#160;</p>

Could RemoveEmpty() be extended to cover RemoveEmptyOrWhitespace() ??

@cakkermans
Copy link
Contributor

cakkermans commented Oct 27, 2019

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?

@mistyn8
Copy link
Author

mistyn8 commented Nov 7, 2019

Maybe follow String.IsNullOrEmpty and String.IsNullOrWhiteSpace ??

@cakkermans
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants