From a2afdc8c966aa7e886d2729b01d3a6302b62537f Mon Sep 17 00:00:00 2001 From: pmario Date: Wed, 7 Feb 2024 01:25:12 +0100 Subject: [PATCH] allow tagField and parentField instead of tags --- core/wiki/macros/toc.tid | 41 ++++++++++++------- .../tiddlers/macros/TableOfContentsMacro.tid | 4 +- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/core/wiki/macros/toc.tid b/core/wiki/macros/toc.tid index abf4505be..2c1e172da 100644 --- a/core/wiki/macros/toc.tid +++ b/core/wiki/macros/toc.tid @@ -19,37 +19,47 @@ tags: $:/tags/Macro \procedure toc-open-icon() $:/core/images/down-arrow \procedure toc-closed-icon() $:/core/images/right-arrow -\procedure toc-hide-field() toc-hide +\procedure toc-hide-field() toc-hide \procedure toc-include-field() toc-include -\procedure toc-filter-field() toc-filter +\procedure toc-filter-field() toc-filter \function tf.toc-itemClassFilter() [get[text]matchthen[toc-item-selected]else[toc-item]] -\function tf.toc-includeClass() [subfiltermatchthen[toc-item-include]] -\function tf.toc-filterClass() [subfiltermatchthen[toc-item-filter]] -\function tf.toc-hideClass() [!is[blank]then[toc-item-hide]] +\function tf.toc-includeClass() [subfiltermatchthen[toc-item-include]] +\function tf.toc-filterClass() [subfiltermatchthen[toc-item-filter]] +\function tf.toc-hideClass() [!is[blank]then[toc-item-hide]] -\function tf.toc-itemClass() [] [] [] [] +[join[ ]] +\function tf.toc-itemClass() [] [] [] [] +[join[ ]] - + \function tf.toc-getHideText() [get] -\function tf.toc-hideIsYes() [format:titlelist[]] - +\function tf.toc-hideIsYes() [format:titlelist[]] -\function tf.toc-hide() [match[yes]then] :else[] +\function tf.toc-hide() [match[yes]then] :else[] -\function tf.toc-include() [get] -\function tf.toc-filter() [get] +\function tf.toc-include() [get] +\function tf.toc-filter() [get] + + +\procedure toc-filterDefault() [all[shadows+tiddlers]tag!has[draft.of]] +\procedure toc-filterParent() [has!has[draft.of]] :filter[getmatch] +\procedure toc-filterTagLike() [getenlist-input[]] + + +\function tf.toc-filterString() [!is[blank]then] :else[!is[blank]thenelse] \function tf.toc-newPath() [addsuffix[/]addsuffix] + \procedure toc-body(tag,sort:"",itemClassFilter,exclude,path) + +<$set name=currentTiddler filter="[!is[blank]thenelse]">
    <$list filter=` [subfilter] - :else[all[shadows+tiddlers]tag!has[draft.of]$(sort)$] + :else[subfilter$(sort)$] [subfilter] -[] -[subfilter]`> <%if [] -[subfilter] %> <$let item=<> _path=<> > @@ -75,13 +85,16 @@ tags: $:/tags/Macro
\end + + + -\procedure toc(tag, sort:"", itemClassFilter, exclude, captionField, captionFieldTemplate) +\procedure toc(tag, sort:"", itemClassFilter, exclude, tagField, parentField, captionField, captionFieldTemplate) <$macrocall $name="toc-body" tag=<> sort=<> exclude=<>/> \end diff --git a/editions/tw5.com/tiddlers/macros/TableOfContentsMacro.tid b/editions/tw5.com/tiddlers/macros/TableOfContentsMacro.tid index 675a469be..f8170f823 100644 --- a/editions/tw5.com/tiddlers/macros/TableOfContentsMacro.tid +++ b/editions/tw5.com/tiddlers/macros/TableOfContentsMacro.tid @@ -1,5 +1,5 @@ created: 20140919155729620 -modified: 20240206175037389 +modified: 20240206175448578 tags: Macros [[Core Macros]] title: Table-of-Contents Macros 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 : 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.