This is a good point. The built-in table-of-contents macro appears to avoid
the issue by excluding the current tiddler at each level, which could be
applied to my example above:
\define toc-body(tag,sort:"",itemClassFilter,exclude,path)
<ol class="tc-toc">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$]
-[<__tag__>] *-[enlist<__exclude__>]*""">
<$vars item=<<currentTiddler>> path={{{
[<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
<$set name="*excluded*" filter="""[enlist<__exclude__>] *[<__tag__>]*
""">
<$set name="toc-item-class" filter=<<__itemClassFilter__>>
emptyValue="toc-item-selected" value="toc-item">
<li class=<<toc-item-class>>>
<$list filter="[all[current]toc-link[no]]" emptyMessage="<$link
to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}><$view
field='caption'><$view field='title'/></$view></$link>">
<<toc-caption>>
</$list>
<$macrocall $name="toc-body" tag=<<item>> sort=<<__sort__>>
itemClassFilter=<<__itemClassFilter__>> *exclude=<<excluded>>*
path=<<path>>/>
</li>
</$set>
</$set>
</$vars>
</$list>
</ol>
\end
On Monday, April 19, 2021 at 12:41:48 PM UTC-5 [email protected] wrote:
> About recursive macro, they may be possible, but the problem is how to
> stop the recursion. Your example works if there is no loop created by
> tagging.
>
> The problem is we don't have a proper <<if>> macro to decide what to do
> (control recursion call in that case). Or how do you do that?
>
> Le dimanche 18 avril 2021 à 21:36:33 UTC+2, Soren Bjornstad a écrit :
>
>> I've never tried to do a recursive* filter*, so I don't know what's
>> technically possible (though I've never seen someone try to use multiple
>> filter runs in *subfilter* and am a bit suspicious that the second run
>> is doing a tagging[] on everything in your wiki). But recursive macros are
>> easy and functional, and I suspect they'll work for your use case. Here's
>> one version that does an outline of the TOC on tiddlywiki.com, using the
>> current tiddler to easily pass the state through to the next level:
>>
>> \define recurse()
>> <$list filter="[all[current]tagging[]]">
>> <li><<currentTiddler>><ul>
>> <<recurse>></ul></li>
>> </$list>
>> \end
>>
>> <$tiddler tiddler="TableOfContents">
>> <ul>
>> <<recurse>>
>> </ul>
>> </$tiddler>
>>
>> On Sunday, April 18, 2021 at 2:01:51 PM UTC-5 Yaisog Bonegnasher wrote:
>>
>>> Hi,
>>> I recently tried to create a recursive subfilter to find all tiddlers
>>> below a certain tag, no matter how many levels deep (similar to the
>>> *kin* filter, which is too slow for my large wiki). Unfortunately, I
>>> was greeted with a red-message-box-of-death informing me of too much
>>> recursion. However, there should only be a couple of levels.
>>> Are recursive filters at all possible or am I doing something wrong?
>>> For a quick example, try this in a new tiddler on tiddlywiki.com:
>>> \define subfilter-test() [tagging[]] [tagging[]subfilter<subfilter-test>]
>>>
>>> <$set name="test" filter="[[TableOfContents]subfilter<subfilter-test>]">
>>> <$list filter="=[enlist<test>]" template="$:/core/ui/ListItemTemplate"
>>> />
>>> </$set>
>>> Any enlightment is greatly appreciated.
>>> Best regards
>>> Yaisog
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/0df850d6-9b10-4ccc-8511-3c845cd91474n%40googlegroups.com.