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