summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/format.pm
blob: a219190e820a4f579a389c223a536a371e357ef7 (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, $text);
  22. } #}}}
  23. 1