1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-04-29 18:21:30 +00:00

First pass at table of contents macros

Introduce macros for automatically generating table of contents
This commit is contained in:
Jermolene
2014-08-18 20:52:36 +01:00
parent a2acb1462b
commit 8cf726275c
18 changed files with 143 additions and 0 deletions

46
core/wiki/macros/toc.tid Normal file
View File

@@ -0,0 +1,46 @@
title: $:/core/macros/toc
tags: $:/tags/Macro
\define toc(tag)
<ol>
<$list filter="[tag[$tag$]]">
<li>
<$link>
<$view field="title"/>
</$link>
<$macrocall $name="toc" tag=<<currentTiddler>>/>
</li>
</$list>
</ol>
\end
\define toc-body(tag,show-button-filter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
<li>
<$link>
<$reveal type="nomatch" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="open" class="btn-invisible">
{{$:/core/images/right-arrow}}
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="close" class="btn-invisible">
{{$:/core/images/down-arrow}}
</$button>
</$reveal>
<$view field="title"/>
</$link>
<$reveal type="match" state=<<toc-state>> text="open">
<$macrocall $name="toc-expandable" tag=<<currentTiddler>>/>
</$reveal>
</li>
</$set>
\end
\define toc-expandable(tag)
<ol>
<$list filter="[tag[$tag$]]">
<<toc-body tag:"$tag$">>
</$list>
</ol>
\end