Preventing Links inside links

79 views
Skip to first unread message

Matthew Lauber

unread,
Oct 14, 2016, 2:21:30 PM10/14/16
to TiddlyWiki
I've got a macro I'm using, that's essentially a shortcut function.  

\define npc(number) <$link to="NPC $number$">{{NPC $number$!!name}}</$link>

This works great, I've got my NPCs numbered and I can change their names at any time without worrying about links.  But sometimes I use this macro inside another <$link> tag, and then parts of the link goes to different places.  What I'd like is some way to make the macro say "If I'm already in a link, don't add the <$link> tags"   Anyone ever done something like that?  Is there any way to know if you're already in a link?

Tobias Beer

unread,
Oct 14, 2016, 2:48:11 PM10/14/16
to TiddlyWiki
Hi Matthew,

 
\define npc(number) <$link to="NPC $number$">{{NPC $number$!!name}}</$link>

Try:

\define npc(number) <$link to="NPC $number$"><$text text={{NPC $number$!!name}}/></$link>

Best wishes,

Tobias. 

Matthew Lauber

unread,
Oct 14, 2016, 2:53:12 PM10/14/16
to TiddlyWiki
Oops, looks like I wasn't completely clear.  The issue isn't links inside `{{NPC $number$!!name}}` but rather inside something like <$link to "...">Talking with <<npc 13>></$link>

So, I want it to be a link if the macro is called outside a <$link> block, but not inside.

Tobias Beer

unread,
Oct 14, 2016, 4:12:32 PM10/14/16
to tiddl...@googlegroups.com
Hi Matthew,

So, you're saying that your text reference actually points to another link widget, so when that is replaced:

<$link to="foo">{{SomeTiddler!!reference}}</$link>

you end up with something like:

<$link to="foo">bar <$link to="baz">mumble frotz</$link> gronk</$link>

?

I would think you're not properly using your fields if that's your result,
e.g. like transcluding an entire tiddler in a link widget.

If TiddlyWiki ends up having you click the link in the link
then it's actually doing what it's supposed to.

The only way out would be if the $link widget had some attribute like:

<$link greedy="yes">if there is some click handler in here, it should never fire</$link>

But that sounds like a lot of work for something you may want to rethink in the first place.

What's wrong about using the $text widget in your case?

Best wishes,

Tobias.

BJ

unread,
Oct 15, 2016, 1:47:52 AM10/15/16
to tiddl...@googlegroups.com
It is possible to turn linking off:

\define g() <$link to="b">linktob</$link>

<$link to="a"><$vars tv-wikilinks=no>linktoa <<g>></$vars></$link> <<g>>


all the best
BJ

Matthew Lauber

unread,
Oct 17, 2016, 8:54:40 AM10/17/16
to tiddl...@googlegroups.com
@BJ, brilliant, that's exactly what I needed.  

Matt
Reply all
Reply to author
Forward
0 new messages