On Wednesday, December 30, 2015 at 7:34:29 AM UTC-8, Jed Carty wrote:
>
> I just put up a new version that I haven't been able to break yet. It may
> keep some things from showing up correctly but I haven't found any yet.
>
As part of my InsideTiddlyWiki (ITW) book project, I've written my own TOC
macro replacements with lots of good stuff, including a <<toc-path>> macro
that handles all loops in the parent path. Here's a simplified version of
that function that illustrates the basic recursion for showing the path:
\define toc-path()
<$macrocall $name="toc-path-body" here=<<currentTiddler>>/>
\end
\define toc-path-body(here,exclude)
<$list filter="""[title[$here$]tags[]] $exclude$ -[[$here$]]
+[limit[1]]""">
<$macrocall $name="toc-path-body" here=<<currentTiddler>>
exclude="""$exclude$ -[[$here$]]"""/>
<$link><$text text=<<currentTiddler>>/></$link> >
</$list>
\end
Notes:
* I used [limit[1]] to handle the "multiple parents" issue. It only shows
the "first" path from the current tiddler to the root of the tree.
* The "exclude" param is not passed initially. It is used internally to
keep track of which tiddlers have already been visited in the path to avoid
looping. This also means that if a node has two or more parents, the first
parent not already excluded is used to continue up the tree.
* The recursion happens *before* the output. Thus, the macro gets to the
root of the tree, and THEN outputs the current title, followed by a ">"
(>). As the recursion 'pops the stack', successive titles are
displayed, giving the proper "top down" path from root to node.
enjoy,
-e
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/4412be07-1bcf-45d2-9aea-d4c3a5665480%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.