2 # Markdown markup language
3 package IkiWiki::Plugin::mdwn;
10 hook(type => "getsetup", id => "mdwn", call => \&getsetup);
11 hook(type => "htmlize", id => "mdwn", call => \&htmlize, longname => "Markdown");
18 rebuild => 1, # format plugin
23 description => "enable multimarkdown features?",
32 my $content = $params{content};
34 if (! defined $markdown_sub) {
35 # Markdown is forked and splintered upstream and can be
36 # available in a variety of forms. Support them all.
38 $blosxom::version="is a proper perl module too much to ask?";
41 if (exists $config{multimarkdown} && $config{multimarkdown}) {
42 eval q{use Text::MultiMarkdown};
44 debug(gettext("multimarkdown is enabled, but Text::MultiMarkdown is not installed"));
48 Text::MultiMarkdown::markdown(shift, {use_metadata => 0});
52 if (! defined $markdown_sub) {
53 eval q{use Text::Markdown};
55 if (Text::Markdown->can('markdown')) {
56 $markdown_sub=\&Text::Markdown::markdown;
59 $markdown_sub=\&Text::Markdown::Markdown;
65 $markdown_sub=\&Markdown::Markdown;
68 do "/usr/bin/markdown" ||
69 error(sprintf(gettext("failed to load Markdown.pm perl module (%s) or /usr/bin/markdown (%s)"), $@, $!));
70 $markdown_sub=\&Markdown::Markdown;
78 # Workaround for perl bug (#376329)
79 $content=Encode::encode_utf8($content);
80 eval {$content=&$markdown_sub($content)};
82 eval {$content=&$markdown_sub($content)};
83 print STDERR $@ if $@;
85 $content=Encode::decode_utf8($content);