X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/3ef8864122c2e665d41ed4d45baa50d4a5d21873..b6774bc6afac48e2c0a122647edc1485e7174a6e:/IkiWiki/Plugin/flattr.pm diff --git a/IkiWiki/Plugin/flattr.pm b/IkiWiki/Plugin/flattr.pm index 9cf9dfb13..3aee1eb93 100644 --- a/IkiWiki/Plugin/flattr.pm +++ b/IkiWiki/Plugin/flattr.pm @@ -8,7 +8,7 @@ use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "flattr", call => \&getsetup); hook(type => "preprocess", id => "flattr", call => \&preprocess); - hook(type => "sanitize", id => "flattr", call => \&sanitize, last => 1); + hook(type => "format", id => "flattr", call => \&format); } sub getsetup () { @@ -54,16 +54,17 @@ sub preprocess (@) { ''; } -sub sanitize (@) { +sub format (@) { my %params=@_; # Add flattr's javascript to pages with flattr buttons. if ($flattr_pages{$params{page}}) { - return flattrjs().$params{content}; - } - else { - return $params{content}; + if (! ($params{content}=~s!^(]*>)!$1.flattrjs()!em)) { + # no tag, probably in preview mode + $params{content}=flattrjs().$params{content}; + } } + return $params{content}; } my $js_cached;