]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/format.pm
Merge commit 'upstream/master' into prv/po
[ikiwiki.git] / IkiWiki / Plugin / format.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::format;
3
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
7
8 sub import {
9         hook(type => "preprocess", id => "format", call => \&preprocess);
10 }
11
12 sub preprocess (@) {
13         my $format=$_[0];
14         shift; shift;
15         my $text=$_[0];
16         shift; shift;
17         my %params=@_;
18
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         }
25
26         return IkiWiki::htmlize($params{page}, $params{destpage}, $format,
27                 IkiWiki::preprocess($params{page}, $params{destpage}, $text));
28 }
29
30 1