Re: Fantasy: TiddlyWiki weaves itself

40 views
Skip to first unread message

Elise Springer

unread,
Feb 7, 2006, 12:37:29 AM2/7/06
to Tiddl...@googlegroups.com, Elise Springer
Gee, my "fantasy" post about a self-weaving TW just never attracted any notice :^|  Well, I've trudged on, and stumbled across a way to make it ALMOST work.

Here's the neat thing I found: Using ForEachTiddler and RedirectMacro, I just make a tiddler called "redirects" and it includes:

<<forEachTiddler
 where
 '! tiddler.tags.containsAny([["excludeLists"]])'
 write
 '"<<redirect "+tiddler.title+" [["+tiddler.title+"]]$))\n"'>>

and I add <<tiddler [[redirects]]>> at the bottom of MainMenu (so that it loads early). I should have what I want, right? All tiddlers other than those with excludeLists tag get linked-to whenever their titles come up in the text of any other tiddler!

Well, not quite: 

(1) tiddlers with multi-word names fail -- the first word gets turned into a link for the second (which doesn't exist and/or isn't what I want). I need quote marks around multi-word tiddlers. Apparently they don't interfere with the way RedirectMacro works for tiddlers without spaces in the names, so I could have it put quotes around every phrase which is the title of the redirect trigger. STICKING POINT: Though I saw how Udo managed to escape the >> so that it could be included within a write action without ending the ForEachTiddler macro call, I don't see how we can escape quote-marks so that they won't be taken as part of ForEachTiddler's way of concatenating things to write...
 
(2) the list is long... anybody know at what point a long main menu with lots of redirect calls would create a performance barrier?

(3) It's still pretty odd the way TW gets hung up on capitalization, so I'd need to duplicate the whole set of redirects with some kind of way of getting capitalized uses of the same words to point to the tiddlers entitled with the lower-case version of the same word...

In the meantime, I *have* implemented the solution with a *positive* search for a tag ("reference"), and I tag a tiddler with "reference" if I want it to be an "EasterEgg" link, even for students who don't know they're making a link! ; )

OK, back to work.

-Elise

Folks,

With so much exciting development in the TW world, I'm feeling bolder about hinting at the sort of TW that I've been fantasizing about:

(1) The wikifier "notices" if any of the words or phrases in my tiddler correspond to the titles of other tiddlers, and forms links automatically.

(2) Each tiddler has a "field" as it were (like the tags area) for "aliases": variations on the name...

Eric Shulman

unread,
Feb 7, 2006, 12:48:44 AM2/7/06
to TiddlyWiki
> macro call, I don't see how we can escape quote-marks so that they
> won't be taken as part of ForEachTiddler's way of concatenating
> things to write...

use \" to escape quote-marks so you can put them around the tiddler
title:

<<forEachTiddler
where
'! tiddler.tags.containsAny([["excludeLists"]])'
write
'"<<redirect \""+tiddler.title+"\" [["+tiddler.title+"]]$))\n"'>>

-e
Eric Shulman
TiddlyTools / ELS Design Studios

Simon Baird

unread,
Feb 7, 2006, 1:27:52 AM2/7/06
to Tiddl...@googlegroups.com
That's a very clever way to use the forEachTiddler. Cool!
 
Ps, I think you are inventing the WikiWordLess wiki. That's kind of ground-breaking.  Good luck. :)

--
Simon Baird <simon...@gmail.com>

Simon Baird

unread,
Feb 7, 2006, 1:31:27 AM2/7/06
to Tiddl...@googlegroups.com
...I meant to add some exclamations after groundbreaking!!!!
 
Seriously, this idea could be a step forward for Wiki technology, not just TW.

Udo Borkowski

unread,
Feb 7, 2006, 8:22:17 AM2/7/06
to Tiddl...@googlegroups.com
Hi Elise,

very nice idea!!

Regarding 3)
You can avoid repeating the words in lower case. Just write a second redirect with the lower cased words.

