[pmwiki-users] Page names with spaces (Was: case-insensitive file names

Patrick R. Michaud pmichaud at pobox.com
Thu Sep 29 14:35:59 CDT 2005


On Thu, Sep 29, 2005 at 06:42:35PM +0200, chr at home.se wrote:
> On Thu, 29 Sep 2005, Patrick R. Michaud wrote:
> 
> >     Main.Abc               "_Main._Abc"
> >     Main.ABC               "_Main._A_B_C"
> >     Long.PageName          "_Long._Page_Name"
> >     Long.Pagename          "_Long._Pagename"
> >     LongGroup.LongerName   "_Long_Group._Longer_Name"
> 
> Looking at all the underscores, do you know of a cookbook recipe that 
> let's you have page names with spaces in them?

There's http://www.pmwiki.org/wiki/Cookbook/AlternateNamingScheme,
which takes a slightly different approach to the problem than how
I'd do it now (mainly because it's based on an older devel or 
beta release).

In current releases one can modify the $MakePageNamePatterns 
array to customize the way that strings are converted into
pagenames.  Currently the default sequence is:

    "/'/" => '',                           # strip single-quotes
    "/[^$PageNameChars]+/" => ' ',         # convert non-alnums to spaces
    "/((^|[^-\\w])\\w)/e" 
      => "strtoupper('$1')",               # initial caps after spaces
    "/ /" => ''                            # strip spaces

We can set the sequence so that the last rule instead reads:

    "/\\s+/" => '_'                        # Convert spaces to underscores

Thus, [[Documentation index]] becomes "Documentation_Index".

Similarly, the strtoupper rule can be omitted, which eliminates
the automatic up-casing of letters, thus [[Documentation index]] 
becomes "Documentation_index".  If the wiki can then do a 
case-insensitive searches for the corresponding page file, 
it'll work out fine.

There are probably a few other patterns that need adjusting
here and there, but this the core of getting underscores to
work.

Pm




More information about the pmwiki-users mailing list