mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
Toc recursion protection (#2650)
* add recursion protection first take * fix problem with selectable expand * ust path for toc-state variable instead of tag * reactivate disabled macro call.
This commit is contained in:
parent
66a13cb915
commit
e1053bf014
@ -3,164 +3,166 @@ tags: $:/tags/Macro
|
|||||||
|
|
||||||
\define toc-caption()
|
\define toc-caption()
|
||||||
<$set name="tv-wikilinks" value="no">
|
<$set name="tv-wikilinks" value="no">
|
||||||
<$transclude field="caption">
|
<$transclude field="caption">
|
||||||
<$view field="title"/>
|
<$view field="title"/>
|
||||||
</$transclude>
|
</$transclude>
|
||||||
</$set>
|
</$set>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-body(rootTag,tag,sort:"",itemClassFilter)
|
\define toc-body(tag,sort:"",itemClassFilter,exclude,path)
|
||||||
<ol class="tc-toc">
|
<ol class="tc-toc">
|
||||||
<$list filter="""[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$]""">
|
<$list filter="""[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$] $exclude$""">
|
||||||
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
|
<$vars item=<<currentTiddler>> path="""$path$/$tag$""" excluded="""$exclude$ -[[$tag$]]""">
|
||||||
<li class=<<toc-item-class>>>
|
<$set name="toc-item-class" filter="""$itemClassFilter$""" emptyValue="toc-item" value="toc-item-selected">
|
||||||
<$list filter="[all[current]toc-link[no]]" emptyMessage="<$link><$view field='caption'><$view field='title'/></$view></$link>">
|
<li class=<<toc-item-class>>>
|
||||||
<<toc-caption>>
|
<$list filter="[all[current]toc-link[no]]" emptyMessage="<$link><$view field='caption'><$view field='title'/></$view></$link>">
|
||||||
</$list>
|
<<toc-caption>>
|
||||||
<$list filter="""[all[current]] -[[$rootTag$]]""">
|
</$list>
|
||||||
<$macrocall $name="toc-body" rootTag="""$rootTag$""" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
|
<$macrocall $name="toc-body" tag=<<item>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" exclude=<<excluded>> path=<<path>>/>
|
||||||
</$list>
|
</li>
|
||||||
</li>
|
</$set>
|
||||||
</$set>
|
</$vars>
|
||||||
</$list>
|
</$list>
|
||||||
</ol>
|
</ol>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc(tag,sort:"",itemClassFilter)
|
\define toc(tag,sort:"",itemClassFilter:" ")
|
||||||
<<toc-body rootTag:"""$tag$""" tag:"""$tag$""" sort:"""$sort$""" itemClassFilter:"""itemClassFilter""">>
|
<<toc-body tag:"""$tag$""" sort:"""$sort$""" itemClassFilter:"""$itemClassFilter$""">>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-linked-expandable-body(tag,sort:"",itemClassFilter)
|
\define toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
||||||
<$set name="toc-state" value=<<qualify """$:/state/toc/$tag$-$(currentTiddler)$""">>>
|
<!-- helper function -->
|
||||||
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
|
<$set name="toc-state" value=<<qualify """$:/state/toc$path$-$(currentTiddler)$""">>>
|
||||||
<li class=<<toc-item-class>>>
|
<$set name="toc-item-class" filter="""$itemClassFilter$""" emptyValue="toc-item" value="toc-item-selected">
|
||||||
<$link>
|
<li class=<<toc-item-class>>>
|
||||||
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
<$link>
|
||||||
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
||||||
{{$:/core/images/right-arrow}}
|
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
||||||
</$button>
|
{{$:/core/images/right-arrow}}
|
||||||
</$reveal>
|
</$button>
|
||||||
<$reveal type="match" state=<<toc-state>> text="open">
|
</$reveal>
|
||||||
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
<$reveal type="match" state=<<toc-state>> text="open">
|
||||||
{{$:/core/images/down-arrow}}
|
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
||||||
</$button>
|
{{$:/core/images/down-arrow}}
|
||||||
</$reveal>
|
</$button>
|
||||||
<<toc-caption>>
|
</$reveal>
|
||||||
</$link>
|
<<toc-caption>>
|
||||||
<$reveal type="match" state=<<toc-state>> text="open">
|
</$link>
|
||||||
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
|
<$reveal type="match" state=<<toc-state>> text="open">
|
||||||
</$reveal>
|
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" exclude="""$exclude$""" path="""$path$"""/>
|
||||||
</li>
|
</$reveal>
|
||||||
</$set>
|
</li>
|
||||||
|
</$set>
|
||||||
</$set>
|
</$set>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-unlinked-expandable-body(tag,sort:"",itemClassFilter)
|
\define toc-unlinked-expandable-body(tag,sort:"",itemClassFilter:" ",exclude,path)
|
||||||
<$set name="toc-state" value=<<qualify """$:/state/toc/$tag$-$(currentTiddler)$""">>>
|
<!-- helper function -->
|
||||||
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
|
<$set name="toc-state" value=<<qualify """$:/state/toc$path$-$(currentTiddler)$""">>>
|
||||||
<li class=<<toc-item-class>>>
|
<$set name="toc-item-class" filter="""$itemClassFilter$""" emptyValue="toc-item" value="toc-item-selected">
|
||||||
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
<li class=<<toc-item-class>>>
|
||||||
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
||||||
{{$:/core/images/right-arrow}}
|
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
||||||
<<toc-caption>>
|
{{$:/core/images/right-arrow}}
|
||||||
</$button>
|
<<toc-caption>>
|
||||||
</$reveal>
|
</$button>
|
||||||
<$reveal type="match" state=<<toc-state>> text="open">
|
</$reveal>
|
||||||
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
<$reveal type="match" state=<<toc-state>> text="open">
|
||||||
{{$:/core/images/down-arrow}}
|
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
||||||
<<toc-caption>>
|
{{$:/core/images/down-arrow}}
|
||||||
</$button>
|
<<toc-caption>>
|
||||||
</$reveal>
|
</$button>
|
||||||
<$reveal type="match" state=<<toc-state>> text="open">
|
</$reveal>
|
||||||
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
|
<$reveal type="match" state=<<toc-state>> text="open">
|
||||||
</$reveal>
|
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" exclude="""$exclude$""" path="""$path$"""/>
|
||||||
</li>
|
</$reveal>
|
||||||
</$set>
|
</li>
|
||||||
|
</$set>
|
||||||
</$set>
|
</$set>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-expandable-empty-message()
|
\define toc-expandable-empty-message()
|
||||||
<<toc-linked-expandable-body tag:"""$(tag)$""" sort:"""$(sort)$""" itemClassFilter:"""$(itemClassFilter)$""">>
|
<<toc-linked-expandable-body tag:"""$(tag)$""" sort:"""$(sort)$""" itemClassFilter:"""$(itemClassFilter)$""" exclude:"""$(excluded)$""" path:"""$(path)$""">>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-expandable(tag,sort:"",itemClassFilter)
|
\define toc-expandable(tag,sort:"",itemClassFilter:" ",exclude,path)
|
||||||
<$vars tag="""$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$""">
|
<$vars tag="""$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" excluded="""$exclude$ -[[$tag$]]""" path="""$path$/$tag$""">
|
||||||
<ol class="tc-toc toc-expandable">
|
<ol class="tc-toc toc-expandable">
|
||||||
<$list filter="[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$]">
|
<$list filter="""[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$] $exclude$""">
|
||||||
<$list filter="[all[current]toc-link[no]]" emptyMessage=<<toc-expandable-empty-message>>>
|
<$list filter="[all[current]toc-link[no]]" emptyMessage=<<toc-expandable-empty-message>> >
|
||||||
<<toc-unlinked-expandable-body tag:"""$tag$""" sort:"""$sort$""" itemClassFilter:"""itemClassFilter""">>
|
<$macrocall $name="toc-unlinked-expandable-body" tag="""$tag$""" sort="""$sort$""" itemClassFilter="""itemClassFilter""" exclude=<<excluded>> path=<<path>> />
|
||||||
</$list>
|
</$list>
|
||||||
</$list>
|
</$list>
|
||||||
</ol>
|
</ol>
|
||||||
</$vars>
|
</$vars>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter)
|
\define toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter:" ",exclude,path)
|
||||||
<$set name="toc-state" value=<<qualify """$:/state/toc/$tag$-$(currentTiddler)$""">>>
|
<$set name="toc-state" value=<<qualify """$:/state/toc$path$-$(currentTiddler)$""">>>
|
||||||
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
|
<$set name="toc-item-class" filter="""$itemClassFilter$""" emptyValue="toc-item" value="toc-item-selected" >
|
||||||
<li class=<<toc-item-class>>>
|
<li class=<<toc-item-class>>>
|
||||||
<$link>
|
<$link>
|
||||||
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
|
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
|
||||||
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
||||||
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
||||||
{{$:/core/images/right-arrow}}
|
{{$:/core/images/right-arrow}}
|
||||||
</$button>
|
</$button>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
<$reveal type="match" state=<<toc-state>> text="open">
|
<$reveal type="match" state=<<toc-state>> text="open">
|
||||||
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
||||||
{{$:/core/images/down-arrow}}
|
{{$:/core/images/down-arrow}}
|
||||||
</$button>
|
</$button>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
</$list>
|
</$list>
|
||||||
<<toc-caption>>
|
<<toc-caption>>
|
||||||
</$link>
|
</$link>
|
||||||
<$reveal type="match" state=<<toc-state>> text="open">
|
<$reveal type="match" state=<<toc-state>> text="open">
|
||||||
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
|
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" exclude="""$exclude$""" path="""$path$"""/>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
</li>
|
</li>
|
||||||
</$set>
|
</$set>
|
||||||
</$set>
|
</$set>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter)
|
\define toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter:" ",exclude,path)
|
||||||
<$set name="toc-state" value=<<qualify """$:/state/toc/$tag$-$(currentTiddler)$""">>>
|
<$set name="toc-state" value=<<qualify """$:/state/toc$path$-$(currentTiddler)$""">>>
|
||||||
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
|
<$set name="toc-item-class" filter="""$itemClassFilter$""" emptyValue="toc-item" value="toc-item-selected">
|
||||||
<li class=<<toc-item-class>>>
|
<li class=<<toc-item-class>>>
|
||||||
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button> <$view field='caption'><$view field='title'/></$view>">
|
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button> <$view field='caption'><$view field='title'/></$view>">
|
||||||
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
<$reveal type="nomatch" state=<<toc-state>> text="open">
|
||||||
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
|
||||||
{{$:/core/images/right-arrow}}
|
{{$:/core/images/right-arrow}}
|
||||||
<<toc-caption>>
|
<<toc-caption>>
|
||||||
</$button>
|
</$button>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
<$reveal type="match" state=<<toc-state>> text="open">
|
<$reveal type="match" state=<<toc-state>> text="open">
|
||||||
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
|
||||||
{{$:/core/images/down-arrow}}
|
{{$:/core/images/down-arrow}}
|
||||||
<<toc-caption>>
|
<<toc-caption>>
|
||||||
</$button>
|
</$button>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
</$list>
|
</$list>
|
||||||
<$reveal type="match" state=<<toc-state>> text="open">
|
<$reveal type="match" state=<<toc-state>> text="open">
|
||||||
<$macrocall $name="""toc-selective-expandable""" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
|
<$macrocall $name="""toc-selective-expandable""" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" exclude="""$exclude$""" path="""$path$"""/>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
</li>
|
</li>
|
||||||
</$set>
|
</$set>
|
||||||
</$set>
|
</$set>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-selective-expandable-empty-message()
|
\define toc-selective-expandable-empty-message()
|
||||||
<<toc-linked-selective-expandable-body tag:"""$(tag)$""" sort:"""$(sort)$""" itemClassFilter:"""$(itemClassFilter)$""">>
|
<<toc-linked-selective-expandable-body tag:"""$(tag)$""" sort:"""$(sort)$""" itemClassFilter:"""$(itemClassFilter)$""" exclude:"""$(excluded)$""" path:"""$(path)$""">>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-selective-expandable(tag,sort:"",itemClassFilter)
|
\define toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path)
|
||||||
<$vars tag="""$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$""">
|
<$vars tag="""$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" excluded="""$exclude$ -[[$tag$]]""" path="""$path$/$tag$""">
|
||||||
<ol class="tc-toc toc-selective-expandable">
|
<ol class="tc-toc toc-selective-expandable">
|
||||||
<$list filter="[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$]">
|
<$list filter="""[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$] $exclude$""">
|
||||||
<$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage=<<toc-selective-expandable-empty-message>>>
|
<$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage=<<toc-selective-expandable-empty-message>> >
|
||||||
<<toc-unlinked-selective-expandable-body tag:"""$tag$""" sort:"""$sort$""" itemClassFilter:"""$itemClassFilter$""">>
|
<$macrocall $name=toc-unlinked-selective-expandable-body tag="""$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" exclude=<<excluded>> path=<<path>> >
|
||||||
</$list>
|
</$list>
|
||||||
</$list>
|
</$list>
|
||||||
</ol>
|
</ol>
|
||||||
</$vars>
|
</$vars>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
@ -170,30 +172,30 @@ tags: $:/tags/Macro
|
|||||||
|
|
||||||
\define toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"")
|
\define toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"")
|
||||||
<$tiddler tiddler={{$selectedTiddler$}}>
|
<$tiddler tiddler={{$selectedTiddler$}}>
|
||||||
<div class="tc-tabbed-table-of-contents">
|
<div class="tc-tabbed-table-of-contents">
|
||||||
<$linkcatcher to="$selectedTiddler$">
|
<$linkcatcher to="$selectedTiddler$">
|
||||||
<div class="tc-table-of-contents">
|
<div class="tc-table-of-contents">
|
||||||
<$macrocall $name="toc-selective-expandable" tag="""$tag$""" sort="""$sort$""" itemClassFilter=<<toc-tabbed-selected-item-filter selectedTiddler:"""$selectedTiddler$""">>/>
|
<$macrocall $name="toc-selective-expandable" tag="""$tag$""" sort="""$sort$""" itemClassFilter=<<toc-tabbed-selected-item-filter selectedTiddler:"""$selectedTiddler$""">>/>
|
||||||
</div>
|
</div>
|
||||||
</$linkcatcher>
|
</$linkcatcher>
|
||||||
<div class="tc-tabbed-table-of-contents-content">
|
<div class="tc-tabbed-table-of-contents-content">
|
||||||
<$reveal state="""$selectedTiddler$""" type="nomatch" text="">
|
<$reveal state="""$selectedTiddler$""" type="nomatch" text="">
|
||||||
<$transclude mode="block" tiddler="$template$">
|
<$transclude mode="block" tiddler="$template$">
|
||||||
<h1><<toc-caption>></h1>
|
<h1><<toc-caption>></h1>
|
||||||
<$transclude mode="block">$missingText$</$transclude>
|
<$transclude mode="block">$missingText$</$transclude>
|
||||||
</$transclude>
|
</$transclude>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
<$reveal state="""$selectedTiddler$""" type="match" text="">
|
<$reveal state="""$selectedTiddler$""" type="match" text="">
|
||||||
$unselectedText$
|
$unselectedText$
|
||||||
</$reveal>
|
</$reveal>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</$tiddler>
|
</$tiddler>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
\define toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"")
|
\define toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"")
|
||||||
<$linkcatcher to="""$selectedTiddler$""">
|
<$linkcatcher to="""$selectedTiddler$""">
|
||||||
<$macrocall $name="toc-tabbed-external-nav" tag="""$tag$""" sort="""$sort$""" selectedTiddler="""$selectedTiddler$""" unselectedText="""$unselectedText$""" missingText="""$missingText$""" template="""$template$"""/>
|
<$macrocall $name="toc-tabbed-external-nav" tag="""$tag$""" sort="""$sort$""" selectedTiddler="""$selectedTiddler$""" unselectedText="""$unselectedText$""" missingText="""$missingText$""" template="""$template$"""/>
|
||||||
</$linkcatcher>
|
</$linkcatcher>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user