We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
Tags:
create new tag
, view all tags

Question

Could anybody please explain the purpose that the $TranslationToken serves, which is wrapped around the words when links are created? In particular, I am puzzled why these are wrapped around the text corresponding to the links.

Note that these mess up the handler that is provided to call word rendering in plugins (TWiki::Plugins::renderWikiWordHandler), when internalLink is called from internalCrosswebLink.

Environment

TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories:  

-- ThomasWeigert - 08 Feb 2005

Answer

The $TranslationToken is inserted into text temporarily to defuse a regular expression search. Example:

        # "TopicName" to "Web.TopicName"
        $text =~ s/(^|[\s\(])($regex{webNameRegex}\.$regex{wikiWordRegex})/$1$TranslationToken$2/go;
        $text =~ s/(^|[\s\(])($regex{wikiWordRegex})/$1$theWeb\.$2/go;
        $text =~ s/(^|[\s\(])$TranslationToken/$1/go;

The first regex prefixes Web.TopicNames with a token so that the word is no longer prefixed by whitespace or parenthesis. The second regex looks for WikiWords. It won't find web names that happen to be!WikiWords such as WebName.TopicNames because of the prefixed token. The third regex removes the temporary token.

$TranslationToken should only be added temporarily and should not be passed into subroutines. File a BugReport if this is the case.

-- PeterThoeny - 10 Feb 2005

Peter, thanks. I definitely see that $TranslationToken is passed into subroutines. I will submit a BugReport.

But just to verify... I understand you as saying that there would be no harm done if I were to take the $TranslationToken out before entering the subroutine, without putting it back in afterwards?

-- ThomasWeigert - 10 Feb 2005

Not sure if it is OK to remove the token out of context. The code neeeds to be looked at.

-- PeterThoeny - 11 Feb 2005

Bug report filed as TranslationTokenPassedIntoSubroutines. I have also added a patch that solves the problem for me, but it appears rather awkward.

-- ThomasWeigert - 11 Feb 2005

 
Topic revision: r5 - 11 Feb 2005 - 13:32:51 - ThomasWeigert
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback