aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/format.pm
blob: bbe3aa9fee56e28b978e8d11c0f5f71d6d1b8824 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl
package IkiWiki::Plugin::format;

use warnings;
use strict;
use IkiWiki 3.00;

sub import {
	hook(type => "preprocess", id => "format", call => \&preprocess);
}

sub preprocess (@) {
	my $format=$_[0];
	shift; shift;
	my $text=$_[0];
	shift; shift;
	my %params=@_;

	if (! defined $format || ! defined $text) {
		error(gettext("must specify format and text"));
	}
	elsif (! exists $IkiWiki::hooks{htmlize}{$format}) {
		error(sprintf(gettext("unsupported page format %s"), $format));
	}

	return IkiWiki::htmlize($params{page}, $params{destpage}, $format,
		IkiWiki::preprocess($params{page}, $params{destpage}, $text));
}

1