http://qs321.pair.com?node_id=682124


in reply to Re^2: Cleaning up HTML
in thread Cleaning up HTML

I've been trying some things with this module, and it's a bit hard going.

Agreed - it makes certain things very easy, but other bits (like adding allowed attributes) are nasty and crust. As we've discussed privately, this module could do with a major API overhaul. And a new name! Stripping scripts is just a part of what this does. It's actually a very powerful HTML tidier

I'd like to combine the two span tags, merging their style attributes:

Merging adjacent tags wasn't a use that I envisaged, but that was my own lack of imagination - the next version will have some nice way of querying the parent and sibling elements.

I've been trying to think about how you could do this with the current module (using private methods and properties), but it's nasty, and would probably result in having to reparse content, because to merge two spans, you need to know:

As per the private message you've just sent me, maintaining the nodes as a DOM-tree seems like the only reasonable way to handle this.

UPDATE So if we're planning on building DOM-trees, this starts sounding like a job for XML::LibXML, or HTML::TreeBuilder. But HTML::StripScripts does three things that neither of these modules does (AFAIK):

Ideas for the new glamorous DOM-tree based version gladly accepted