I use my TWiki site (
http://www.mattwalsh.com
) in mostly read-only mode - I send people links to look at it and I do all the editing. As such, few of them understand the
CamelCase thing. So, I hacked my TWiki scripts a bit so that the Wiki word links have appropriate spaces in them. Visit my site to check it out.
A good example where this helps is something like
InterfacingCWithTCL vs.
Interfacing C With TCL. Anyway, to make this change you only have to make a couple changes.
Put this function in
TWiki.pm
sub unpackWikiName
{
my ( $name ) = @_;
return $name unless isWikiName($name);
if ( ! $name ) {
$name = "";
}
# Make BSFLeaders into BSF Leaders, but don't make
# InterfacingTCL into Interfacing TC L
$name =~ s!([A-Z\s]+)([A-Z][^A-Z\s]+)!$1 $2!g;
# make DogWalkers into Dog Walkers
$name =~ s!([a-z])([A-Z])!$1 $2!g;
# make Lotus123 into Lotus 123
$name =~ s!([A-Z])([^A-Z\s])!$1 $2!gi;
# Make 1999Corvette into 1999 Corvette
$name =~ s!([^A-Z\s])([A-Z])!$1 $2!gi;
return $name;
}
Then, also in
TWiki.pm in the function
internalLink() add the second line after the existing one as shown
$theLinkText =~ s/([\s\(])([A-Z]+[a-z]+[A-Z])/$1<nop>$2/go; # find this line...
$theLinkText = unpackWikiName($theLinkText); # ...then add this line after it
Voila! Sorry, I haven't created a patch, because my TWiki scripts are a lot like the Milenium Falcon...they've been hacked up but they suit me just perfectly. I've added image thumbnail creation, auto image galleries, and more.
You will notice that there is one notable excpetion this code does not handle well...
TWiki becomes
T Wiki. But I don't think there is a clean way around this; the code more or less assumes that words within
WikiWords start with a capital and then have lower-case, or are all caps. This is logical and normal for the way words are spelled. I could (gasp) special-case the word 'TWiki' - I mean, how many other words have multiple initial capital letters? At least for my site, the tradeoff for readability is well worth it.
And I'm sure you regexp gurus can show me a more efficient way....
--
MattWalsh - 28 Feb 2004
Nice site Matt. I think thats the first variation of the default twiki skin that I actually
like. Amazing how much difference well-matched colours can make. As for a more efficient method, I don't have the knowledge to help but plundering the code of the
SpacedWikiWordPlugin and
SpacedWikiWordPluginNextGen plugins might do.
--
MattWilkie - 28 Feb 2004
Thanks Matt. Your code has been successfully plundered into the new version of
SpacedWikiWordPlugin
You will note that I did not change the Regexs but that a couple of them failed. You can feel free to fix them in the plugin.
--
MartinCleaver - 12 Apr 2004