TW5: How to make simple TOC for headers in the current tiddler only?

103 views
Skip to first unread message

Chuck R.

unread,
Dec 10, 2019, 10:32:13 AM12/10/19
to TiddlyWiki
My setup: TW5.1.19 on tiddlyspot.com, using Chrome to view and edit the TW online, using Windows 7 or 10, using TW5 markup

I just want a TOC at the top of tiddlers where I insert the TOC, to show a list of the headers listed in that tiddler only, with links so the user can click on a link in the TOC to jump to that area of the tiddler.

I've looked at some of the <<toc>> macros but I can't get them to work, nor find any documentation on which parameters are required. I've tried this at the top of a normal TW5 language tiddler:

<div class="tc-table-of-contents">
<$macrocall $name="toc-selective-expandable" tag=<
<currentTiddler>> >
</div>


But then my whole tiddler disappears when I save the changes with no TOC. I can edit the tiddler again and everything is still there, but none of the contents are displayed.

Is this possible? I don't want another sidebar TOC as my horizontal spaces is very limited for my browser and desktop. I prefer to keep my brower tall and narrow that is.

Thank you.

Chuck R.

unread,
Dec 10, 2019, 10:34:09 AM12/10/19
to TiddlyWiki
Also, I don't need the TOC entries to be numbered. If the TOC is not expandable that's ok too. I just need something simple to list all header entries in the current tiddler. H3 entries should appear indented under H2 entries. Typically I start by adding H2 entries to a tiddler, not H1 entries.


Mark S.

unread,
Dec 10, 2019, 11:41:02 AM12/10/19
to TiddlyWiki
If you're having to create a TOC inside a tiddler, then you're probably not following the philosophy of tiddlers. Yes, TiddlyWiki has a philosophy.

The idea in TW is that each tiddler contains the smallest meaningful text. Sometimes what is meaningful is a paragraph. Sometimes it's a word. Sometimes it's an article.

Once you have all these tiddlers, you can then use tools like the TOC macro or the List Widget to create an index into them. If they're connected by a common tag, then you can also easily re-arrange them. You can slice them and dice them, compare them and share them.

Having said all that, there's a bug in TW that may allow you to index inside a tiddler, if you want more things in your TW than are dreamt of in your philosophy.

See:


I notice the very last link in the thread leads to a 404 error, but there may be other links in the discussion that you can use.

Chuck R.

unread,
Dec 10, 2019, 12:11:40 PM12/10/19
to TiddlyWiki
Thank you. I read up on the philosophy of tiddlers and it makes sense. My idea was to have one topic and put summaries to a bunch of studies in that tiddler, to make it easier to print that one tiddler to paper, but I can actually make one tiddler for each study summary and transclude all those tiddlers into the one, via the <$list> widget and a common tag, which can also be printed. So I'm converting to transcluded tiddlers, one tiddler per study summary. :)

I'm not that far creating my wiki so that's why I have all these beginner questions. I'm figuring out designs of the wiki right now.

Thanks!


Eric Shulman

unread,
Dec 10, 2019, 12:49:26 PM12/10/19
to TiddlyWiki
On Tuesday, December 10, 2019 at 7:32:13 AM UTC-8, Chuck R. wrote:
I just want a TOC at the top of tiddlers where I insert the TOC, to show a list of the headers listed in that tiddler only, with links so the user can click on a link in the TOC to jump to that area of the tiddler. 

As Mark S. indicated in his reply, this is not how the TOC macros work.  There is no INTRA-tiddler addressing in TW5.

Interestingly enough, this kind of functionality WAS available in TWClassic, based on the concept of tiddler "sections", which were defined by using the "!" header syntax to identify the starting/ending boundaries of the sections within a tiddler.

Using that TWClassic syntax, I actually created a plugin, http://tiddlytools.com/#SectionLinksPlugin, that provided extended reference and navigation tools for working with tiddler sections, including the ability to generate an intra-tiddler "table of contents" display.

However... as noted, "sections" are no longer a valid construct within TW5, which -- correctly -- eschews the entire concept in favor of the more consistent and logical "tiddlers are the smallest units of information" paradigm.

historically,
-e
Eric Shulman
TiddlyTools: "Small Tools for Big Ideas!" (tm) www.TiddlyTools.com (TWClassic)
InsideTiddlyWiki: The Missing Manuals www.TiddlyTools.com/InsideTW (TW5, work-in-progress)


TonyM

unread,
Dec 11, 2019, 9:02:25 PM12/11/19
to TiddlyWiki
Chuck

Not withstanding the good advice to make tiddlers the the main unit of data in tiddlywiki, because apart from anything all the tools and solutions leverage this, this has being an ongoing issues for many one approach to the solution is;


There is a fundamental difference between tiddlywiki and standard html pages, and that is everything is in a single page (the tiddlywiki file) which has many advantages including the live refresh where a change is immediately reflected. However this make use of standard anchors difficult because there may be more than one on the page at a time. The linked to discussions address this but you need to code the headings a particular way.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages