Folks,

We see a range of requests to customise the Table Of Contents macros such 
as here 
<https://groups.google.com/forum/?hl=en#!topic/tiddlywiki/c26Ovb5ivdA> to 
colour items. Often we try and address each of these bespoke requests using 
the existing TOC macros. This perhaps because the nature of a TOC is a 
little less intuitive than most. It requires a Recursive 
<https://en.wikipedia.org/wiki/Recursion> process. I thought I would share 
some details on this recursive code pattern and invite others to produce 
additional features, ideally based on those prior so people can learn from 
them.

The Following examples work if placed in a single tiddler on TiddlyWiki.com

\define each-other-level(filter)
<li><$link to=<<currentTiddler>> ><$text text=<<currentTiddler>>/></$link></li>
<ul>
<$list filter="$filter$">
   <<each-other-level $filter$>>
</$list>
</ul>
\end
\define first-level(filter)
<ul>
<$list filter="$filter$">
   <<each-other-level $filter$>>
</$list>
</ul>
\end

Start in TableOfContents<br>
<$tiddler tiddler="TableOfContents">

<<first-level "[is[current]tagging[]]">>

</$tiddler>


See how the at the bottom we start calling the first-level macro, then this 
calls each-other-level for each item in the list.


The recursion then occurs when inside *each-other-**level* we call 
*each-other-level*


Not how the list is wrapped in `<ul>` and each line with `<li>` this makes use 
of HTML to generate lists and will nest them.


Soon I will post a more advanced version with Notes.


Regards

Tony


-- 
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/5143cad3-5e7a-429b-b263-9ea3214ca35d%40googlegroups.com.

Reply via email to