[pmwiki-devel] Formatting page names
Petko Yotov
5ko at 5ko.fr
Mon Apr 1 13:59:46 PDT 2024
$MakePageNamePatterns has rules calculating the page name Group.PageName
from a string like "page name". It seems you need a way to "space" page
names like in {PageName$Namespaced} or in {(asspaced text)}, that's the
opposite.
Spacing is done by the function AsSpacedUTF8($text) which converts a
string with WikiWords into a spaced version of that string. It can be
overridden via $AsSpacedFunction:
$AsSpacedFunction = 'SimonAsSpaced';
function SimonAsSpaced($text) {
$text = AsSpacedUTF8($text);
$text = preg_replace('/([A-Z])\\s+(\\d)/', '$1$2', $text);
return $text;
}
Here, instead of rewriting the whole AsSpacedUTF8() function, we call
it, then undo the damage it did to our text.
With this, "{E1Freeway$Namespaced}" will print "E1 Freeway".
Alternatively, you can copy the full AsSpacedUTF8() function to
config.php under a different name, adapt it, and set the
$AsSpacedFunction variable to the new name.
Petko
On 01/04/2024 22:23, Simon wrote:
> I've had a look through the documentation and discovered
> $MakePageNamePatterns,
>
> What I want to do is exclude certain patterns from being space
> separated.
>
> Specifically a Capital letter followed by a digit.
>
> e.g. " E1 " is displayed as " E 1 "
>
> Is there a way to configure this?
>
> thanks in advance
>
> Simon
More information about the pmwiki-devel
mailing list