summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/textile.pm
blob: 56bb4bffce83bf9fa47b1ad731f46c8dc8d9f652 (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, longname => "Textile");
  12. }
  13. sub getsetup () {
  14. return
  15. plugin => {
  16. safe => 1,
  17. rebuild => 1, # format plugin
  18. section => "format",
  19. },
  20. }
  21. sub htmlize (@) {
  22. my %params=@_;
  23. my $content = decode_utf8(encode_utf8($params{content}));
  24. eval q{use Text::Textile};
  25. return $content if $@;
  26. return Text::Textile::textile($content);
  27. }
  28. 1