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...
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
Here's the neat thing I found: Using ForEachTiddler and RedirectMacro, I just make a tiddler called "redirects" and it includes:
(2) the list is long... anybody know at what point a long main menu with lots of redirect calls would create a performance barrier?
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?
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)
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
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)
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,
Here's a one-liner that converts the param[0] to the needed pattern for
parsing:
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.
AT ANY RATE>>> I THINK THE 'WIKI-WORD-LESS WIKI' Is fantastic I want
to use that. i would...
Rock on tiddlywiki