This plugin will enable link_like_this to become linked to page Link_link_this and displayed as link like this for easy copying and pasting into other media, e.g. email or
StarOffice documents.
The topic is stores as it is written in the raw text, i.e. stored_like_this. Rename is the tricky part. My first attempt was to store topics as traditional
WikiWords, but in becomes very complex to track which pages to changes references on upon a rename, since character case could be anything for every character. I suppose it's doable by brote force, but it doesn't conform to KISS.
Some notes on the implementation below. This is work in progress. Please assist if you see things I don't.
Unfortunately, some things have to be done in TWiki.pm. In internalLinks after this:
if( &TWiki::Store::topicExists( $theWeb, $tmp ) ) {
$theTopic = $tmp;
$exist = 1;
}
}
add this:
# test for underscore topics regardless of case (StefanLindmark - 4 Feb 2002)
if( ( ! $exist ) ) {
my $tmp = $theTopic;
$tmp =~ s/_(.)/_\l$1/g ; # lowercase every char following a _
$tmp =~ s/^(.)/\u$1/g ; # ...and uppercase the very first char
if( &TWiki::Store::topicExists( $theWeb, $tmp ) ) {
$theTopic = $tmp;
$exist = 1;
}
}
This is from
UnderscoreLinksPlugin.pm :
# =========================
sub startRenderingHandler
{
### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead
# &TWiki::Func::writeDebug( "- UnderscoreLinksPlugin::startRenderingHandler( $_[1].$topic )" ) if $debug;
# &TWiki::Func::writeDebug( "- UnderscoreLinksPlugin::startRenderingHandler( $_[0] )" ) if $debug;
# This handler is called by getRenderedVersion just before the line loop
$_[0] =~ s/(^|[\s\(\)!\?\.])([A-Z拍周a-z邃鳇][A-Z拍周a-z邃鳇]*_+[A-Z拍周a-z邃鳇A-Z拍周0-9_]*[A-Z拍周a-z邃鳇A-Z拍周0-9])([\s\(\)!\?\.])/
$1."[[".$2."][".underscoreToSpace($2)."]]".$3/geo;
# $1."[[".underscoreToWiki($2)."][".underscoreToSpace($2)."]]".$3/geo; # This was the old one where files would be LikeThis from a topic like_this
&TWiki::Func::writeDebug( "- UnderscoreLinksPlugin::startRenderingHandler( $_[0] )" ) if $debug;
}
# This sub turns "the_topic_name" into "the topic name" for display
sub underscoreToSpace
{
my ( $text ) = @_;
$text =~ s/_/ /g;
# &TWiki::Func::writeDebug( "- UnderscoreLinksPlugin:underscoreToSpace( $_[0] spaced to $text )" ) if $debug;
return $text;
}
--
StefanLindmark - 02 Feb 2002
Discussion below here, please