Is there any way of having wikitext call a procedure to do linking? I am thinking of a user defined way to linking tiddlers via a procedure. For example,
[[abc| xyz]]
Where xyz is a procedure call.
Bobj
Is there any way of having wikitext call a procedure to do linking? I am thinking of a user defined way to linking tiddlers via a procedure. For example,
[[abc| xyz]]
Where xyz is a procedure call.
Bobj
[[abc|xyz]] is already used to create a “pretty link”, where abc is the display text, and xyz is the tiddler title.
To use a procedure to output a link, I suggest just using the standard <<xyz "abc">> syntax, where the xyz procedure might be defined something like this:
\procedure xyz(tid)
<$link to=<<tid>>
... do something to compute and output the desired display text ...
</$link>
\end
-e
You could also call the procedure from inside a transclusion {{abc||uvw}} in side uvw it will call xyz with the abc parameter or current tiddler. Better yet, {{abx||xyz}} where xyz is a tiddler that does what your procedure would have done to abc. An advantage here is the new transcluding operator.
In the case of [[abc|xyz]] xyz is a tiddler or as you propose a procedure. You could redefine the $link widget to handle calling procedure but how do you decide when its a tiddler and when its a procedure.
But @Bob_Jansen why?, If not @EricShulman way, as this is how you use a procedure?
@TW_Tones , the reason i asked this question is because I am looking for a way to have dynamic linking where the target is determined at run time.
I think this would be useful in my gun TW because the gun type, the type of artillery piece a particular gun is, can and appears to have many different labels. For example, a 64 pounder RLF can be referred to as a 64 pounder, 64-pounder, 64 Pounder, 64-Pounder, 64 pndr, etc .
I have discussed with the domain experts about a standard labelling scheme but have been advised there is no agreed standard taxonomy.
So my thinking was to give each gun type tiddler a unique name, eg. MGA124, and then have a field containing all known labels for this type. The dynamic linker would then, when the user clicks a link in the specific gun text, look for a gun type with that source label in the dynamic label field and if a match is found, display that linked tiddler.
Now, the link should look identical to a normal wiki text link, so coloured blue. The user does not need to be aware of the underlying complexity.
This way, we can add new labels to gun types as we process content along the way.
Bobj
I’d recommend one (but not both!) of the two “alias” plugins I’m aware of: @mklauber’s Aliases or @pmario’s uni-link. In either case, you’d add labels to the aliases field, so aliases for “MGA124” might look like
aliases: [[64 pounder]] 64-pounder [[64 Pounder]] 64-Pounder [[64 pndr]]
Aliases are casesensitive in the “Aliases” plugin, but not in uni-link, so in that case you could omit “64-Pounder” and “64 Pounder” or their lowercase equivalents.
I use uni-link myself, but both plugins have their advantages.
Aliases overwrites the core link mechanism, which allows you to use the standard wikitext link format — so [[64 pounder]] would link 1) to a tiddler “64 pounder”, if one exists; 2) to a tiddler with “[[64 pounder]]” in its aliases field, if one exists, 3) to a disambiguation page if more than one tiddler shares the same alias. This might be the easiest solution, especially if some of the people using/maintaining your wiki are less familiar with TW. However, as it does overwrite some core widgets, it may not be optimal if you’ve made any other changes to link handling in your wiki.
uni-link maintains a wikitext distinction between [[standard links]] and [[alias links|?]], and it’s overall more feature-rich (and easier to customize, in my experience) at the cost of greater complexity. For instance, it also lets you choose to display the caption field, if present, as the link text of any [[standard link]] in your wiki. If you have a lot of short or opaque titles that you’d prefer to display with more semantic link text — e.g., you want a link to [[MGA124]] to render as “64 pounder RLF” by default — I recommend uni-link over Aliases.