]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/mdwn.pm
* Run page through any relevant filters when generating a page preview.
[ikiwiki.git] / IkiWiki / Plugin / mdwn.pm
1 #!/usr/bin/perl
2 # Markdown markup language
3 package IkiWiki::Plugin::mdwn;
4
5 use warnings;
6 use strict;
7 use IkiWiki;
8
9 sub import { #{{{
10         IkiWiki::hook(type => "htmlize", id => "mdwn", call => \&htmlize);
11 } # }}}
12
13 sub htmlize ($) { #{{{
14         my $content = shift;
15
16         if (! $INC{"/usr/bin/markdown"}) {
17                 # Note: a proper perl module is available in Debian
18                 # for markdown, but not upstream yet.
19                 no warnings 'once';
20                 $blosxom::version="is a proper perl module too much to ask?";
21                 use warnings 'all';
22                 do "/usr/bin/markdown";
23                 require Encode;
24         }
25         
26         # Workaround for perl bug (#376329)
27         $content=Encode::encode_utf8($content);
28         $content=Encode::encode_utf8($content);
29         $content=Markdown::Markdown($content);
30         $content=Encode::decode_utf8($content);
31         $content=Encode::decode_utf8($content);
32
33         return $content;
34 } # }}}
35
36 1