]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/mdwn.pm
toc: Add the table of contents at sanitize time, rather than at format time. This...
[git.ikiwiki.info.git] / IkiWiki / Plugin / mdwn.pm
index 1520b3eecc66d96eb7b0da44a441b01bc3fc5ad1..2ffe7bc3e6b8cc1656fcba3998cde0e81258fc55 100644 (file)
@@ -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" ||
@@ -41,8 +46,6 @@ sub htmlize (@) { #{{{
                require Encode;
        }
        
                require Encode;
        }
        
-       my $oneline = $content !~ /\n/;
-
        # Workaround for perl bug (#376329)
        $content=Encode::encode_utf8($content);
        eval {$content=&$markdown_sub($content)};
        # Workaround for perl bug (#376329)
        $content=Encode::encode_utf8($content);
        eval {$content=&$markdown_sub($content)};
@@ -52,13 +55,6 @@ sub htmlize (@) { #{{{
        }
        $content=Encode::decode_utf8($content);
 
        }
        $content=Encode::decode_utf8($content);
 
-       if ($oneline) {
-               # hack to get rid of enclosing junk added by markdown
-               $content=~s!^<p>!!;
-               $content=~s!</p>$!!;
-               chomp $content;
-       }
-
        return $content;
 } # }}}
 
        return $content;
 } # }}}