Here the changed text:


<<forEachTiddler
 where
 '! tiddler.tags.containsAny([["excludeLists"]])'
 write
 '"<<redirect \""+tiddler.title+"\" [["+tiddler.title+"]]$))\n"+
  "<<redirect \""+tiddler.title.toLowerCase()+"\" [["+tiddler.title+"]]$))\n"'>>


This also includes the escape of the " (as already suggested by Eric).

Udo

Clint Checketts

unread,
Feb 7, 2006, 8:47:28 AM2/7/06
to Tiddl...@googlegroups.com
On 2/6/06, Elise Springer <elise_s...@yahoo.com> wrote:
Here's the neat thing I found: Using ForEachTiddler and RedirectMacro, I just make a tiddler called "redirects" and it includes:

Thats a great use of the redirect macro! Now I need to revisit it with Udo's suggestion of adding multiple redirects in a single macro call.

(2) the list is long... anybody know at what point a long main menu with lots of redirect calls would create a performance barrier?

A quick redirect rewrite would help if you run into any performance snags. Keep us posted on how it behaves.

-Clint

Eric Shulman

unread,
Feb 7, 2006, 9:03:32 AM2/7/06
to TiddlyWiki
Clint,

re: case-folding for redirects

Since the <<redirect>> macro creates new wikify() formatters, it should
be possible to allow regexps for the first param. For example:

<<redirect "[Cc]ase [Ii]nsensitive [Tt]iddler" CaseInsensitiveTiddler>>

The only problem I can see is that the macro uses param[0] to construct
the formatter "ID" as well as the "match" pattern for that formatter.
But it shouldn't be too hard to re-write to create a unique formatter
ID (or allow optional specification of one if a regexp is being used)

thoughts?

Clint Checketts

unread,
Feb 7, 2006, 9:28:36 AM2/7/06
to Tiddl...@googlegroups.com
On 2/7/06, Eric Shulman <elsd...@gmail.com> wrote:
The only problem I can see is that the macro uses param[0] to construct
the formatter "ID" as well as the "match" pattern for that formatter.
But it shouldn't be too hard to re-write to create a unique formatter
ID (or allow optional specification of one if a regexp is being used)

The idea has merit. It seems like it would be wise to call a different macro to enable the unique ID generator. Any ideas on how to accomplish it?

Another problem that might crop up (primarily in the context of this thread) is that I'm not sure if we can programatically generate the case insensitive reg-ex. Would we just create another function that checks the string for uppercase letters and does the bracket thing? If thats the case, couldn't we bracket every letter to make it case insensitive?

Maybe we coulr solve it all by using the \i (case insensitive switch) in the regex. Sadly I have no idea on how it would be put in. Any ideas?

-Clint

Eric Shulman

unread,
Feb 7, 2006, 11:11:36 AM2/7/06
to TiddlyWiki
> Maybe we coulr solve it all by using the \i (case insensitive switch) in the
> regex. Sadly I have no idea on how it would be put in. Any ideas?

Is there any reason that TW parsing is case sensitive to begin with?
If there isn't, and case-insensitive parsing would be safe to do for
ALL wiki syntax, in the TW core function "Formatter(formatters)",
changing this line:

this.formatterRegExp = new RegExp(pattern.join("|"),"mg");
to
this.formatterRegExp = new RegExp(pattern.join("|"),"img");

will make ALL wikify() parsing in TW case-insensitive. If this works
well, then Elise's use of redirect should get the results she wants
(i.e., case-insensitive auto-linking of existing non-WikiWord tiddlers)

caveat: I have not tried this myself...

-e
Eric Shulman
ELS Design Studios

Clint Checketts

unread,
Feb 7, 2006, 11:14:58 AM2/7/06
to Tiddl...@googlegroups.com
On 2/7/06, Eric Shulman <elsd...@gmail.com> wrote:
Is there any reason that TW parsing is case sensitive to begin with?
If there isn't, and case-insensitive parsing would be safe to do for
ALL wiki syntax, in the TW core function "Formatter(formatters)",
changing this line:

        this.formatterRegExp = new RegExp(pattern.join("|"),"mg");
