X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/27d029113faf479464db289a71b98cbf5e672793..d0d598e429313756192927418757e2869004049e:/IkiWiki/Plugin/embed.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/embed.pm b/IkiWiki/Plugin/embed.pm index 4fc91d978..664c95763 100644 --- a/IkiWiki/Plugin/embed.pm +++ b/IkiWiki/Plugin/embed.pm @@ -43,26 +43,35 @@ my $safehtml=qr{( my @embedded; -sub import { #{{{ +sub import { + hook(type => "getsetup", id => "embed", call => \&getsetup); hook(type => "filter", id => "embed", call => \&filter); -} # }}} +} -sub embed ($) { #{{{ +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => undef, + }, +} + +sub embed ($) { hook(type => "format", id => "embed", call => \&format) unless @embedded; push @embedded, shift; return "
"; -} #}}} +} -sub filter (@) { #{{{ +sub filter (@) { my %params=@_; $params{content} =~ s/$safehtml/embed($1)/eg; return $params{content}; -} # }}} +} -sub format (@) { #{{{ +sub format (@) { my %params=@_; $params{content} =~ s/
<\/div>/$embedded[$1]/eg; return $params{content}; -} # }}} +} 1