]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/mdwn.pm
* mdwn: When htmlizing text, if it's a single line with no newline,
[ikiwiki.git] / IkiWiki / Plugin / mdwn.pm
index 254ab51d03b078afbbeed1727fdb56b18a6c1a1c..1520b3eecc66d96eb7b0da44a441b01bc3fc5ad1 100644 (file)
@@ -41,6 +41,8 @@ sub htmlize (@) { #{{{
                require Encode;
        }
        
+       my $oneline = $content !~ /\n/;
+
        # Workaround for perl bug (#376329)
        $content=Encode::encode_utf8($content);
        eval {$content=&$markdown_sub($content)};
@@ -50,6 +52,13 @@ sub htmlize (@) { #{{{
        }
        $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;
 } # }}}