]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/teximg.pm
add plugin safe/rebuild info (part 3 of 3)
[ikiwiki.git] / IkiWiki / Plugin / teximg.pm
index 8c3e88c6974a8f2d5aa00fc119ba1f8941f4c943..369c1088203cb2ec86e397bd46e9a98e1a4e544d 100644 (file)
@@ -11,9 +11,18 @@ use HTML::Entities;
 use IkiWiki 2.00;
 
 sub import { #{{{
+       hook(type => "getsetup", id => "teximg", call => \&getsetup);
        hook(type => "preprocess", id => "teximg", call => \&preprocess);
 } #}}}
 
+sub getsetup () { #{{{
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
+} #}}}
+
 sub preprocess (@) { #{{{
        my %params = @_;
        
@@ -27,14 +36,14 @@ sub preprocess (@) { #{{{
        
        my $code = $params{code};
        if (! defined $code && ! length $code) {
-               return "[[teximg ".gettext("missing tex code"). "]]";
+               error gettext("missing tex code");
        }
 
        if (check($code)) {
                return create($code, check_height($height), \%params);
        }
        else {
-               return "[[teximg ".gettext("code includes disallowed latex commands"). "]]";
+               error gettext("code includes disallowed latex commands")
        }
 } #}}}
 
@@ -85,7 +94,7 @@ sub create ($$$) { #{{{
                        .qq{" class="teximg" />};
        }
        else {
-               return qq{[[teximg <a href="$logurl">}.gettext("failed to generate image from code")."</a>]]";
+               error qq{<a href="$logurl">}.gettext("failed to generate image from code")."</a>";
        }
 } #}}}