]> scripts.mit.edu Git - www/ikiwiki.git/commitdiff
* Don't run tidy with -xml as that fails if the input is not well-formed.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 4 Aug 2006 07:41:02 +0000 (07:41 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 4 Aug 2006 07:41:02 +0000 (07:41 +0000)
  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
IkiWiki/Render.pm
debian/changelog
doc/plugins/aggregate.mdwn
doc/plugins/write.mdwn

index fa08e4ef5d29f218018fa9da172a1fe2f5b1eb5a..6c1fba98e1b98e913ead06258a74ac21050d34de 100644 (file)
@@ -13,11 +13,11 @@ use IkiWiki;
 use IPC::Open2;
 
 sub import { #{{{
 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'); 
        # open2 doesn't respect "use open ':utf8'"
        binmode (IN, ':utf8'); 
        binmode (OUT, ':utf8'); 
index 09b871900da94d6f97627aced76ef5013ad0b342..b855d2c8f86b02e5a25da3cf822bdd482700c773 100644 (file)
@@ -187,7 +187,13 @@ sub genpage ($$$) { #{{{
                shift->(page => $page, destpage => $page, template => $template);
        });
        
                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 ($$) { #{{{
 } #}}}
 
 sub check_overwrite ($$) { #{{{
index de7d6434402e0af8be08117c76a70488f42fefb0..d68a37864891bb69f233172343ebeac63e63813d 100644 (file)
@@ -13,8 +13,15 @@ ikiwiki (1.16) UNRELEASED; urgency=low
   * Also generate rel=bookmark links for permalinks.
   * Fix the htmltidy plugin, which wasn't working due my breaking it when
     I added it..
   * 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
 
 
 ikiwiki (1.15) unstable; urgency=low
 
index 4cd5b57acc4316f31a115e4a841b1ad66cf6ac2c..fe17199e3882a5062240d6e0d9e95d22d06a75fa 100644 (file)
@@ -13,7 +13,9 @@ aggregated feeds.
 ## setup
 
 Make sure that you have the [[html]] plugin enabled, as the created pages are
 ## 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
 
 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
index 79bd75e9b8583d0e5fa13769b22f3a7b924cd979..6d90543895f95baa393b312bc31d4a5bf91adcdc 100644 (file)
@@ -129,10 +129,20 @@ to set it, as setting a variable that's not present is an error.
        IkiWiki::hook(type => "sanitize", id => "foo", call => \&sanitize);
 
 Use this to implement html sanitization or anything else that needs to
        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.
 
 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);
 ## delete
 
        IkiWiki::hook(type => "delete", id => "foo", call => \&delete);