mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-04 23:39:57 +00:00
allow tagField and parentField instead of tags
This commit is contained in:
parent
655f9616e8
commit
a2afdc8c96
@ -31,10 +31,9 @@ tags: $:/tags/Macro
|
|||||||
<!-- join the CSS definitions from above -->
|
<!-- join the CSS definitions from above -->
|
||||||
\function tf.toc-itemClass() [<tf.toc-itemClassFilter>] [<tf.toc-includeClass>] [<tf.toc-filterClass>] [<tf.toc-hideClass>] +[join[ ]]
|
\function tf.toc-itemClass() [<tf.toc-itemClassFilter>] [<tf.toc-includeClass>] [<tf.toc-filterClass>] [<tf.toc-hideClass>] +[join[ ]]
|
||||||
|
|
||||||
<!-- the following 3 functions need to use <currentTiddler> -->
|
<!-- the following functions need to use <currentTiddler> -->
|
||||||
\function tf.toc-getHideText() [<currentTiddler>get<toc-hide-field>]
|
\function tf.toc-getHideText() [<currentTiddler>get<toc-hide-field>]
|
||||||
\function tf.toc-hideIsYes() [<currentTiddler>format:titlelist[]]
|
\function tf.toc-hideIsYes() [<currentTiddler>format:titlelist[]]
|
||||||
|
|
||||||
<!-- Special case, if toc-hide field is "yes", we need a currentTiddler *titlelist* -- otherwise return the content as text -->
|
<!-- Special case, if toc-hide field is "yes", we need a currentTiddler *titlelist* -- otherwise return the content as text -->
|
||||||
\function tf.toc-hide() [<tf.toc-getHideText>match[yes]then<tf.toc-hideIsYes>] :else[<tf.toc-getHideText>]
|
\function tf.toc-hide() [<tf.toc-getHideText>match[yes]then<tf.toc-hideIsYes>] :else[<tf.toc-getHideText>]
|
||||||
|
|
||||||
@ -42,14 +41,25 @@ tags: $:/tags/Macro
|
|||||||
\function tf.toc-include() [<tag>get<toc-include-field>]
|
\function tf.toc-include() [<tag>get<toc-include-field>]
|
||||||
\function tf.toc-filter() [<tag>get<toc-filter-field>]
|
\function tf.toc-filter() [<tag>get<toc-filter-field>]
|
||||||
|
|
||||||
|
<!-- Use a field instead of a tag -->
|
||||||
|
\procedure toc-filterDefault() [all[shadows+tiddlers]tag<tag>!has[draft.of]]
|
||||||
|
\procedure toc-filterParent() [has<parentField>!has[draft.of]] :filter[get<parentField>match<tag>]
|
||||||
|
\procedure toc-filterTagLike() [<tag>get<tagField>enlist-input[]]
|
||||||
|
|
||||||
|
<!-- activate the filterString depending on tagField, parentField or default. tagField takes precedence -->
|
||||||
|
\function tf.toc-filterString() [<tagField>!is[blank]then<toc-filterTagLike>] :else[<parentField>!is[blank]then<toc-filterParent>else<toc-filterDefault>]
|
||||||
|
|
||||||
<!-- define unique path based state title -->
|
<!-- define unique path based state title -->
|
||||||
\function tf.toc-newPath() [<path>addsuffix[/]addsuffix<tag>]
|
\function tf.toc-newPath() [<path>addsuffix[/]addsuffix<tag>]
|
||||||
|
|
||||||
|
<!-- toc helper -->
|
||||||
\procedure toc-body(tag,sort:"",itemClassFilter,exclude,path)
|
\procedure toc-body(tag,sort:"",itemClassFilter,exclude,path)
|
||||||
|
<!-- Be aware: if parentField is set, the "tag" parameter contains the currentTiddler -->
|
||||||
|
<$set name=currentTiddler filter="[<parentField>!is[blank]then<tag>else<currentTiddler>]">
|
||||||
<ol class="tc-toc">
|
<ol class="tc-toc">
|
||||||
<!-- text substitution is needed for backwards compatibility -->
|
<!-- text substitution is needed for backwards compatibility -->
|
||||||
<$list filter=` [subfilter<tf.toc-filter>]
|
<$list filter=` [subfilter<tf.toc-filter>]
|
||||||
:else[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$]
|
:else[subfilter<tf.toc-filterString>$(sort)$]
|
||||||
[subfilter<tf.toc-include>] -[<tag>] -[subfilter<exclude>]`>
|
[subfilter<tf.toc-include>] -[<tag>] -[subfilter<exclude>]`>
|
||||||
<%if [<currentTiddler>] -[subfilter<tf.toc-hide>] %>
|
<%if [<currentTiddler>] -[subfilter<tf.toc-hide>] %>
|
||||||
<$let item=<<currentTiddler>> _path=<<tf.toc-newPath>> >
|
<$let item=<<currentTiddler>> _path=<<tf.toc-newPath>> >
|
||||||
@ -75,13 +85,16 @@ tags: $:/tags/Macro
|
|||||||
</$list>
|
</$list>
|
||||||
</ol>
|
</ol>
|
||||||
\end
|
\end
|
||||||
|
<!-- -->
|
||||||
|
<!-- <$log tag=<<tag>> parentField=<<parentField>> toc-filter=<<toc-filter>> ct=<<currentTiddler>> captionField=<<captionField>>/> -->
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
<!-- =============================================================
|
<!-- =============================================================
|
||||||
Simple toc macro which alwayse shows the full tree
|
Simple toc macro which alwayse shows the full tree
|
||||||
This macro is _not_ used by other toc-macros
|
This macro is _not_ used by other toc-macros
|
||||||
v5.3.4 itemClassFilter has been replaced by tf.toc-itemClassFilter
|
v5.3.4 itemClassFilter has been replaced by tf.toc-itemClassFilter
|
||||||
================================================================== -->
|
================================================================== -->
|
||||||
\procedure toc(tag, sort:"", itemClassFilter, exclude, captionField, captionFieldTemplate)
|
\procedure toc(tag, sort:"", itemClassFilter, exclude, tagField, parentField, captionField, captionFieldTemplate)
|
||||||
<$macrocall $name="toc-body" tag=<<tag>> sort=<<sort>> exclude=<<exclude>>/>
|
<$macrocall $name="toc-body" tag=<<tag>> sort=<<sort>> exclude=<<exclude>>/>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
created: 20140919155729620
|
created: 20140919155729620
|
||||||
modified: 20240206175037389
|
modified: 20240206175448578
|
||||||
tags: Macros [[Core Macros]]
|
tags: Macros [[Core Macros]]
|
||||||
title: Table-of-Contents Macros
|
title: Table-of-Contents Macros
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
@ -65,7 +65,7 @@ The difference between the last two has to do with what happens when the user cl
|
|||||||
; template
|
; template
|
||||||
: Optionally, the title of a tiddler to use as a [[template|TemplateTiddlers]] for transcluding the selected tiddler into the right-hand panel
|
: Optionally, the title of a tiddler to use as a [[template|TemplateTiddlers]] for transcluding the selected tiddler into the right-hand panel
|
||||||
|
|
||||||
!! Structure
|
!! Tiddler Fields
|
||||||
|
|
||||||
The top level of the tree consists of the tiddlers that carry a particular tag, known as the <<.def "root tag">>. Tiddlers tagged with any of those make up the next level down, and so on.
|
The top level of the tree consists of the tiddlers that carry a particular tag, known as the <<.def "root tag">>. Tiddlers tagged with any of those make up the next level down, and so on.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user