From 2b9ce0129bc61177e976caf432af9b4406ab2f3f Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Wed, 9 Jan 2008 14:35:23 -0500
Subject: [PATCH] * 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.
---
IkiWiki/Plugin/mdwn.pm | 9 +++++++++
IkiWiki/Plugin/meta.pm | 14 +++-----------
IkiWiki/Plugin/table.pm | 12 ++----------
debian/changelog | 4 ++++
po/ikiwiki.pot | 8 ++++----
5 files changed, 22 insertions(+), 25 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!^!!;
+ $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!^!!;
- $text=~s!
$!!;
- 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("!!;
- $text=~s!
$!!;
- chomp $text;
- return $text;
+ return IkiWiki::htmlize($page, pagetype($pagesources{$page}),
+ IkiWiki::preprocess($page, $destpage, shift));
}
1
diff --git a/debian/changelog b/debian/changelog
index 3bebe7f25..ee2ecc4d5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,10 @@ ikiwiki (2.20) UNRELEASED; urgency=low
* template: Remove bogus htmlize pass added in 2.16.
* template: Htmlize template variables, but also provide a raw version
via ``.
+ * 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.
-- Joey Hess Wed, 09 Jan 2008 00:34:46 -0500
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index 2af29ad46..73fd91b85 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-01-09 14:04-0500\n"
+"POT-Creation-Date: 2008-01-09 14:31-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -240,15 +240,15 @@ msgstr ""
msgid "failed to load Markdown.pm perl module (%s) or /usr/bin/markdown (%s)"
msgstr ""
-#: ../IkiWiki/Plugin/meta.pm:132
+#: ../IkiWiki/Plugin/meta.pm:124
msgid "stylesheet not found"
msgstr ""
-#: ../IkiWiki/Plugin/meta.pm:156
+#: ../IkiWiki/Plugin/meta.pm:148
msgid "redir page not found"
msgstr ""
-#: ../IkiWiki/Plugin/meta.pm:169
+#: ../IkiWiki/Plugin/meta.pm:161
msgid "redir cycle is not allowed"
msgstr ""
--
2.39.5