[TW5] Mysteriouse leading and Training space

73 views
Skip to first unread message

TonyM

unread,
Nov 8, 2017, 7:07:29 AM11/8/17
to TiddlyWiki

Folks,

I almost have a simple Boolean tag search see discussion working. However

I am bugged by the following, which does everything I want but results in leading and trailing spaces in the resultant macro value. This seems to be enough to stop any filter using this value.

\define displaymyfilter()
<$list filter="[list[EditInput!!input]]" variable=item>
<$list filter="[<item>!prefix[+]!prefix[-]]" variable=tagfilter>
[tag[<<tagfilter>>]]
</$list>
<$list filter="[<item>prefix[+]]+[removeprefix[+]]" variable=tagfilter>
+[tag[<<tagfilter>>]]
</$list>
<$list filter="[<item>prefix[-]]+[removeprefix[-]]" variable=tagfilter>
-[tag[<<tagfilter>>]]
</$list>
</$list>
\end

Debug: Source Field "one two -three" Comes from {{EditInput!!input}}
Debug: My Constructed Filter " [tag[one]] [tag[two]] -[tag[three]] " Output of <<displaymyfilter>>
Note: The leading and Trailing spaces in my constructed filter.


Which means


<<list-links filter:"<<displaymyfilter>>" >>


Throws a display error, does not work, multiple formats tried! also <$list...



Tiddler ends with a <$set>

Mark S.

unread,
Nov 8, 2017, 9:26:51 AM11/8/17
to TiddlyWiki
Hey that's looking pretty good. Invoke it like this:

<$wikify name=filt text="<<displaymyfilter>>">
<$macrocall $name="list-links" filter=<<filt>> />
</$wikify>

Good luck!
Mark

TonyM

unread,
Nov 8, 2017, 2:58:01 PM11/8/17
to tiddl...@googlegroups.com
Mark,

Thanks, That was perfect. works like a dream.

Can you tell me Is this just that wikify removes the leading or trailing spaces?

If so could it be said to be  "work around" or is this a common need because of artefacts such as this occurring?, or am I missing something?

I will try and publish the resulting solution.

Thanks very much.

Tony

Mark S.

unread,
Nov 8, 2017, 3:10:21 PM11/8/17
to TiddlyWiki
I don't think this would have worked at all without wikify. The tricky thing is, just because you see text on screen doesn't mean that you can pass it to a macro.

So you see
 
[tag[tag1]] [tag[tag2]] -[tag[tag3]]

but that's a rendering illusion. Because it was made inside of loops, what's actually there is something like:


"[tag[tag1]]"#"[tag[tag2]]"#"-[tag[tag3]]"

where # is some sort of white space character (possible even new line characters).

This sort of thing would leave you banging your head for hours before the Wikify widget. Now you can just turn the "perceived" text into a real text string and pass it to a variable.

This syntax:

<<list-links filter:"<<displaymyfilter>>" >>

would definitely not work because <<displaymyfilter>> is inside of strings and so will be passed literally to the list-links macro which wouldn't know what to do with it.

This syntax:

<<list-links filter:<<filter>> >>

Doesn't work either. I've never been able to get a macro short cut (<<macro>>) to work inside of another macro short-cut. In situations where I need a macro called by a macro, I use <$macrocall>.

Good luck!
Mark

TonyM

unread,
Nov 8, 2017, 3:29:48 PM11/8/17
to TiddlyWiki
Thanks for those insights.
Reply all
Reply to author
Forward
0 new messages