1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-07 07:50:26 +00:00

add internal variable prefixes to __exclude and __path to make the code less error prone

This commit is contained in:
pmario 2024-02-02 00:42:40 +01:00
parent 0639c0b728
commit 84167ed1e9

View File

@ -7,7 +7,7 @@ tags: $:/tags/Macro
\procedure toc-open-icon() $:/core/images/down-arrow \procedure toc-open-icon() $:/core/images/down-arrow
\procedure toc-closed-icon() $:/core/images/right-arrow \procedure toc-closed-icon() $:/core/images/right-arrow
<!-- v5.3.4 complrete rewrite --> <!-- v5.3.4 complete rewrite -->
\function tf.toc-stateTitle() [[$:/state/toc]] [<path>] "/" [<currentTiddler>] +[join[]] \function tf.toc-stateTitle() [[$:/state/toc]] [<path>] "/" [<currentTiddler>] +[join[]]
\function tf.toc-newPath() [<path>addsuffix[/]addsuffix<tag>] \function tf.toc-newPath() [<path>addsuffix[/]addsuffix<tag>]
@ -17,11 +17,11 @@ tags: $:/tags/Macro
\procedure toc-caption() \procedure toc-caption()
<span class="tc-toc-caption tc-tiny-gap-left"> <span class="tc-toc-caption tc-tiny-gap-left">
<$set name="tv-wikilinks" value="no"> <$let name="tv-wikilinks" value="no">
<$transclude field="caption"> <$transclude field="caption">
<$view field="title"/> <$view field="title"/>
</$transclude> </$transclude>
</$set> </$let>
</span> </span>
\end \end
@ -29,19 +29,20 @@ tags: $:/tags/Macro
<ol class="tc-toc"> <ol class="tc-toc">
<!-- text substitution is needed for backwards compatibility --> <!-- text substitution is needed for backwards compatibility -->
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`> <$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
<$let item=<<currentTiddler>> path=<<tf.toc-newPath>> > <$let item=<<currentTiddler>> __path=<<tf.toc-newPath>> >
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]"> <$set name="__excluded" filter="[subfilter<exclude>] [<tag>]">
<li class=<<tf.toc-getItemClass>>> <li class=<<tf.toc-getItemClass>>>
<% if [all[current]toc-link[no]] %> <% if [all[current]toc-link[no]] %>
<<toc-caption>> <<toc-caption>>
<% else %> <% else %>
<!-- v5.1.23 use target-field if present in tiddler -->
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}> <$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
<<toc-caption>> <<toc-caption>>
</$link> </$link>
<% endif %> <% endif %>
<$macrocall <$macrocall
$name="toc-body" $name="toc-body"
tag=<<item>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>> tag=<<item>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<__excluded>> path=<<__path>>
/> />
</li> </li>
</$set> </$set>
@ -64,26 +65,27 @@ This macro is _not_ used by other toc-macros
If a toc-item should not show a link, the toc-caption is part of the button. So it can be clicked to open / close the branch If a toc-item should not show a link, the toc-caption is part of the button. So it can be clicked to open / close the branch
--> -->
\procedure toc-item(isUnlinked:"") \procedure toc-item(isUnlinked:"")
<% if [<toc-state>get[text]else[close]match[close]] %> <% if [<toc-state>get[text]else[close]match[close]] %>
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep" tooltip=<<toc-state>>> <$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep" tooltip=<<toc-state>>>
<$transclude tiddler=<<toc-closed-icon>> /> <$transclude tiddler=<<toc-closed-icon>> />
<% if [<isUnlinked>match[yes]] %> <% if [<isUnlinked>match[yes]] %>
<<toc-caption>> <<toc-caption>>
<% endif %> <% endif %>
</$button> </$button>
<% elseif [<toc-state>get[text]match[open]] %> <% elseif [<toc-state>get[text]match[open]] %>
<$button setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible tc-popup-keep" tooltip=<<toc-state>>> <$button setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible tc-popup-keep" tooltip=<<toc-state>>>
<$transclude tiddler=<<toc-open-icon>> /> <$transclude tiddler=<<toc-open-icon>> />
<% if [<isUnlinked>match[yes]] %> <% if [<isUnlinked>match[yes]] %>
<<toc-caption>> <<toc-caption>>
<% endif %> <% endif %>
</$button> </$button>
<% endif %> <% endif %>
\end \end
\procedure toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path) \procedure toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>> > <$qualify name="toc-state" title=<<tf.toc-stateTitle>> >
<li class=<<tf.toc-getItemClass>>> <li class=<<tf.toc-getItemClass>>>
<!-- v5.1.23 use target-field if present in tiddler -->
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}> <$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
<<toc-item>> <<toc-item>>
<<toc-caption>> <<toc-caption>>
@ -118,20 +120,20 @@ This macro is _not_ used by other toc-macros
Shows an expandable toc. Item always have an open/close chevron Shows an expandable toc. Item always have an open/close chevron
=============================================================== --> =============================================================== -->
\procedure toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path) \procedure toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path)
<$let path=<<tf.toc-newPath>>> <$let __path=<<tf.toc-newPath>>>
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]"> <$set name="__excluded" filter="[subfilter<exclude>] [<tag>]">
<ol class="tc-toc toc-expandable"> <ol class="tc-toc toc-expandable">
<!-- text substitution is needed for backwards compatibility --> <!-- text substitution is needed for backwards compatibility -->
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`> <$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
<% if [all[current]toc-link[no]] %> <% if [all[current]toc-link[no]] %>
<$macrocall <$macrocall
$name="toc-unlinked-expandable-body" $name="toc-unlinked-expandable-body"
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>> tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<__excluded>> path=<<__path>>
/> />
<% else %> <% else %>
<$macrocall <$macrocall
$name="toc-linked-expandable-body" $name="toc-linked-expandable-body"
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>> tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<__excluded>> path=<<__path>>
/> />
<% endif %> <% endif %>
</$list> </$list>
@ -143,6 +145,7 @@ Shows an expandable toc. Item always have an open/close chevron
\procedure toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path) \procedure toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>>> <$qualify name="toc-state" title=<<tf.toc-stateTitle>>>
<li class=<<tf.toc-getItemClass>>> <li class=<<tf.toc-getItemClass>>>
<!-- v5.1.23 use target-field if present in tiddler -->
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}> <$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
<% if [all[current]tagging[]] -[subfilter<exclude>] +[limit[1]] %> <% if [all[current]tagging[]] -[subfilter<exclude>] +[limit[1]] %>
<<toc-item>> <<toc-item>>
@ -193,20 +196,20 @@ Shows a selctive expandable toc.
If an item has no children, there is no open/close chevron If an item has no children, there is no open/close chevron
========================================================== --> ========================================================== -->
\procedure toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path) \procedure toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path)
<$let tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> path=<<tf.toc-newPath>>> <$let __path=<<tf.toc-newPath>>>
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]"> <$set name="__excluded" filter="[subfilter<exclude>] [<tag>]">
<ol class="tc-toc toc-selective-expandable"> <ol class="tc-toc toc-selective-expandable">
<!-- text substitution is needed for backwards compatibility --> <!-- text substitution is needed for backwards compatibility -->
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`> <$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
<% if [all[current]toc-link[no]] %> <% if [all[current]toc-link[no]] %>
<$macrocall <$macrocall
$name="toc-unlinked-selective-expandable-body" $name="toc-unlinked-selective-expandable-body"
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>> tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<__excluded>> path=<<__path>>
/> />
<% else %> <% else %>
<$macrocall <$macrocall
$name="toc-linked-selective-expandable-body" $name="toc-linked-selective-expandable-body"
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>> tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<__excluded>> path=<<__path>>
/> />
<% endif %> <% endif %>
</$list> </$list>