MathManM
MathManM

Reputation: 135

How to make abbreviated links to other tiddlers?

I frequently link to another tiddler in my wiki having a particularly long name. Currently I'm using the [[text|tiddler_name]] syntax. I'd like to replace tiddler_name with an abbreviated version or shortcut rather than the full name, to make it more convenient to use. How to do that?

Upvotes: 1

Views: 537

Answers (2)

laverniust
laverniust

Reputation: 35

I came across this question by accident, but if you're still looking for solutions, Tobias Beer has a macro that I've been using for years that allows you to define multiple case-insensitive alt links using the following code.

\define a:target()
<$list filter="[regexp:alink<regexp>limit[1]]"><$link><<target>></$link></$list>
\end

\define a:(target)
<$set name="regexp" value="\|$target$\|(?i)"><$set name="target" value="$target$"><<a:target>></$set></$set>
\end

\define alink(target) 
<<a: "$target$">> 
\end

https://tobibeer.github.io/tb5/#Alias%20Links

After adding the plugin to your wiki, just add a field named alink to the tiddler and put |text| as the value. You can then type <<a: text>> instead of [[tiddler_name]].

Be aware that alink values should be lowercase and if you use something with spaces like |your text|, you'll need to reference it as <<a: [[your text]]>>

Upvotes: 1

sfx
sfx

Reputation: 103

You cannot use the [[|]] syntax for that. You can define a new macro using the link widget as follows.

\define mylink(the_caption, text)
<$list filter="[caption[$the_caption$]]">
<$link to={{!!title}}>$text$</$link>
</$list>
\end

I assumed that you use the field caption to store a shorter name of a tiddler. Put the above code into a tiddler and tag the tiddler with $:/tags/Macro. To put a link using this macro, use

<<mylink short_name text_displayed>>

Basically, the macro filters all tiddlers that have the caption=short_name. So if there are two tiddlers having the same caption, two links will be displayed.

Upvotes: 0

Related Questions