]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/format.pm
1e21a0bdc59d01b1768e04a812b6fd59e4afb7b1
[git.ikiwiki.info.git] / IkiWiki / Plugin / format.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::format;
4 use warnings;
5 use strict;
6 use IkiWiki 2.00;
8 sub import { #{{{
9         hook(type => "preprocess", id => "format", call => \&preprocess);
10 } #}}}
12 sub preprocess (@) { #{{{
13         my $format=$_[0];
14         shift; shift;
15         my $text=$_[0];
16         shift; shift;
17         my %params=@_;
19         if (! defined $format || ! defined $text) {
20                 error(gettext("must specify format and text"));
21         }
22         elsif (! exists $IkiWiki::hooks{htmlize}{$format}) {
23                 error(sprintf(gettext("unsupported page format %s"), $format));
24         }
26         return IkiWiki::htmlize($params{page}, $params{destpage}, $format,
27                 IkiWiki::preprocess($params{page}, $params{destpage}, $text));
28 } #}}}
30 1