]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Allow for underscores to appear in page titles, if encoded appropriately
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 2 Mar 2007 00:37:22 +0000 (00:37 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 2 Mar 2007 00:37:22 +0000 (00:37 +0000)
  (__95__) in filenames. Previously, all underscores were replaced with
  spaces. Thanks, Enrico Zini for noticing that bug.

IkiWiki.pm
debian/changelog
t/pagetitle.t
t/titlepage.t

index dcb68bca6d525578fee12e7bdd25d5f92c1e51ef..62b54373bfb6195e64717bd9d613d184621fbbab 100644 (file)
@@ -365,20 +365,18 @@ sub pagetitle ($;$) { #{{{
        my $unescaped=shift;
 
        if ($unescaped) {
        my $unescaped=shift;
 
        if ($unescaped) {
-               $page=~s/__(\d+)__/chr($1)/eg;
+               $page=~s/(__(\d+)__|_)/$1 eq '_' ? ' ' : chr($2)/eg;
        }
        else {
        }
        else {
-               $page=~s/__(\d+)__/&#$1;/g;
+               $page=~s/(__(\d+)__|_)/$1 eq '_' ? ' ' : "&#$2;"/eg;
        }
        }
-       $page=~y/_/ /;
 
        return $page;
 } #}}}
 
 sub titlepage ($) { #{{{
        my $title=shift;
 
        return $page;
 } #}}}
 
 sub titlepage ($) { #{{{
        my $title=shift;
-       $title=~y/ /_/;
-       $title=~s/([^-[:alnum:]_:+\/.])/"__".ord($1)."__"/eg;
+       $title=~s/([^-[:alnum:]:+\/.])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
        return $title;
 } #}}}
 
        return $title;
 } #}}}
 
index aa3f167fc5930e89fbd35eefae790b86c0df43f8..77333b0ec04d7d223aa2aeedfb3df9bd000cc2a5 100644 (file)
@@ -1,3 +1,11 @@
+ikiwiki (1.45) UNRELEASED; urgency=low
+
+  * Allow for underscores to appear in page titles, if encoded appropriately
+    (__95__) in filenames. Previously, all underscores were replaced with
+    spaces. Thanks, Enrico Zini for noticing that bug.
+
+ -- Joey Hess <joeyh@debian.org>  Thu,  1 Mar 2007 19:30:36 -0500
+
 ikiwiki (1.44) unstable; urgency=low
 
   * Patch by Ben to fix validaton of atom feeds by fixing the category tags.
 ikiwiki (1.44) unstable; urgency=low
 
   * Patch by Ben to fix validaton of atom feeds by fixing the category tags.
index 1bb4421e4457b870ffd5d7e34c56b9faca085311..37adba144f33b26d31bbfc84ad313c998d8ecf8e 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 6;
+use Test::More tests => 7;
 
 BEGIN { use_ok("IkiWiki"); }
 
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -10,3 +10,4 @@ is(IkiWiki::pagetitle("foo_bar_baz"), "foo bar baz");
 is(IkiWiki::pagetitle("foo_bar__33__baz"), "foo bar&#33;baz");
 is(IkiWiki::pagetitle("foo_bar__1234__baz"), "foo bar&#1234;baz");
 is(IkiWiki::pagetitle("foo_bar___33___baz"), "foo bar &#33; baz");
 is(IkiWiki::pagetitle("foo_bar__33__baz"), "foo bar&#33;baz");
 is(IkiWiki::pagetitle("foo_bar__1234__baz"), "foo bar&#1234;baz");
 is(IkiWiki::pagetitle("foo_bar___33___baz"), "foo bar &#33; baz");
+is(IkiWiki::pagetitle("foo_bar___95___baz"), "foo bar &#95; baz");
index 6e1856a15763edd41328d0b3d72386d0d203b567..cc56db70c089caccb850b6760960627a3cd1c27a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 6;
+use Test::More tests => 7;
 
 BEGIN { use_ok("IkiWiki"); }
 
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -10,3 +10,4 @@ is(IkiWiki::titlepage("foo bar baz"), "foo_bar_baz");
 is(IkiWiki::titlepage("foo bar/baz"), "foo_bar/baz");
 is(IkiWiki::titlepage("foo bar&baz"), "foo_bar__38__baz");
 is(IkiWiki::titlepage("foo bar & baz"), "foo_bar___38___baz");
 is(IkiWiki::titlepage("foo bar/baz"), "foo_bar/baz");
 is(IkiWiki::titlepage("foo bar&baz"), "foo_bar__38__baz");
 is(IkiWiki::titlepage("foo bar & baz"), "foo_bar___38___baz");
+is(IkiWiki::titlepage("foo bar_baz"), "foo_bar__95__baz");