aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/format.pm
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki/Plugin/format.pm')
-rw-r--r--IkiWiki/Plugin/format.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/format.pm b/IkiWiki/Plugin/format.pm
new file mode 100644
index 000000000..bbe3aa9fe
--- /dev/null
+++ b/IkiWiki/Plugin/format.pm
@@ -0,0 +1,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