create new tag
, view all tags


see for a working example.

The basic idea is to create a plugin or other customization that would cause every word written in a topic to become a link.

  • Usage I want to implement this as a sort of encyclopedia website not unlike wikipedia but with the following differences.
    • Twiki would be used as the platform for it
    • Every word used to define a Encyclopedia entry would become a link to that words definition. Essentially, recursively definitive.
    • All variations of All words would "auto-link" in the same way CamelCase does with current variation.

Here is an example entry with the [partial] definition taken from Webster's Revised Unabridged Dictionary (1913) [web1913]

Of course the "?"'s would have to be disabled for these "dead links" but that raises the point that the words themselves would have to become clickable instead. If both deadlinks and live links are clickable we will have to come up with another way to distinguish the two. Considering the goal is to eventually populate this EncycloTWiki to the point that every word becomes a live link ( a daunting task I know) It may be desirable to have links set to "underline" onmouseover only (or on hover) [which ever], in which case i propose we cause live links to be underlined in a blue font color (standard) and deadlinks to be underlined with a red font color.

  • I have looked at the lib/TWiki.pm file specifically line 470. I think that It may be possible to modify this line to get the desired effect discussed above, but my Regex knowledge is nill at best.
    • Line 470: $wikiWordRegex = qr/[$upperAlpha]+[$lowerAlpha]+[$upperAlpha]+[$mixedAlphaNum]*/;

  • from TWiki.pm lines 445-494:

    # Build up character class components for use in regexes.
    # Depends on locale mode and Perl version, and finally on
    # whether locale-based regexes are turned off.
    if ( not $useLocale or $] < 5.006 or not $localeRegexes ) {
   # No locales needed/working, or Perl 5.005_03 or lower, so just use
   # any additional national characters defined in TWiki.cfg
   $upperAlpha = "A-Z$upperNational";
   $lowerAlpha = "a-z$lowerNational";
   $numeric = '\d';
   $mixedAlpha = "${upperAlpha}${lowerAlpha}";
    } else {
   # Perl 5.6 or higher with working locales
   $upperAlpha = "[:upper:]";
   $lowerAlpha = "[:lower:]";
   $numeric = "[:digit:]";
   $mixedAlpha = "[:alpha:]";
    $mixedAlphaNum = "${mixedAlpha}${numeric}";
    $lowerAlphaNum = "${lowerAlpha}${numeric}";

    # Compile regexes for efficiency and ease of use
    # Note: qr// locks in regex modes (i.e. '-xism' here) - see Friedl
    # book at http://regex.info/.

    # TWiki concept regexes
    $wikiWordRegex = qr/[$upperAlpha]+[$lowerAlpha]+[$upperAlpha]+[$mixedAlphaNum]*/;
    $webNameRegex = qr/[$upperAlpha]+[$lowerAlphaNum]*/;
    $defaultWebNameRegex = qr/_[${mixedAlphaNum}_]+/;
    $anchorRegex = qr/\#[${mixedAlphaNum}_]+/;
    $abbrevRegex = qr/[$upperAlpha]{3,}/;

    # Simplistic email regex, e.g. for WebNotify processing - no i18n
    # characters allowed
    $emailAddrRegex = qr/([A-Za-z0-9\.\+\-\_]+\@[A-Za-z0-9\.\-]+)/;

    # Single-character alpha-based regexes
    $singleUpperAlphaRegex = qr/[$upperAlpha]/;
    $singleLowerAlphaRegex = qr/[$lowerAlpha]/;
    $singleUpperAlphaNumRegex = qr/[${upperAlpha}${numeric}]/;
    $singleMixedAlphaNumRegex = qr/[${upperAlpha}${lowerAlpha}${numeric}]/;

    $singleMixedNonAlphaRegex = qr/[^${upperAlpha}${lowerAlpha}]/;
    $singleMixedNonAlphaNumRegex = qr/[^${upperAlpha}${lowerAlpha}${numeric}]/;

    # Multi-character alpha-based regexes
    $mixedAlphaNumRegex = qr/[${mixedAlphaNum}]*/;


# =========================

trial and error working with the Regex of line 470 I noticed that if I remove parts of it such as the two [$upperAlpha] segments, suddenly text suddenly become eligible to become Wiki links. This causes the page to be rendered incorrectly due to "

<a href="foo">
becomes href? and breakes the html.

I found that "qr/[$upperAlpha]+[$lowerAlpha]+[$upperAlpha]+[$mixedAlphaNum]*/;" only works because that combination usually never occures in html (ie:html usually never looks like CamelCase)

The solution for this could be to tell Regex to exclude working its magic on the stuff we dont want to be linked ie: things already linked up in certain html tags.

-- TravisBarker - 14 Nov 2003

To make your text easier to read, you may consider CSS to abandon link altogether, and use background color only - possible different for existing and non-existing pages. And how would you join two words together to link to a concept which name are two words?

-- PeterMasiar - 14 Nov 2003

to answer the question about how you would join words together to link to a concept which name are two words, consider WikiWords would still work just as they always did, because the new parser would simply see them as a single word

For a working example of what we are talking about here see altho it is a MoinMoin Wiki using a custom "GaGaParser" and some custom CSS work to make the links look better. If something like this Moin solution could be implemented in TWiki it would be combining the best of both worlds. too bad for us moin is in python.

-- TravisBarker - 21 Nov 2003

Though I'm not sure why it is called this, what you are implementing is a GaGaParser.

-- TomKagan - 14 Nov 2003

at first glance i thought GaGaParser was not what i wanted, but upon actually looking at it, i was dead wrong wink GaGaParser appears to be exactly what i was looking for TomKagan thanks allot for the tip here. You saved me from reinvinting the wheel. It maybe it could use a Name Change to something that is a bit more descriptive but im not complaining ;). Its just too bad its a MoinMoin Wiki solution rather than a TWiki Plugin.

-- TravisBarker - 14 Nov 2003

This is a bit like http://relevanta.com/ 's AutoContextualisatoin.

-- MartinCleaver - 10 Jan 2005

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2005-01-10 - MartinCleaver
  • 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.