summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/textile.pm
blob: b604aa3c52ab1d0fe34b686a4634920ac6310dc6 (plain)
  1. #!/usr/bin/perl
  2. # By mazirian; GPL license
  3. # Textile markup
  4. package IkiWiki::Plugin::textile;
  5. use warnings;
  6. use strict;
  7. use IkiWiki 3.00;
  8. use Encode;
  9. sub import {
  10. hook(type => "getsetup", id => "textile", call => \&getsetup);
  11. hook(type => "htmlize", id => "txtl", call => \&htmlize);
  12. }
  13. sub getsetup () {
  14. return
  15. plugin => {
  16. safe => 1,
  17. rebuild => 1, # format plugin
  18. },
  19. }
  20. sub htmlize (@) {
  21. my %params=@_;
  22. my $content = decode_utf8(encode_utf8($params{content}));
  23. eval q{use Text::Textile};
  24. return $content if $@;
  25. return Text::Textile::textile($content);
  26. }
  27. 1