Welcome! » Log In » Create A New Profile

Filter all elements except b, convert filtered elements to space

Posted by mrfr0g 
Filter all elements except b, convert filtered elements to space
December 13, 2011 01:26PM

I'm having a small issue where I have minified HTML, that I now need to strip out all tags except for the 'b' tag when it has the class 'red'. I am able to pretty easily do this with this config

'HTML.Allowed', 'b[class]'

'Attr.AllowedClasses', 'red'

Since my HTML text is minified, the output looks something like this

::input:: <p><ul><li>item</li><li><b class="red">item2</li></ul></p> ::output:: item<b class="red">item2</b> When when rendered, looks like, "itemitem2"

Since them items are block level elements, is there a way to add a space between them? So the output would look like,

::output:: item <b class="red">item2</b>

Re: Filter all elements except b, convert filtered elements to space
December 13, 2011 03:16PM

Yeah, this is a kind of known lacking feature One possible thing to do is to preprocess the HTML to add the extra spaces necessary before tossing it at HTML Purifier.

Sorry, you do not have permission to post/reply in this forum.