aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
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
parented30330ac23ca84235e09cfc2f0acd55d62e4a09 (diff)
downloadikiwiki-2b9ce0129bc61177e976caf432af9b4406ab2f3f.tar
ikiwiki-2b9ce0129bc61177e976caf432af9b4406ab2f3f.tar.gz
* 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')
-rw-r--r--IkiWiki/Plugin/mdwn.pm9
-rw-r--r--IkiWiki/Plugin/meta.pm14
-rw-r--r--IkiWiki/Plugin/table.pm12
3 files changed, 14 insertions, 21 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;
} # }}}
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!^<p>!!;
- $text=~s!</p>$!!;
- chomp $text;
-
- return $text;
+ IkiWiki::preprocess($page, $destpage, shift)));
}
sub preprocess (@) { #{{{
@@ -184,7 +176,7 @@ sub preprocess (@) { #{{{
}
elsif ($key eq 'link') {
if (%params) {
- $meta{$page}.=scrub("<link href=\"".encode_entities($value)."\" ".
+ push @{$meta{$page}}, scrub("<link href=\"".encode_entities($value)."\" ".
join(" ", map {
encode_entities($_)."=\"".encode_entities(decode_entities($params{$_}))."\""
} keys %params).
diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm
index ddc2f68be..20c71e1c7 100644
--- a/IkiWiki/Plugin/table.pm
+++ b/IkiWiki/Plugin/table.pm
@@ -174,17 +174,9 @@ sub genrow ($$$@) { #{{{
sub htmlize ($$$) { #{{{
my $page = shift;
my $destpage = shift;
- my $text = shift;
-
- $text=IkiWiki::htmlize($page, pagetype($pagesources{$page}),
- IkiWiki::preprocess($page, $destpage, $text));
-
- # hack to get rid of enclosing junk added by markdown
- $text=~s!^<p>!!;
- $text=~s!</p>$!!;
- chomp $text;
- return $text;
+ return IkiWiki::htmlize($page, pagetype($pagesources{$page}),
+ IkiWiki::preprocess($page, $destpage, shift));
}
1