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

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2005-02-11 - ThomasWeigert
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.