From: Joey Hess
Date: Wed, 9 Jan 2008 19:35:23 +0000 (-0500)
Subject: * mdwn: When htmlizing text, if it's a single line with no newline,
X-Git-Tag: 2.20~11
X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2b9ce0129bc61177e976caf432af9b4406ab2f3f;p=ikiwiki.git
* 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.
---
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!^
!!;
+ $content=~s!
$!!;
+ chomp $content;
+ }
+
return $content;
} # }}}
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index 42fddb0bb..d2c6e7f8b 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -46,18 +46,10 @@ sub scrub ($) { #{{{
sub htmlize ($$$) { #{{{
my $page = shift;
my $destpage = shift;
- my $text = shift;
- $text=IkiWiki::htmlize($page, pagetype($pagesources{$page}),
+ return IkiWiki::htmlize($page, pagetype($pagesources{$page}),
IkiWiki::linkify($page, $destpage,
- IkiWiki::preprocess($page, $destpage, $text)));
-
- # hack to get rid of enclosing junk added by markdown
- $text=~s!^