summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/mdwn.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-09 14:35:23 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-09 14:35:23 -0500
commit2b9ce0129bc61177e976caf432af9b4406ab2f3f (patch)
tree74be3d536540070af41385e8b108c651073af52d /IkiWiki/Plugin/mdwn.pm
parented30330ac23ca84235e09cfc2f0acd55d62e4a09 (diff)
* mdwn: When htmlizing text, if it's a single line with no newline,
remove the enclosing paragraph and newline markdown wraps it in. This allows removing several hacks around this markdown behavior from other plugins that htmlize fragements of pages.
Diffstat (limited to 'IkiWiki/Plugin/mdwn.pm')
-rw-r--r--IkiWiki/Plugin/mdwn.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm
index 254ab51d0..1520b3eec 100644
--- a/IkiWiki/Plugin/mdwn.pm
+++ b/IkiWiki/Plugin/mdwn.pm
@@ -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;
} # }}}