remove empty tag
mrbbp opened this issue · comments
mrbbp commented
Hello sure my question is stupid but i do not understand your example:
sanitizeHtml(
'<p>This is <a href="http://www.linux.org"></a><br/>Linux</p>',
{
exclusiveFilter: function(frame) {
return frame.tag === 'a' && !frame.text.trim();
}
}
);
i'm trying to remove empty span
and p
or fill with
or whitespace
i do not understand this line return frame.tag === 'a' && !frame.text.trim();
i do not understand the return with the test inside... (sorry it's tricky for me)
what does it suppose to return if tag is a
and ???
would you kindly develop your line?
best regards
Tom Boutell commented
This line returns true if the tag is "a" and it contains no text
(frame.text.trim() is falsy, i.e. the empty string).
So it discards links with no text in them and keeps the rest.
JavaScript treats expressions the same way regardless of whether they are
part of a "return" statement, an "if" statement, an assignment, etc.
…On Sun, Oct 31, 2021 at 1:17 PM mrbbp ***@***.***> wrote:
Hello sure my question is stupid but i do not understand your example:
sanitizeHtml(
'<p>This is <a href="http://www.linux.org"></a><br/>Linux</p>',
{
exclusiveFilter: function(frame) {
return frame.tag === 'a' && !frame.text.trim();
}
}
);
i'm trying to remove empty span *and* p or fill with or whitespace
i do not understand this line return frame.tag === 'a' &&
!frame.text.trim();
i do not understand the return with the test inside... (sorry it's tricky
for me)
what does it suppose to return if tag is a and ???
would you kindly develop your line?
best regards
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#509>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAH27LOG4AO4QGJI7XPEGTUJV24BANCNFSM5HCQDEJA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER
APOSTROPHECMS | apostrophecms.com | he/him/his
mrbbp commented
thanks for your help
now i'm able to modifying it as i wish
have to return a true if i want to discard a tag.
regards