]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* mdwn: When htmlizing text, if it's a single line with no newline,
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 9 Jan 2008 19:35:23 +0000 (14:35 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 9 Jan 2008 19:35:23 +0000 (14:35 -0500)
  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
IkiWiki/Plugin/meta.pm
IkiWiki/Plugin/table.pm
debian/changelog
po/ikiwiki.pot

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;
 } # }}}
 
index 42fddb0bb695855ecbedec0001f8d395e4d66957..d2c6e7f8bfa404739498940050bda916b54d3209 100644 (file)
@@ -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).
index ddc2f68be0940e1336cf11561d08ebeee5cbcb84..20c71e1c72c23272275d7b1ab219d2fa9a5ab228 100644 (file)
@@ -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
index 3bebe7f25c207784012d4b4858cd410c9977b5b1..ee2ecc4d5cb41e6932853a075b7361f3462d8aae 100644 (file)
@@ -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 `<TMPL_VAR raw_variable>`.
+  * 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 <joeyh@debian.org>  Wed, 09 Jan 2008 00:34:46 -0500
 
index 2af29ad467fca1063a44b5a631bb83ed2802638b..73fd91b851289f1a1ff2580b9e884e91b5d54a31 100644 (file)
@@ -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 <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\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 ""