]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/toggle.pm
add plugin safe/rebuild info (part 3 of 3)
[ikiwiki.git] / IkiWiki / Plugin / toggle.pm
index cd9617e259d5433f561faabb4719abc7756c8d75..610d38e3ac0d8e39c43d56e727f098441862b5ce 100644 (file)
@@ -60,6 +60,7 @@ function getElementsByClass(cls, node, tag) {
 EOF
 
 sub import { #{{{
+       hook(type => "getsetup", id => "toggle", call => \&getsetup);
        hook(type => "preprocess", id => "toggle",
                call => \&preprocess_toggle);
        hook(type => "preprocess", id => "toggleable",
@@ -67,6 +68,14 @@ sub import { #{{{
        hook(type => "format", id => "toggle", call => \&format);
 } # }}}
 
+sub getsetup () { #{{{
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
+} #}}}
+
 sub genid ($$) { #{{{
        my $page=shift;
        my $id=shift;
@@ -110,7 +119,7 @@ sub preprocess_toggleable (@) { #{{{
 sub format (@) { #{{{
         my %params=@_;
 
-       if ($params{content}=~s!(<div class="toggleable(?:-open)?" id="[^"]+">)</div>!$1!g) {
+       if ($params{content}=~s!(<div class="toggleable(?:-open)?" id="[^"]+">\s*)</div>!$1!g) {
                $params{content}=~s/<div class="toggleableend">//g;
                if (! ($params{content}=~s!^<body>!<body>$javascript!m)) {
                        # no </body> tag, probably in preview mode