1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-18 03:19:55 +00:00
TiddlyWiki5/core/wiki/macros/toc.tid
Jermolene 58730b7452 Add selective expandable table of contents macro
And improve the layout of the examples
2014-08-19 12:30:22 +01:00

80 lines
1.9 KiB
Plaintext

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-expandable-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-expandable-body tag:"$tag$">>
</$list>
</ol>
\end
\define toc-selective-expandable-body(tag,show-button-filter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
<li>
<$link>
<$list filter="[all[current]tagging[]limit[1]]">
<$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>
</$list>
<$view field="title"/>
</$link>
<$reveal type="match" state=<<toc-state>> text="open">
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>>/>
</$reveal>
</li>
</$set>
\end
\define toc-selective-expandable(tag)
<ol>
<$list filter="[tag[$tag$]]">
<<toc-selective-expandable-body tag:"$tag$">>
</$list>
</ol>
\end