summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/format.pm
blob: bbe3aa9fee56e28b978e8d11c0f5f71d6d1b8824 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::format;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 3.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