2 package IkiWiki::Plugin::htmlbalance;
4 # htmlbalance: Parse and re-serialize HTML to ensure balanced tags
6 # Copyright 2008 Simon McVittie <http://smcv.pseudorandom.co.uk/>
7 # Licensed under the GNU GPL, version 2, or any later version published by the
8 # Free Software Foundation
13 use HTML::TreeBuilder;
17 hook(type => "getsetup", id => "htmlbalance", call => \&getsetup);
18 hook(type => "sanitize", id => "htmlbalance", call => \&sanitize);
21 sub getsetup () { #{{{
29 sub sanitize (@) { #{{{
33 my $tree = HTML::TreeBuilder->new_from_content($params{content});
34 my @nodes = $tree->disembowel();
35 foreach my $node (@nodes) {
37 $ret .= $node->as_XML();
42 $ret .= encode_entities($node);