Hi. Suppose I have the tiddler tid1
with contents
* 300 <<tag "keyword">>
* 100 <<tag "keyword">>
and the tiddler tid2
with contents
* 400 <<tag "keyword">>
* 200 <<tag "keyword">>
I want to search for tiddlers containing <<tag "keyword">>
and get back-links to it. So my first implementation would be
\define search-string() \<\<tag\s"keyword"\>\>
\define show-backlink()
(<$link to=<<currentTiddler>>><$view field="caption">{{!!title}}</$view></$link>)
\end
Search results (1):
<$list filter="[regexp:text<search-string>]">
<$list filter="[all[current]get[text]splitregexp[\n]trim[*]regexp<search-string>] +[sort[title]]" variable="line">
<<line>> <<show-backlink>> <br/>
</$list>
</$list>
The outer list gets target tiddlers and the inner list gets the sorted lines. This gives output in search results (1) in the picture below.
This was ok but it only sorts lines within the same tiddler. (The outer list sorts the tiddlers and the inner list sorts lines within the same tiddlers). But I want to do sort(S) where S should be the union of all line results.
So using the trick from this thread I asked a while ago, by concatenating the results into a single string and then sort, I tried
Search results (2):
<$list filter="[regexp:text<search-string>]
+[get[text]splitregexp[\n]trim[*]regexp<search-string>addsuffix<show-backlink>]
+[sort[title]]" variable="line">
<<line>><br/>
</$list>
This sorts the lines correctly as expected. However, as you can see in the picture, the backlinks are not correct. It’s like the currentTiddler variable from [regexp:text<search-string>]
is lost when it gets passed to the next filter. Is there any way I can get the backlink to link to the correct tiddlers?
Any help is appreciated. (I attached the three tiddlers above in case you need to experiment.)
inline-search.json (1.0 KB)