[pmwiki-users] automatic page titles (aless)

aless alessors at gmail.com
Sat Aug 2 05:17:22 CDT 2008


I tried to adapt the third solution of the recipe Alternate Naming 
Scheme (http://www.pmwiki.org/wiki/Cookbook/AlternateNamingScheme) to 
get apostrophes in page titles as John suggested:

' => ~ for page names and URLS

~ => ' for page display

But every time I try to create a page that contains an apostrophe I get:

PmWiki can't process your request

?invalid page name

Any idea?

Here's the modified code:


/*  Copyright 2005 Mateusz Czaplinski (mateusz at czaplinski.pl)
     This file is spacedTitles.php; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published
     by the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
*/

if( $Charset=='UTF-8' ) {
   $PageNameChars='-~_[:alnum:]\\x80-\\xfe';
   $MakePageNamePatterns = array(
     "/'/" => '~',                          # ' => ~
     "/[^$PageNameChars]+/" => ' ',         # convert everything else to 
space
     "/(^\\s+)|(\\s+\$)/" => '',            # trim whitespaces
     "/^([a-z])/e" => "strtoupper('$1')",   # uppercase first letter
     "/^([\\xc0-\\xdf].)/e" => "utf8toupper('$1')",  # uppercase first 
letter
     "/ /" => '_');                         # convert spaces to undersc
} else {
   $PageNameChars = '-~_[:alnum:]';
   $MakePageNamePatterns = array(
     "/'/" => '~',                          # # ' => ~
     "/[^$PageNameChars]+/" => ' ',         # convert everything else to 
space
     "/(^\\s+)|(\\s+\$)/" => '',            # trim whitespaces
     "/^(\\w)/e" => "strtoupper('$1')",     # uppercase first letter
     "/ /" => '_'                           # convert spaces to underscores
   );
}

$AsSpacedFunction = 'AsSpacedUnderlines';
function AsSpacedUnderlines($text) {
if ( $text=='_' ) {
return strtr($text,'_',' ');
}

if ( $text=='~' ) {
return strtr($text,'~',''');   # ~ => ' single quote need to be escaped?
}

}
$SpaceWikiWords = 1;




More information about the pmwiki-users mailing list