call format hooks when generating page previews
[ikiwiki.git] / IkiWiki / Plugin / toggle.pm
index df5a2a7373290026a11910b97b94a291f24eed5c..8089443e02b9296d37d393b83ba6456a7c0a4e45 100644 (file)
@@ -112,7 +112,10 @@ sub format (@) { #{{{
 
        if ($params{content}=~s!(<div class="toggleable" id="[^"]+">)</div>!$1!g) {
                $params{content}=~s/<div class="toggleableend">//g;
-               $params{content}=~s!^<\/body>!$javascript</body>!m;
+               if (! ($params{content}=~s!^<\/body>!$javascript</body>!m)) {
+                       # no </body> tag, probably in preview mode
+                       $params{content}.=$javascript;
+               }
        }
        return $params{content};
 } # }}}