Tags:
create new tag
, view all tags

Disable WikiWord Links with noautolink Tag

In Support.DisablingWikiWords the question was raised if it is possible to prevent WikiWord links globally, e.g. to depend only on the [[...][...]] link syntax. Wikipedia did that switch after some time of use.

TWiki has now a NOAUTOLINK preferences setting in the TWikiPreferences where you can disable the auto links.

Is in TWikiAlphaRelease and at TWiki.org.

Patch:

*** ../../TWiki.pm      Mon Dec 30 23:46:02 2002
--- TWiki.pm    Tue Dec 31 13:46:05 2002
***************
*** 76,82 ****
  use vars qw(
        @isoMonth @weekDay
        $TranslationToken %mon2num $isList @listTypes @listElements
!         $newTopicFontColor $newTopicBgColor $linkProtocolPattern
          $headerPatternDa $headerPatternSp $headerPatternHt $headerPatternNoTOC
          $debugUserTime $debugSystemTime
          $viewableAttachmentCount $noviewableAttachmentCount
--- 76,82 ----
  use vars qw(
        @isoMonth @weekDay
        $TranslationToken %mon2num $isList @listTypes @listElements
!         $newTopicFontColor $newTopicBgColor $noAutoLink $linkProtocolPattern
          $headerPatternDa $headerPatternSp $headerPatternHt $headerPatternNoTOC
          $debugUserTime $debugSystemTime
          $viewableAttachmentCount $noviewableAttachmentCount
***************
*** 173,178 ****
--- 173,179 ----
  # initialize not called.
  $cgiQuery = 0;
  @publicWebList = ();
+ $noAutoLink = 0;
  $viewScript = "view";

  $linkProtocolPattern = "(http|ftp|gopher|news|file|https|telnet)";
***************
*** 368,377 ****

      # Add background color and font color (AlWilliams - 18 Sep 2000)
      # PTh: Moved from internalLink to initialize ('cause of performance)
!     $newTopicBgColor = &TWiki::Prefs::getPreferencesValue("NEWTOPICBGCOLOR");
!     if ($newTopicBgColor eq "") { $newTopicBgColor="#FFFFCE"; }
!     $newTopicFontColor = &TWiki::Prefs::getPreferencesValue("NEWTOPICFONTCOLOR");
!     if ($newTopicFontColor eq "") { $newTopicFontColor="#0000FF"; }

  #AS
      if( !$disableAllPlugins ) {
--- 369,378 ----

      # Add background color and font color (AlWilliams - 18 Sep 2000)
      # PTh: Moved from internalLink to initialize ('cause of performance)
!     $newTopicBgColor   = TWiki::Prefs::getPreferencesValue("NEWTOPICBGCOLOR")   || "#FFFFCE";
!     $newTopicFontColor = TWiki::Prefs::getPreferencesValue("NEWTOPICFONTCOLOR") || "#0000FF";
!     # Prevent autolink of WikiWords
!     $noAutoLink        = TWiki::Prefs::getPreferencesValue("NOAUTOLINK") || 0;

  #AS
      if( !$disableAllPlugins ) {
***************
*** 2488,2494 ****
  # =========================
  sub getRenderedVersion {
      my( $text, $theWeb, $meta ) = @_;
!     my( $head, $result, $extraLines, $insidePRE, $insideTABLE, $noAutoLink );

      return "" unless $text;  # nothing to do

--- 2489,2495 ----
  # =========================
  sub getRenderedVersion {
      my( $text, $theWeb, $meta ) = @_;
!     my( $head, $result, $extraLines, $insidePRE, $insideTABLE, $insideNoAutoLink );

      return "" unless $text;  # nothing to do

***************
*** 2505,2511 ****
      $result = "";
      $insidePRE = 0;
      $insideTABLE = 0;
!     $noAutoLink = 0;      # PTh 02 Feb 2001: Added Codev.DisableWikiWordLinks
      $isList = 0;
      @listTypes = ();
      @listElements = ();
--- 2506,2512 ----
      $result = "";
      $insidePRE = 0;
      $insideTABLE = 0;
!     $insideNoAutoLink = 0;      # PTh 02 Feb 2001: Added Codev.DisableWikiWordLinks
      $isList = 0;
      @listTypes = ();
      @listElements = ();
***************
*** 2536,2543 ****
          # change state:
          m|<pre>|i  && ( $insidePRE = 1 );
          m|</pre>|i && ( $insidePRE = 0 );
!         m|<noautolink>|i   && ( $noAutoLink = 1 );
!         m|</noautolink>|i  && ( $noAutoLink = 0 );

          if( $insidePRE ) {
              # inside <PRE>
--- 2537,2544 ----
          # change state:
          m|<pre>|i  && ( $insidePRE = 1 );
          m|</pre>|i && ( $insidePRE = 0 );
!         m|<noautolink>|i   && ( $insideNoAutoLink = 1 );
!         m|</noautolink>|i  && ( $insideNoAutoLink = 0 );

          if( $insidePRE ) {
              # inside <PRE>
***************
*** 2667,2674 ****
              # '[[Web.odd wiki word#anchor]]' link:
              s/\[\[([^\]]+)\]\]/&specificLink("",$theWeb,$theTopic,$1,$1)/ge;

!             # do normal WikiWord link if not disabled by <noautolink>
!             if( ! ( $noAutoLink ) ) {


                  # 'Web.TopicName#anchor' link:
                  s/([\s\(])($webNameRegex)\.($wikiWordRegex)($anchorRegex)/&internalLink($1,$2,$3,"$TranslationToken$3$4$TranslationToken",$4,1)/geo;
--- 2668,2675 ----
              # '[[Web.odd wiki word#anchor]]' link:
              s/\[\[([^\]]+)\]\]/&specificLink("",$theWeb,$theTopic,$1,$1)/ge;

!             # do normal WikiWord link if not disabled by <noautolink> or NOAUTOLINK preferences variable
!             unless( $noAutoLink || $insideNoAutoLink ) {

                  # 'Web.TopicName#anchor' link:
                  s/([\s\(])($webNameRegex)\.($wikiWordRegex)($anchorRegex)/&internalLink($1,$2,$3,"$TranslationToken$3$4$TranslationToken",$4,1)/geo;

-- PeterThoeny - 31 Dec 2002

Sweet! Thanks, Peter.

-- AdamTheo - 01 Jan 2003

This is an overkill. I think it's better to keep existing WikiWord links but remove the question mark following the nonexistent ones.

-- FengZhaolin - 17 Feb 2009

Funny you mention this Feng, we just discussed this in today's release meeting, GeorgetownReleaseMeeting2009x02x16. We plan to RemoveQuestionMarkLinks in the upcoming TWiki 4.3 release. To get involved with the community I suggest you participate in our biweekly release meetings, listed at GeorgetownRelease.

-- PeterThoeny - 17 Feb 2009

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2009-02-17 - PeterThoeny
 
  • 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.