$macrocall $name=toc-selective-expandable : tag selection

Hello,

I have a macrocall

<$macrocall $name=toc-selective-expandable tag={{!!title}}

How could I add a “not a specific tag” AND another tag filter to it please ?

Thanks

Hi,
There is no official way at the moment, but there is a “hacky” way. … The macro has an “exclude” parameter, that is internally used, to avoid recursions. So eg: A tags B and B tags A … Which would create an endless loop.

This parameter can be used. Internally the macro uses -[enlist<__exclude__>] to filter out tiddlers, that have already been used.

So if you call it:

<$macrocall $name=toc-selective-expandable tag={{!!title}} exclude={{{ [enlist[A B]] }}}/>

It will not use tiddler: A and tiddler: B in your toc.

A more flexible approach should be to use a “list variable”

<$set name="myList" filter="[tag[hide]]">
<$macrocall $name=toc-selective-expandable tag={{!!title}} exclude=<<myList>> />
</$set>

This will exclude every tiddler tagged: “hide”

The important thing is: myList needs to contain a list. So if you test it and [enlist<myList>] shows you a list the parameter should work for the toc-xxx macros.

4 Likes

That is a really neat trick, @pmario, thanks for sharing!

I was delighted to find this, but…

This trick fails for toc-tabbed-external-nav and toc-tabbed-internal-nav (which is, of course, what I want it for).

Try it at tiddlywiki.com:

<$set name="myList" filter="[tag[Mathematics Operators]]">
<$macrocall $name=toc-tabbed-internal-nav tag="Filter Operators" exclude=<<myList>> />
</$set>

(In the resulting tabbed toc, Mathematics Operators are not excluded.)

Any ideas, or workarounds?

If you look inside $:/core/macros/toc you will notice the two you mention do not define the exclude parameter.

  • Work around is to use one of the other toc macros

Fix

  • Investigate if its trivial or complex to also add the exclude parameter in those macros.
  • If so don’t touch $:/core/macros/toc just copy out the macros you want to edit and place them in a new tiddler tagged $:/tags/Macro with a list-after="" (check this) so these replace the core ones.
    • If you / we get this working submit a core change

[Post Script] Table-of-Contents Macros documentation needs be updated as exclude is not even mentioned.

Thanks for chiming in!

Alas, I would not call that a workaround. The difference between the tabbed toc macros and the others is a total difference of function, for some purposes.

If I get desperate, I may try to clone the macro and make a version that works with any title list from a filter, rather than accepting only a tag… and this would solve other challenges as well. Alas, it’s not something I should devote time to at the moment…

see [tw5] Using Filter Notation in code for Table of Contents - #5 by EricShulman
and [BUG] toc-tabbed-* macros should accept initial `exclude` parameter · Issue #7261 · Jermolene/TiddlyWiki5 · GitHub

1 Like