How to create custom $link widget and use $wikify

I’m trying to create a custom link widget that will let me have a tooltip that previews some of the text of the linked tiddler. The code below works if you take out the $wikify. But I want the tooltip to display the rendered text. But when I use $wikify I get a recursive error.

I know there’s an old Tobias plugin that does this, but wouldn’t it be great if it could work with the new toolset from 5.3.0 ?

Thanks!

Kind of like a human LLM, I cobbled this code from these two threads:

\widget $link()
<$parameters $params="params-var">
   <$let newtip={{{[<params-var>jsonget[to]get[text]split[]limit[50]join[]]}}} >
<$wikify text=<<newtip>> name="newtip2" output="text">
	<$genesis
			$type="$link"
			$remappable="no"
			$names="[<params-var>jsonindexes[]] =[[tooltip]]"
			$values="[<params-var>jsonindexes[]] :map[<params-var>jsonget<currentTiddler>] =[<newtip2>]"
			>
	</$genesis>
</$wikify>
   </$let>
</$parameters>
\end

* <$link to="HelloThere" tooltip="something">has a tooltip link</$link> to a tiddler
* [[HelloThere]] is a tiddler in TiddlyWiki.

I suspect the problem is due to links being rendered within the wikify widget and this leading to recursion, though this is merely a suspicion. Perhaps try the example with camel case links disabled?

Another potential approach might look like this:

\widget $link()
	\procedure tv-wikilink-tooltip()
	<$let newtip={{{[<currentTiddler>get[text]split[]limit[50]join[]]}}} tv-wikilinks="no">
		<$wikify text=<<newtip>> name="newtip2" output="text">
			<$transclude $variable="newtip2"/>
		</$wikify>
	</$let>
	\end tv-wikilink-tooltip
<$parameters $params="params-var">
	<$genesis
		$type="$link"
		$remappable="no"
		$names="[<params-var>jsonindexes[]]"
		$values="[<params-var>jsonindexes[]] :map[<params-var>jsonget<currentTiddler>]"
	>
	<$slot $name="ts-raw"/>
	</$genesis>
</$parameters>
\end

Thanks for the code and the clever work-around!

I still don’t understand why $wikify should cause recursion, especially if output mode is “text”. There may not be a handy background variable for other apps.

I guess everyone already knew that you can’t apply rendering to a tooltip. TIL …

Thanks!

Unfortunately I don’t have an example on hand as I scrapped the approach, but I’ve encountered recursion errors with custom $link widgets before, and I’m 99% sure I was not using $wikify. I wonder whether there’s something else going on here.

The wikify widget needs to render your wikitext first and then extract the plain text representation for it.

But if the incoming WikiText has no links, then why should it recurse?

Recursion drives me in circles.

Have you confirmed that recursion errors occur even when the text to be wikified has no links?

Oh, you’re right. Although I don’t understand why. My filter looks for the first 50 characters of a tiddler. There is no link in the first 50 characters of tiddler TiddlyWiki . But $wikify must be somehow reading the entire thing ?? Anyways, when I turn off camelcase for TiddlyWiki, it doesn’t recurse. (Also I switched “HelloThere” to “HelloThere2”).

I’m late to the custom widgets game. Another thing is that you apparently need a blank line inside of the $genesis widget (or the $slot widget) in order to see the contents (in this case, the linked text).