diff --git a/core/wiki/macros/toc.tid b/core/wiki/macros/toc.tid index 4c1356b20..a6c3148d1 100644 --- a/core/wiki/macros/toc.tid +++ b/core/wiki/macros/toc.tid @@ -1,226 +1,212 @@ title: $:/core/macros/toc tags: $:/tags/Macro - - -\define toc-open-icon() $:/core/images/down-arrow -\define toc-closed-icon() $:/core/images/right-arrow - - -\function makeTocState() [{_/state/toc/global}match[open]then[_/state/toc/global]] :else[[$:/state/toc]addsuffix<__path__>addsuffix[/]addsuffix] -\function makeTocState() [get[text]match[open]then[_/state/toc/global]] :else[[$:/state/toc]addsuffix<__path__>addsuffix[/]addsuffix] - - -\function makeTocState() [[$:/state/toc]addsuffix<__path__>addsuffix[/]addsuffix] - -\define toc-caption() \whitespace trim + + +\procedure toc-open-icon() $:/core/images/down-arrow +\procedure toc-closed-icon() $:/core/images/right-arrow + + +\function tf.makeTocState() [[$:/state/toc]addsuffixaddsuffix[/]addsuffix] + + +\procedure toc-caption() <$set name="tv-wikilinks" value="no"> - <$transclude field="caption"> - <$view field="title"/> - + <$transclude field="caption"> + <$view field="title"/> + \end -\define toc-body(tag,sort:"",itemClassFilter,exclude,path) -\whitespace trim + +\function tf.newPath() [addsuffix[/]addsuffix] + +\procedure toc-body(tag,sort:"",itemClassFilter,exclude,path)
    - <$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]"""> - <$let item=<> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}> - <$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]"> - <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item"> -
  1. >> - <$list filter="[all[current]toc-link[no]]" emptyMessage="<$link to={{{ [get[target]else] }}}><>"> - <> - - <$macrocall $name="toc-body" tag=<> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<> path=<>/> -
  2. - - - - + <$list filter=`[all[shadows+tiddlers]tag!has[draft.of]$(sort)$] -[] -[subfilter]`> + <$let item=<> path=<> > + <$set name="excluded" filter="[subfilter] []"> +
  3. >> + <% if [all[current]toc-link[no]] %> + <> + <% else %> + <$link to={{{ [get[target]else] }}}><> + <% endif %> + <$macrocall $name="toc-body" tag=<> sort=<> itemClassFilter=<> exclude=<> path=<>/> +
  4. + + +
\end -\define toc(tag,sort:"",itemClassFilter:"", exclude) -<$macrocall $name="toc-body" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>>/> +\procedure toc(tag,sort:"",itemClassFilter:"", exclude) +<$macrocall $name="toc-body" tag=<> sort=<> itemClassFilter=<> exclude=<>/> \end -\define toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path) -\whitespace trim - -<$qualify name="toc-state" title=<> > - <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item"> -
  • >> - <$link to={{{ [get[target]else] }}}> - <$reveal type="nomatch" stateTitle=<> text="open"> - <$button setTitle=<> setTo="open" class="tc-btn-invisible tc-popup-keep"> - <$transclude tiddler=<> /> - - - <$reveal type="match" stateTitle=<> text="open"> - <$button setTitle=<> setTo="close" class="tc-btn-invisible tc-popup-keep"> - <$transclude tiddler=<> /> - - - <> - - <$reveal type="match" stateTitle=<> text="open"> - <$macrocall $name="toc-expandable" tag=<> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>> path=<<__path__>>/> - -
  • - +\procedure toc-item(isUnlinked:"") + <$reveal type="nomatch" stateTitle=<> text="open"> + <$button setTitle=<> setTo="open" class="tc-btn-invisible tc-popup-keep"> + <$transclude tiddler=<> /> + <% if [match[yes]] %> + <> + <% endif %> + + + <$reveal type="match" stateTitle=<> text="open"> + <$button setTitle=<> setTo="close" class="tc-btn-invisible tc-popup-keep"> + <$transclude tiddler=<> /> + <% if [match[yes]] %> + <> + <% endif %> + + +\end + +\procedure toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path) +<$qualify name="toc-state" title=<> > +
  • >> + <$link to={{{ [get[target]else] }}}> + <> + <> + + <$reveal type="match" stateTitle=<> text="open"> + <$macrocall $name="toc-expandable" tag=<> sort=<> itemClassFilter=<> exclude=<> path=<>/> + +
  • \end -\define toc-unlinked-expandable-body(tag,sort:"",itemClassFilter,exclude,path) -\whitespace trim +\procedure toc-unlinked-expandable-body(tag,sort:"",itemClassFilter,exclude,path) -<$qualify name="toc-state" title=<>> - <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item"> -
  • >> - <$reveal type="nomatch" stateTitle=<> text="open"> - <$button setTitle=<> setTo="open" class="tc-btn-invisible tc-popup-keep"> - <$transclude tiddler=<> /> - <> - - - <$reveal type="match" stateTitle=<> text="open"> - <$button setTitle=<> setTo="close" class="tc-btn-invisible tc-popup-keep"> - <$transclude tiddler=<> /> - <> - - - <$reveal type="match" stateTitle=<> text="open"> - <$macrocall $name="toc-expandable" tag=<> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>> path=<<__path__>>/> - -
  • - +<$qualify name="toc-state" title=<>> +
  • >> + <> + <$reveal type="match" stateTitle=<> text="open"> + <$macrocall $name="toc-expandable" tag=<> sort=<> itemClassFilter=<> exclude=<> path=<>/> + +
  • \end -\define toc-expandable-empty-message() +\procedure toc-expandable-empty-message() <$macrocall $name="toc-linked-expandable-body" tag=<> sort=<> itemClassFilter=<> exclude=<> path=<>/> \end -\define toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path) -\whitespace trim -<$let tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}> - <$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]"> -
      - <$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]"""> - <$list filter="[all[current]toc-link[no]]" emptyMessage=<> > - <$macrocall $name="toc-unlinked-expandable-body" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter="""itemClassFilter""" exclude=<> path=<> /> - - -
    - +\procedure toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path) +<$let path=<>> + <$set name="excluded" filter="[subfilter] []"> +
      + <$list filter=`[all[shadows+tiddlers]tag!has[draft.of]$(sort)$] -[] -[subfilter]`> + <$list filter="[all[current]toc-link[no]]" emptyMessage=<> > + <$macrocall $name="toc-unlinked-expandable-body" tag=<> sort=<> itemClassFilter=<> exclude=<> path=<> /> + + +
    + \end -\define toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path) -\whitespace trim -<$qualify name="toc-state" title=<>> - <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item" > -
  • >> - <$link to={{{ [get[target]else] }}}> - <$list filter="[all[current]tagging[]$sort$limit[1]] -[subfilter<__exclude__>]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}"> - <$reveal type="nomatch" stateTitle=<> text="open"> - <$button setTitle=<> setTo="open" class="tc-btn-invisible tc-popup-keep"> - <$transclude tiddler=<> /> - - - <$reveal type="match" stateTitle=<> text="open"> - <$button setTitle=<> setTo="close" class="tc-btn-invisible tc-popup-keep"> - <$transclude tiddler=<> /> - - - - <> - - <$reveal type="match" stateTitle=<> text="open"> - <$macrocall $name="toc-selective-expandable" tag=<> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>> path=<<__path__>>/> - -
  • - +\procedure toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path) +<$qualify name="toc-state" title=<>> +
  • >> + <$link to={{{ [get[target]else] }}}> + <$list filter=`[all[current]tagging[]$(sort)$] -[subfilter] +[limit[1]]` variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}"> + <> + + <> + + <$reveal type="match" stateTitle=<> text="open"> + <$macrocall $name="toc-selective-expandable" tag=<> sort=<> itemClassFilter=<> exclude=<> path=<>/> + +
  • \end -\define toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path) -\whitespace trim -<$qualify name="toc-state" title=<> > - <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item"> -
  • >> - <$list filter="[all[current]tagging[]$sort$limit[1]] -[subfilter<__exclude__>]" variable="ignore" emptyMessage="""<$button class="tc-btn-invisible">{{$:/core/images/blank}}<>"""> - <$reveal type="nomatch" stateTitle=<> text="open"> - <$button setTitle=<> setTo="open" class="tc-btn-invisible tc-popup-keep"> - <$transclude tiddler=<> /> - <> - - - <$reveal type="match" stateTitle=<> text="open"> - <$button setTitle=<> setTo="close" class="tc-btn-invisible tc-popup-keep"> - <$transclude tiddler=<> /> - <> - - - - <$reveal type="match" stateTitle=<> text="open"> - <$macrocall $name="toc-selective-expandable" tag=<> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>> path=<<__path__>>/> - -
  • - + +\function tf.toc-getItemClass() [get[text]matchthen[toc-item-selected]else[toc-item]] + +\procedure toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path) +<$qualify name="toc-state" title=<> > +
  • >> + <$list filter=`[all[current]tagging[]$(sort)$] -[subfilter] +[limit[1]]` + variable="ignore" + emptyMessage="""<$button class="tc-btn-invisible">{{$:/core/images/blank}}<>""" + > + <> + + <$reveal type="match" stateTitle=<> text="open"> + <$macrocall $name="toc-selective-expandable" tag=<> sort=<> itemClassFilter=<> exclude=<> path=<>/> + +
  • \end -\define toc-selective-expandable-empty-message() +\procedure toc-selective-expandable-empty-message() <$macrocall $name="toc-linked-selective-expandable-body" tag=<> sort=<> itemClassFilter=<> exclude=<> path=<>/> \end -\define toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path) -\whitespace trim -<$let tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}> - <$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]"> -
      - <$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]"""> - <$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage=<> > - <$macrocall $name="toc-unlinked-selective-expandable-body" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<> path=<>/> - - -
    - +\procedure toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path) +<$let tag=<> sort=<> itemClassFilter=<> path=<>> + <$set name="excluded" filter="[subfilter] []"> +
      + <$list filter=`[all[shadows+tiddlers]tag!has[draft.of]$(sort)$] -[] -[subfilter]`> + <$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage=<> > + <$macrocall + $name="toc-unlinked-selective-expandable-body" + tag=<> sort=<> itemClassFilter=<> exclude=<> path=<> + /> + + +
    + \end -\define toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude) -\whitespace trim -<$tiddler tiddler={{{ [<__selectedTiddler__>get[text]] }}}> -
    - <$linkcatcher to=<<__selectedTiddler__>>> -
    - <$macrocall $name="toc-selective-expandable" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter="[all[current]] -[<__selectedTiddler__>get[text]]" exclude=<<__exclude__>>/> -
    - -
    - <$reveal stateTitle=<<__selectedTiddler__>> type="nomatch" text=""> - <$transclude mode="block" tiddler=<<__template__>>> -

    <>

    - <$transclude mode="block">$missingText$ - - - <$reveal stateTitle=<<__selectedTiddler__>> type="match" text=""> - $unselectedText$ - -
    -
    +\procedure toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude) +<$tiddler tiddler={{{ [get[text]] }}}> +
    + <$linkcatcher to=<>> +
    + + <$macrocall + $name="toc-selective-expandable" + tag=<> + sort=<> + itemClassFilter="[all[current]] -[get[text]]" + exclude=<> + /> +
    + +
    + <$reveal stateTitle=<> type="nomatch" text=""> + <$transclude mode="block" tiddler=<