Apply link label and redirection based on input

50 views
Skip to first unread message

David Allen

unread,
Jul 15, 2017, 6:11:38 PM7/15/17
to TiddlyWiki
I'm trying to create a macro that will format links based on an input string.  The label for the link, as well as its target, may or may not be different from the input string itself.

This is my current attempt at such a macro:
\define current_assign(name, target)
<$list filter="[tag[info_assignment]name[$name$]sort[begin]last[]get[$target$]]">
<$list filter="[<currentTiddler>listed[redirect]]" emptyMessage="<<currentTiddler>>" variable="moose">
<$link to=<<moose>> >
<$macrocall $name="get_clean" input=<<currentTiddler>>/>
</$link>
</$list>
</$list>
\end

\define get_clean(input)
{{Dict_Clean!!$input$}}
\end

Works fine if I want to redirect the link and apply a new label, but if I don't want to do one of those, or neither, this solution doesn't work.

I figured that the redirection problem was due to emptyMessage containing only <<currentTiddler>>, so I tried changing the second list widget to a set widget, as follows:

\define current_assign(name, target)
<$list filter="[tag[info_assignment]name[$name$]sort[begin]last[]get[$target$]]">
<$set name="moose" filter="[<currentTiddler>listed[redirect]]" emptyValue="<<currentTiddler>>">
<$link to=<<moose>> >
<$macrocall $name="get_clean" input=<<currentTiddler>>/>
</$link>
</$set>
</$list>
\end

Here's what's strange about this.  If the tiddler fetched by listed[redirect] has a space in it, the <$list> widget uses it just fine, but the <$set> widget adds double square brackets around the title.  I've been unable to find a reliable way to strip the double brackets, and it makes the process of applying a label to a link impossible.

I've tried using Tobias's setvars widget, same results as the set widget.

If anyone knows of some way to fix this, please let me know!

Eric Shulman

unread,
Jul 15, 2017, 6:41:51 PM7/15/17
to TiddlyWiki
On Saturday, July 15, 2017 at 3:11:38 PM UTC-7, David Allen wrote:
Here's what's strange about this.  If the tiddler fetched by listed[redirect] has a space in it, the <$list> widget uses it just fine, but the <$set> widget adds double square brackets around the title.  I've been unable to find a reliable way to strip the double brackets, and it makes the process of applying a label to a link impossible.
I've tried using Tobias's setvars widget, same results as the set widget.
If anyone knows of some way to fix this, please let me know!

if you pass your result through the <$wikify> widget, it will render the "plain text" of the link, without any surrounding brackets.  Something like this:

<$wikify name="moose" text=<<moose>>>
   <$link to=<
<moose>> >
      <$macrocall $name="get_clean" input=<
<currentTiddler>>/>
   </$link>
</$wikify>

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas" (tm)
InsideTiddlyWiki: The Missing Manuals

David Allen

unread,
Jul 15, 2017, 6:58:04 PM7/15/17
to TiddlyWiki
That seems to have worked, thanks
Reply all
Reply to author
Forward
0 new messages