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');
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 ($$) { #{{{
* Also generate rel=bookmark links for permalinks.
* Fix the htmltidy plugin, which wasn't working due my breaking it when
I added it..
-
- -- Joey Hess <joeyh@debian.org> Fri, 4 Aug 2006 03:03:19 -0400
+ * 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.
+
+ -- Joey Hess <joeyh@debian.org> Fri, 4 Aug 2006 03:33:09 -0400
ikiwiki (1.15) unstable; urgency=low
## setup
Make sure that you have the [[html]] plugin enabled, as the created pages are
-in html format. The [[meta]] and [[tag]] plugins are also recommended.
+in html format. The [[meta]] and [[tag]] plugins are also recommended. The
+[[htmltidy]] plugin is suggested, since feeds can easily contain invalid
+html which tidy can fix.
You will need to run ikiwiki periodically from a cron job, passing it the
--aggregate parameter, to make it check for new posts. Here's an example
IkiWiki::hook(type => "sanitize", id => "foo", call => \&sanitize);
Use this to implement html sanitization or anything else that needs to
-modify the content of a page after it has been fully converted to html.
+modify the body of a page after it has been fully converted to html.
The function is passed the page content and should return the sanitized
content.
+## format
+
+ IkiWiki::hook(type => "format", id => "foo", call => \&format);
+
+The function is passed the complete page content and can reformat it
+and return the new content. The difference between format and sanitize is
+that sanitize only acts on the page body, while format can modify the
+entire html page including the header and footer inserted by ikiwiki, the
+html document type, etc.
+
## delete
IkiWiki::hook(type => "delete", id => "foo", call => \&delete);