tobibeer / tw5-plugins

documentation for all plugins by tobibeer for TiddlyWiki5
http://tobibeer.github.io/tw5-plugins
11 stars 5 forks source link

Alink and Backlinks #3

Closed diego898 closed 6 years ago

diego898 commented 7 years ago

Hello,

I am using the Alinks macro on my TW5 and I have a question about how to use it with backlinks. I have a tiddler called: Followup. In it, I have:

Things to follow back up with:
<<list-links "[all[current]backlinks[]]">>

I use it like:

I need to remember to #[[Followup]] with this.

I now wanted to use with alinks, so I added an alink field to my Followup tiddler, with the content: |#followup|. Now when I use <<a: #followup>> it links correctly, but it no longer shows up in the Followup tiddler.

Is there a way to fix this? Thanks!

diego898 commented 7 years ago

I also posted a question to the google groups, that essentially asked how to best include a footer for tiddlers that have the alink field and is non-empty.

tobibeer commented 6 years ago

Since alink is a custom macro the wikitext parser will not recognize its syntax as the links they eventually become. TiddlyWiki does not parse the eventually wikified output / parse tree but only the wikitext representation.

Let me give you an example. Say you used a list widget that would contain Tiddler X in its output. Surely, as gr8 as that might actually be, you would not expect a search for Tiddler X to yield the tiddler / reference where that list macro would yield it as a result. While determining backlinks for alinks would be a somewhat simpler task it falls in the same problem category.

So, the only way to achive what you want is a custom "backlinks" mechanism for it. However, this is a somewhat hard nut to crack since there are possibly multiple aliases to one tiddler so merging the results into one list is difficult.

I consider alink more as an experiment than an actual plugin. Meaning: I would shoot for a reliable aliasing plugin that is ripe enough to even be a core candidate. Unfortunatel,y alink is not that kind of implementation, although prividing a possible foundation in terms of mechanics.

tobibeer commented 6 years ago

A simplistic, fuzzy, not exact alias search could be implemented using this:

\define aback(term)
<$list filter="[!is[system]search[<<alink $term$]sort[title]]"><$link><$view field="title"/></$link></$list>
\end

Everything reliable would have to be properly done using javascript, I imagine.

tobibeer commented 6 years ago

Actually, I don't know why I thought a "piped list" would be a good idea. I should have just used a plain enumeration of simple words which a filter can easily handle.

tobibeer commented 6 years ago

Here's an updated version of $:/.tb/macros/alink for you to test:

\define aback(alias)
<$set name="regexp" value="<<(?:alink|a\:)\s$alias$>>">

{{{[regexp:text<regexp>]}}}
</$set>
\end

\define a:(target)
<$set name="regexp" value="\|$target$\|(?i)"><$set name="target" value="$target$"><$list filter="[regexp:alink<regexp>limit[1]]"><$link><<target>></$link></$list></$set></$set>
\end

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

Notice the aback macro that you can feed an alias to find instances where it is being used. What it does not allow is to say "find all instances for all defined aliases of a tiddler".

diego898 commented 6 years ago

Thanks for this tobias! I'll go ahead and close this for now.