sanitize-html icon indicating copy to clipboard operation
sanitize-html copied to clipboard

exclusiveFilter - a check to see if HREF in Anchor link is empty

Open antipath opened this issue 10 years ago • 1 comments

cleanHtml = (markup) => { return sanitizeHtml(markup, { allowedTags: ['p', 'b', 'i', 'em', 'a', 'strong', 'sup', 'sub', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'li', 'ol'], allowedAttributes: {'*': [], 'a': ['href', 'target']}, transformTags: {'h1': 'h2'}, exclusiveFilter: function(frame) { return frame.tag === 'a' && !frame.attribs.href.trim(); } }); }

is there a way to perverse the text even tho the Anchor tag is stripped?

antipath avatar May 12 '16 20:05 antipath

You could check it with frame.text in that exclusiveFilter function.

abea avatar May 28 '20 21:05 abea