Is there a way to auto generate a TOC based on tags?

189 views
Skip to first unread message

Andy Pastuszak

unread,
Mar 9, 2016, 1:21:49 PM3/9/16
to TiddlyWiki
I'd like to create a TOC with the tags all being H1 and the notes being H2 underneath them.  Is there an automated way of doing this?

Andy

Mat

unread,
Mar 9, 2016, 2:04:26 PM3/9/16
to TiddlyWiki
There isn't a ready made one doing exactly that but it would not be hard to make something for it using the standard "list filter" procedures. Also there are the Table of Contents macros if you didn't see them.

<:-)

Andy Pastuszak

unread,
Mar 9, 2016, 10:05:30 PM3/9/16
to TiddlyWiki
Right now, I don't have any links in my Tiddlywiki.  Just a bunch of tagged tiddlers.  When I put in a <<toc>>, it doesn't generate anything.

Andy

Eric Shulman

unread,
Mar 9, 2016, 10:49:03 PM3/9/16
to TiddlyWiki
On Wednesday, March 9, 2016 at 7:05:30 PM UTC-8, Andy Pastuszak wrote:
Right now, I don't have any links in my Tiddlywiki.  Just a bunch of tagged tiddlers.  When I put in a <<toc>>, it doesn't generate anything.

To generate a Table of Contents "tree" outline from individual tiddlers. start by picking a tag to use as the "root tag" of your toc tree.  Any tiddlers tagged with the root tag will appear at the top level of the toc tree.  To create additional levels, just create new tiddlers and tag each of them with the title of a tiddler already in the tree, and those tiddlers will appear as a level below that existing tiddler.

To display the Table of Contents, write <<toc ROOTTAG>> where ROOTTAG is the tag you chose for your starting point.

NOTE: be very careful not to tag a tiddler with the name of one of it's "children", or you will create an infinite recursion loop, where a tiddler is it's own "grandchild".  If this happens, the <<toc>> macro keeps trying to render deeper and deeper into a never ending tree, and the entire document become non-responsive and you have to wait for it to timeout and then reload the whole window (without being able to save first).

You can avoid this problem simply by making sure that all the tags in your toc tree form a clean hierarchy, a top-down "tagsonomy", without any cycles.

hope this helps,

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals

Andy Pastuszak

unread,
Mar 9, 2016, 11:08:20 PM3/9/16
to TiddlyWiki
Thank you Eric.  That explanation was perfect.  I've spent the last hour or so trying to figure out how to do this, and your explanation was perfect.
Reply all
Reply to author
Forward
0 new messages