]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/mdwn.pm
Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[git.ikiwiki.info.git] / IkiWiki / Plugin / mdwn.pm
index c087f2b41309f892e52476305bf31ccc48fb7840..2ffe7bc3e6b8cc1656fcba3998cde0e81258fc55 100644 (file)
@@ -4,7 +4,7 @@ package IkiWiki::Plugin::mdwn;
 
 use warnings;
 use strict;
 
 use warnings;
 use strict;
-use IkiWiki;
+use IkiWiki 2.00;
 
 sub import { #{{{
        hook(type => "htmlize", id => "mdwn", call => \&htmlize);
 
 sub import { #{{{
        hook(type => "htmlize", id => "mdwn", call => \&htmlize);
@@ -30,7 +30,12 @@ sub htmlize (@) { #{{{
                else {
                        eval q{use Text::Markdown};
                        if (! $@) {
                else {
                        eval q{use Text::Markdown};
                        if (! $@) {
-                               $markdown_sub=\&Text::Markdown::Markdown;
+                               if (Text::Markdown->can('markdown')) {
+                                       $markdown_sub=\&Text::Markdown::markdown;
+                               }
+                               else {
+                                       $markdown_sub=\&Text::Markdown::Markdown;
+                               }
                        }
                        else {
                                do "/usr/bin/markdown" ||
                        }
                        else {
                                do "/usr/bin/markdown" ||
@@ -43,9 +48,11 @@ sub htmlize (@) { #{{{
        
        # Workaround for perl bug (#376329)
        $content=Encode::encode_utf8($content);
        
        # Workaround for perl bug (#376329)
        $content=Encode::encode_utf8($content);
-       $content=Encode::encode_utf8($content);
-       $content=&$markdown_sub($content);
-       $content=Encode::decode_utf8($content);
+       eval {$content=&$markdown_sub($content)};
+       if ($@) {
+               eval {$content=&$markdown_sub($content)};
+               print STDERR $@ if $@;
+       }
        $content=Encode::decode_utf8($content);
 
        return $content;
        $content=Encode::decode_utf8($content);
 
        return $content;