to
        this.formatterRegExp = new RegExp(pattern.join("|"),"img");

will make ALL wikify() parsing in TW case-insensitive.  If this works
well, then Elise's use of redirect should get the results she wants
(i.e., case-insensitive auto-linking of existing non-WikiWord tiddlers)

The case detection is used in creating WikiWords. I'm fineif that disappears (though I'm sure some like it)

-Clint

Eric Shulman

unread,
Feb 7, 2006, 12:22:42 PM2/7/06
to TiddlyWiki
> The case detection is used in creating WikiWords. I'm fineif that disappears
> (though I'm sure some like it)

I don't think it would be a good idea to break recognition of
WikiWords. How about this instead... in your redirect macro, take
param[0] (the text to be 'redirected') and convert each alphabetic
character to construct a case-insensitive regexp version of the text

example: "This text" becomes "[Tt][Hh][Ii][Ss] [Tt][Ee][Xx][Tt]"

Sure, it's ugly, but it WILL work! The result: case-insensitive
matching for redirections, but the rest of the wikify() pattern matches
are unaffected

A separate issue I noticed while looking at your code: you probably
want to ensure that any regexp special chars that might be included in
param[0] are escaped so they won't be processed as patterns by
wikify().

example: <<redirect "(leave a comment)" CommentTiddler>>
...shouldn't treat the parens as a pattern group syntax.

Here's a one-liner that converts the param[0] to the needed pattern for
parsing:

var pattern=param[0].escapeRegExp().replace(/([A-Z])/img,
function($1) {return("["+$1.toUpperCase()+$1.toLowerCase()+"]");});

then, just use:

match: "(?:\s\sb)"+pattern+"(?:\s\sb)"

when defining the formatter[]...

HTH,

Clint Checketts

unread,
Feb 7, 2006, 12:29:30 PM2/7/06
to Tiddl...@googlegroups.com
On 2/7/06, Eric Shulman <elsd...@gmail.com> wrote:
Here's a one-liner that converts the param[0] to the needed pattern for
parsing:

Thanks! I'll add that in.

Eric, currently if the redirect is for 'MyWord' how can I get it to match [[MyWord]] as well (just in case someone wraps it as an explicit link)

-Clint

Eric Shulman

unread,
Feb 7, 2006, 12:43:45 PM2/7/06
to TiddlyWiki
> Eric, currently if the redirect is for 'MyWord' how can I get it to match
> [[MyWord]] as well (just in case someone wraps it as an explicit link)

add optional matches for [[ and ]] surrounding the pattern

(?:\\[\\[)? and (?:\\]\\])?

match: "(?:\s\sb)(?:\\[\\[)?"+pattern+"(?:\\]\\])?(?:\s\sb)"

Also, it occurs to me that sometimes people may actually want
case-sensitive redirections. Perhaps there should be an extra macro
param to allow that.

redleader

unread,
Feb 9, 2006, 7:40:22 PM2/9/06
to TiddlyWiki
This is where I wish I knew anything about RegExp. I don't grasp
regexp at all and could really use it right now in my yahoo! Widget,
Dylan Online which takes standard AIML (Artificial Intelligence Markup
Language) and displays it... The hitch is that the Yahoo Widget Engine,
Formerly Konfabulator, can't use anything but a text area, eg. No
IFRAME.... So it won't parse &lt;br&gt; or &quot; or any other tags
that the Pandorabots has in it. The way I've approached it is seeing
if I can remove the essentially useless tags from the response of the
bot instead of stripping out the code which I'd have to find, in the
AIML Code itself...

AT ANY RATE>>> I THINK THE 'WIKI-WORD-LESS WIKI' Is fantastic I want
to use that. i would...

Rock on tiddlywiki

Reply all
Reply to author
Forward
0 new messages