Am 22.09.2014 14:25, schrieb Jeremy Ruston:
No, there's no intrinsic limit to the number of levels, although the
default theme only styles the entries up to level 4; we can increase
that if required.
On Mon, Sep 22, 2014 at 1:23 PM, Shash <[email protected]
<mailto:[email protected]>> wrote:
Hi All,
Is there a way to limit the number of levels in TOC macro in TW5.
I could not find any documentation for that. Thanks in advance!
While it is true that there is no such functionality built-in, it is
pretty easy to add such functionality to the toc macro.
The following can be done with any of the toc-* macros, but to make it
more readable I will do a limiting version of the
simple <<toc>> macro:
\define toc-limit(tag,maxdepth,sort:"",depth:"")
<$list filter="$maxdepth$ +[regexp[e$depth$]]">
<ol class="tc-toc">
<$list filter="[tag[$tag$]$sort$]">
<li>
<$list filter="[is[current]toc-link[no]]" emptyMessage="<$link><$view field='caption'><$view
field='title'/></$view></$link>">
<$view field="caption">
<$view field="title"/>
</$view>
</$list>
<$macrocall $name="toc-limit" tag=<<currentTiddler>> maxdepth="$maxdepth$"
depth="e$depth$"/>
</li>
</$list>
</ol>
</$list>
\end
Notice that maxdepth is a required parameter. You can use the macro like
this:
<<toc-limit "Reference" maxdepth:"ee">>
where the number of 'e's in maxdepth denotes the number of levels, so
this would do 2 levels, whereas maxdepth:"eee" would display 3. (You can
ofc choose some other regex, but this demonstrates the concept quite well)
You can copy the macro and the usage into tiddlywiki.com and it will
display part of the sites toc.
Have fun,
/Andreas
--
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 http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.