Welcome! » Log In » Create A New Profile

how to remove empty html tag

Posted by wonderer 
how to remove empty html tag
April 28, 2011 10:36AM

Hi there!

I have a string like : "This is a <a href="javascript:func();">link</a>that is to be removed."

After purified, it becomes

"This is a <a>link</a>that is to be removed."

As there is no attributes on the <a> and </a>, they are meaningless now. I want purifier completely remove the tags while keeping the text inside (i.e. "link") the tag there. Is it possible?

I have turned on the AutoFormat.RemoveEmpty option but it seens not work in this case.

Re: how to remove empty html tag
April 28, 2011 10:42AM

I think someone managed to hack this up by setting href to be a required attribute. There's not a built-in way to do this though.

Your Email:


HTML input is enabled. Make sure you escape all HTML and angled brackets with &lt; and &gt;.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

Place code here

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}