summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/mdwn.pm
blob: a344de0674a8345bffd91a61c4cd0b44ee38994a (plain)
  1. #!/usr/bin/perl
  2. # Markdown markup language
  3. package IkiWiki::Plugin::mdwn;
  4. use warnings;
  5. use strict;
  6. use IkiWiki;
  7. sub import { #{{{
  8. IkiWiki::hook(type => "htmlize", id => "mdwn", call => \&htmlize);
  9. } # }}}
  10. sub htmlize ($) { #{{{
  11. my $content = shift;
  12. if (! $INC{"/usr/bin/markdown"}) {
  13. # Note: a proper perl module is available in Debian
  14. # for markdown, but not upstream yet.
  15. no warnings 'once';
  16. $blosxom::version="is a proper perl module too much to ask?";
  17. use warnings 'all';
  18. do "/usr/bin/markdown";
  19. require Encode;
  20. }
  21. # Workaround for perl bug (#376329)
  22. $content=Encode::encode_utf8($content);
  23. $content=Encode::encode_utf8($content);
  24. $content=Markdown::Markdown($content);
  25. $content=Encode::decode_utf8($content);
  26. $content=Encode::decode_utf8($content);
  27. return $content;
  28. } # }}}
  29. 1