2 # Markdown markup language
3 package IkiWiki::Plugin::mdwn;
10 hook(type => "htmlize", id => "mdwn", call => \&htmlize);
14 sub htmlize (@) { #{{{
16 my $content = $params{content};
18 if (! defined $markdown_sub) {
19 # Markdown is forked and splintered upstream and can be
20 # available in a variety of incompatible forms. Support
23 $blosxom::version="is a proper perl module too much to ask?";
28 $markdown_sub=\&Markdown::Markdown;
31 eval q{use Text::Markdown};
33 if (Text::Markdown->can('markdown')) {
34 $markdown_sub=\&Text::Markdown::markdown;
37 $markdown_sub=\&Text::Markdown::Markdown;
41 do "/usr/bin/markdown" ||
42 error(sprintf(gettext("failed to load Markdown.pm perl module (%s) or /usr/bin/markdown (%s)"), $@, $!));
43 $markdown_sub=\&Markdown::Markdown;
49 # Workaround for perl bug (#376329)
50 $content=Encode::encode_utf8($content);
51 eval {$content=&$markdown_sub($content)};
53 eval {$content=&$markdown_sub($content)};
54 print STDERR $@ if $@;
56 $content=Encode::decode_utf8($content);