From f373d8f2bfe321fc242bcf881ba37f6baee2c999 Mon Sep 17 00:00:00 2001 From: Adrian Morosanu Date: Mon, 19 Nov 2018 12:50:09 +0200 Subject: [PATCH] Tree macro - fix for double quotes (and other special characters) (#3552) * Added fixes for special characters (e.g. double quotes) (including @BurningTreeC and @Jermolene suggestions) * Removed a lot of redundant code * Set a default value for "tree" macro prefix parameter ($:/) --- core/wiki/macros/tree.tid | 58 +++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/core/wiki/macros/tree.tid b/core/wiki/macros/tree.tid index 8cba3339b..d47c1fbc4 100644 --- a/core/wiki/macros/tree.tid +++ b/core/wiki/macros/tree.tid @@ -1,53 +1,57 @@ title: $:/core/macros/tree tags: $:/tags/Macro -\define leaf-node(prefix) +\define leaf-link(full-title, chunk) +<$link to=<<__full-title__>>><$text text=<<__chunk__>>/> +\end + +\define leaf-node(prefix, chunk)
  • -<$list filter="""[[$prefix$$(chunk)$]is[shadow]] [[$prefix$$(chunk)$]is[tiddler]] +[removeprefix[$prefix$]] +[limit[1]]""" -emptyMessage="""<$text text="$prefix$$(chunk)$"/>"""> -{{$:/core/images/file}} <$link to="""$prefix$$(chunk)$"""> -<$view field="title"/> - +<$list filter="[<__prefix__>addsuffix<__chunk__>is[shadow]] [<__prefix__>addsuffix<__chunk__>is[tiddler]]" variable="full-title"> +<$list filter="[removeprefix<__prefix__>]" variable="chunk"> +{{$:/core/images/file}} <$macrocall $name="leaf-link" full-title=<> chunk=<>/> +
  • \end -\define branch-node(prefix) -<$reveal type="nomatch" text="" default="""$(chunk)$"""> -
  • -<$list filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]] +[limit[1]]"""> -<$reveal type="nomatch" stateTitle="""$:/state/tree/$prefix$$(chunk)$""" text="show"> -<$button setTitle="""$:/state/tree/$prefix$$(chunk)$""" setTo="show" class="tc-btn-invisible">{{$:/core/images/folder}} <$text text="""$(chunk)$"""/> +\define branch-node(prefix, chunk) +
  • +<$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<__prefix__>addsuffix<__chunk__>] }}}> +<$reveal type="nomatch" stateTitle=<> text="show"> +<$button setTitle=<> setTo="show" class="tc-btn-invisible"> +{{$:/core/images/folder}} <$text text=<<__chunk__>>/> + -<$reveal type="match" stateTitle="""$:/state/tree/$prefix$$(chunk)$""" text="show"> -<$button setTitle="""$:/state/tree/$prefix$$(chunk)$""" setTo="hide" class="tc-btn-invisible">{{$:/core/images/folder}} <$text text="""$(chunk)$"""/> +<$reveal type="match" stateTitle=<> text="show"> +<$button setTitle=<> setTo="hide" class="tc-btn-invisible"> +{{$:/core/images/folder}} <$text text=<<__chunk__>>/> + - -<$list filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]] +[limit[1]]""">(<$count filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]]"""/>) -<$reveal type="match" stateTitle="""$:/state/tree/$prefix$$(chunk)$""" text="show"> -<$macrocall $name="tree-node" prefix="""$prefix$$(chunk)$"""/> +(<$count filter="[all[shadows+tiddlers]removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>) +<$reveal type="match" stateTitle=<> text="show"> +<$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}}/> - +
  • - \end \define tree-node(prefix)
      -<$list filter="[all[shadows+tiddlers]removeprefix[$prefix$]splitbefore[/]sort[title]] +[!suffix[/]]" variable="chunk"> -<> +<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore[/]sort[]!suffix[/]]" variable="chunk"> +<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<>/> -<$list filter="[all[shadows+tiddlers]removeprefix[$prefix$]splitbefore[/]sort[title]] +[suffix[/]]" variable="chunk"> -<> +<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore[/]sort[]suffix[/]]" variable="chunk"> +<$macrocall $name="branch-node" prefix=<<__prefix__>> chunk=<>/>
    \end -\define tree(prefix) +\define tree(prefix: "$:/")
    -<$text text="""$prefix$"""/> +<$text text=<<__prefix__>>/>
    -<$macrocall $name="tree-node" prefix="""$prefix$"""/> +<$macrocall $name="tree-node" prefix=<<__prefix__>>/>
    \end