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
=> "getsetup", id
=> "tidy", call
=> \
&getsetup
);
17 hook
(type
=> "sanitize", id
=> "tidy", call
=> \
&sanitize
);
18 hook
(type
=> "checkconfig", id
=> "tidy", call
=> \
&checkconfig
);
29 description
=> "tidy command line",
36 if (! defined $config{htmltidy
}) {
37 $config{htmltidy
}="tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no --markup yes";
44 return $params{content
} unless defined $config{htmltidy
};
48 $SIG{PIPE
}=sub { $sigpipe=1 };
49 $pid=open2
(*IN
, *OUT
, "$config{htmltidy} 2>/dev/null");
51 # open2 doesn't respect "use open ':utf8'"
52 binmode (IN
, ':utf8');
53 binmode (OUT
, ':utf8');
55 print OUT
$params{content
};
64 if ($sigpipe || ! defined $ret) {
65 return gettext
("htmltidy failed to parse this html");