From 0708bb8aecaa6f4edcb60d84ed6555d61f83a2bc Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 4 Aug 2006 07:41:02 +0000 Subject: * Don't run tidy with -xml as that fails if the input is not well-formed. Run it with -asxhtml instead, so it will output well-formed xhtml no matter what the input. * Disable tidy warnings too. * Add a new format hook, and make tidy use it, since tidy can really only operate on and output complete html documents, not the body chunks that sanitise gets. --- IkiWiki/Plugin/htmltidy.pm | 6 +++--- IkiWiki/Render.pm | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/htmltidy.pm b/IkiWiki/Plugin/htmltidy.pm index fa08e4ef5..6c1fba98e 100644 --- a/IkiWiki/Plugin/htmltidy.pm +++ b/IkiWiki/Plugin/htmltidy.pm @@ -13,11 +13,11 @@ use IkiWiki; use IPC::Open2; sub import { #{{{ - IkiWiki::hook(type => "sanitize", id => "tidy", call => \&sanitize); + IkiWiki::hook(type => "format", id => "tidy", call => \&format); } # }}} -sub sanitize ($) { #{{{ - open2(*IN, *OUT, 'tidy -quiet -xml -indent -utf8') or return shift; +sub format ($) { #{{{ + open2(*IN, *OUT, 'tidy -quiet -asxhtml -indent -utf8 --show-warnings no') or return shift; # open2 doesn't respect "use open ':utf8'" binmode (IN, ':utf8'); binmode (OUT, ':utf8'); diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 09b871900..b855d2c8f 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -187,7 +187,13 @@ sub genpage ($$$) { #{{{ shift->(page => $page, destpage => $page, template => $template); }); - return $template->output; + $content=$template->output; + + run_hooks(format => sub { + $content=shift->($content); + }); + + return $content; } #}}} sub check_overwrite ($$) { #{{{ -- cgit v1.2.3