3 # requires 'tidy' binary, found in Debian or http://tidy.sf.net/
4 # mostly a proof-of-concept on how to use external filters.
5 # It is particularly useful when the html plugin is used.
8 package IkiWiki::Plugin::htmltidy;
16 hook(type => "sanitize", id => "tidy", call => \&sanitize);
19 sub sanitize (@) { #{{{
26 $pid=open2(*IN, *OUT, 'tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no');
31 debug("failed to run tidy: $@");
32 return $params{content};
35 # open2 doesn't respect "use open ':utf8'"
36 binmode (IN, ':utf8');
37 binmode (OUT, ':utf8');
39 print OUT $params{content};