kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Extend toc macro so that links can be disabled
This allows table of contents to contain heading entries that do not function as links, like the one in the sidebar.print-window-tiddler
rodzic
7e93c93785
commit
ba3f800235
|
@ -5,18 +5,18 @@ tags: $:/tags/Macro
|
|||
<ol class="tc-toc">
|
||||
<$list filter="[tag[$tag$]$sort$]">
|
||||
<li>
|
||||
<$link>
|
||||
<$list filter="[is[current]toc-link[no]]" emptyMessage="<$link><$view field='caption'><$view field='title'/></$view></$link>">
|
||||
<$view field="caption">
|
||||
<$view field="title"/>
|
||||
</$view>
|
||||
</$link>
|
||||
</$list>
|
||||
<$macrocall $name="toc" tag=<<currentTiddler>>/>
|
||||
</li>
|
||||
</$list>
|
||||
</ol>
|
||||
\end
|
||||
|
||||
\define toc-expandable-body(tag,sort:"")
|
||||
\define toc-linked-expandable-body(tag,sort:"")
|
||||
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
|
||||
<li>
|
||||
<$link>
|
||||
|
@ -41,15 +41,43 @@ tags: $:/tags/Macro
|
|||
</$set>
|
||||
\end
|
||||
|
||||
\define toc-unlinked-expandable-body(tag,sort:"")
|
||||
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
|
||||
<li>
|
||||
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
||||
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
||||
{{$:/core/images/right-arrow}}
|
||||
<$view field="caption">
|
||||
<$view field="title"/>
|
||||
</$view>
|
||||
</$button>
|
||||
</$reveal>
|
||||
<$reveal type="match" state=<<toc-state>> text="open">
|
||||
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
||||
{{$:/core/images/down-arrow}}
|
||||
<$view field="caption">
|
||||
<$view field="title"/>
|
||||
</$view>
|
||||
</$button>
|
||||
</$reveal>
|
||||
<$reveal type="match" state=<<toc-state>> text="open">
|
||||
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort="$sort$"/>
|
||||
</$reveal>
|
||||
</li>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
\define toc-expandable(tag,sort:"")
|
||||
<ol class="tc-toc toc-expandable">
|
||||
<$list filter="[tag[$tag$]$sort$]">
|
||||
<<toc-expandable-body tag:"$tag$" sort:"$sort$">>
|
||||
<$list filter="[is[current]toc-link[no]]" emptyMessage="<<toc-linked-expandable-body tag:'$tag$' sort:'$sort$'>>">
|
||||
<<toc-unlinked-expandable-body tag:"$tag$" sort:"$sort$">>
|
||||
</$list>
|
||||
</$list>
|
||||
</ol>
|
||||
\end
|
||||
|
||||
\define toc-selective-expandable-body(tag,sort:"")
|
||||
\define toc-linked-selective-expandable-body(tag,sort:"")
|
||||
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
|
||||
<li>
|
||||
<$link>
|
||||
|
@ -76,10 +104,40 @@ tags: $:/tags/Macro
|
|||
</$set>
|
||||
\end
|
||||
|
||||
\define toc-unlinked-selective-expandable-body(tag,sort:"")
|
||||
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
|
||||
<li>
|
||||
<$list filter="[all[current]tagging[]limit[1]]" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
|
||||
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
||||
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
||||
{{$:/core/images/right-arrow}}
|
||||
<$view field="caption">
|
||||
<$view field="title"/>
|
||||
</$view>
|
||||
</$button>
|
||||
</$reveal>
|
||||
<$reveal type="match" state=<<toc-state>> text="open">
|
||||
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
||||
{{$:/core/images/down-arrow}}
|
||||
<$view field="caption">
|
||||
<$view field="title"/>
|
||||
</$view>
|
||||
</$button>
|
||||
</$reveal>
|
||||
</$list>
|
||||
<$reveal type="match" state=<<toc-state>> text="open">
|
||||
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort="$sort$"/>
|
||||
</$reveal>
|
||||
</li>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
\define toc-selective-expandable(tag,sort:"")
|
||||
<ol class="tc-toc toc-selective-expandable">
|
||||
<$list filter="[tag[$tag$]$sort$]">
|
||||
<<toc-selective-expandable-body tag:"$tag$" sort:"$sort$">>
|
||||
<$list filter="[is[current]toc-link[no]]" emptyMessage="<<toc-linked-selective-expandable-body tag:'$tag$' sort:'$sort$'>>">
|
||||
<<toc-unlinked-selective-expandable-body tag:"$tag$" sort:"$sort$">>
|
||||
</$list>
|
||||
</$list>
|
||||
</ol>
|
||||
\end
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
title: TableOfContentsMacro
|
||||
tags: macros
|
||||
modified: 20140828080307785
|
||||
modified: 20140905084423561
|
||||
|
||||
The table of contents macro produces a hierarchical tree of tiddlers based on their tags.
|
||||
|
||||
The top level entries of the table of contents are defined by a root tag. The subentries under each of those entries are tagged with the title of the entry. Entries can be ordered using the `list` field as described in TiddlerTags. The text for each entry is taken from the ''caption'' field if it is present, otherwise the ''title'' is used.
|
||||
The top level entries of the table of contents are defined by a root tag. The subentries under each of those entries are tagged with the title of the entry. Entries can be ordered using the `list` field of the tag tiddler as described in TiddlerTags.
|
||||
|
||||
The text for each entry is taken from the ''caption'' field if it is present, otherwise the ''title'' is used.
|
||||
|
||||
Entries are rendered as a link to the corresponding tiddler unless the tiddler has the value ''no'' in the field ''toc-link''. In the examples below, the entry SecondThree is set up in this way to not appear as a link.
|
||||
|
||||
There are several variants of the macro:
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
title: SecondThree
|
||||
tags: Second
|
||||
list: SecondThreeOne SecondThreeTwo SecondThreeThree
|
||||
toc-link: no
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
Ładowanie…
Reference in New Issue