# # TWiki WikiClone ($wikiversion has version info) # # Copyright (C) 2000-2001 Andrea Sterbini, a.sterbini@flashnet.it # Copyright (C) 2001 Peter Thoeny, Peter@Thoeny.com # # This program is free software; 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. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details, published at # http://www.gnu.org/copyleft/gpl.html # # ========================= # # # Each plugin is a package that contains the subs: # # initPlugin ( $topic, $web, $user, $installWeb ) # commonTagsHandler ( $text, $topic, $web ) # startRenderingHandler( $text, $web ) # outsidePREHandler ( $text ) # insidePREHandler ( $text ) # endRenderingHandler ( $text ) # # initPlugin is required, all other are optional. # For increased performance, all handlers except initPlugin are # disabled. To enable a handler remove the leading DISABLE_ from # the function name. # # ========================= package TWiki::Plugins::SpacedWikiWordPlugin; # ========================= use vars qw( $web $topic $user $installWeb $VERSION $debug $exampleCfgVar ); $VERSION = '1.000'; # ========================= sub initPlugin { ( $topic, $web, $user, $installWeb ) = @_; # check for Plugins.pm versions if( $TWiki::Plugins::VERSION < 1 ) { &TWiki::Func::writeWarning( "Version mismatch between SpacedWikiWordPlugin and Plugins.pm" ); return 0; } # Get plugin preferences, the variable defined by: #$exampleCfgVar = &TWiki::Prefs::getPreferencesValue( "SPACEDWIKIWORDPLUGIN" ) || "default"; # Get plugin debug flag $debug = &TWiki::Func::getPreferencesFlag( "SPACEDWIKIWORDPLUGIN_DEBUG" ); # Plugin correctly initialized &TWiki::Func::writeDebug( "- TWiki::Plugins::SpacedWikiWord::initPlugin( $web.$topic ) is OK" ) if $debug; return 1; } sub spacedWikiWord { my ( $word ) = @_; # traditional WikiWords: #$word =~ s/([a-z0-9])([A-Z])/$1 $2/g; #lower alphanum followed by upper #$word =~ s/([a-zA-Z])([0-9])/$1 $2/g; #letter followed by number # code added for underscore WikiWords: $word =~ s/\_/ /go; # replace underscore by space # remove spaces at the end of links $word =~ s/ $//; ## Remove trailing space characters return $word; } 1;