Filter and Macro and Spaced delimited Parameter

56 views
Skip to first unread message

Mohammad

unread,
Jan 11, 2019, 6:48:22 AM1/11/19
to TiddlyWiki
Consider the below macro

\define mac(p)
<$set name=cls filter="$p$ +[addprefix[mr-fadeIn-]]">
<$text text=<<cls>> />
</
$set>
\end

It accepts p as input parameter and adds the prefix mr-fadeIn- and return it.

Now consider the below examples

<<mac "ab">>

<<mac "a b">>

<<mac [[a b]]>>

<<mac "[[a b]]">>

and their out puts



mr-fadeIn-ab

mr-fadeIn-a mr-fadeIn-b

mr-fadeIn-a mr-fadeIn-b

[[mr-fadeIn-a b]]



I do not understand the difference. I expect the first three example just append the mr-fadeIn- to begining the argument (parameter)! But filter seems split them on SPACE.


--Mohammad






S. S.

unread,
Jan 11, 2019, 7:45:48 AM1/11/19
to TiddlyWiki
This is how I 75% understand it.

From Title List

A title list is a line of text that presents one or more tiddler titles, strung together with a space between each one and the next.
If a title contains a space, it needs double square brackets around it:


The input is a title list - and must follow the above rule.

"ab" = [[ab]] is a list of one (no spaces)
"a b" = [[a]] & [[b]] is a list of two (space between the titles)
[[a b]] = [[[[a]] & [[b]]]] is a list of two - but no idea how and why this renders back to [[a]] [[b]] - the 25% I don't understand.
"[[a b]]" = [[a b]] is a list of one (double square brackets around a title with a space)

Jed Carty

unread,
Jan 11, 2019, 8:52:02 AM1/11/19
to TiddlyWiki
Your third one is incorrect. [[a b]] is one title, "a b", not two titles.

you can see what I mean if you use this:

<$list filter='[[a b]]'>
item: <
<currentTiddler>><br>
</$list>

if you put in each of your filters than you can see the differences.

Mohammad

unread,
Jan 11, 2019, 9:50:43 AM1/11/19
to TiddlyWiki
Thank you S. S.
As you explained:
  • For case i and ii, I expect the same result as the current output by TW.
  • The third and fourth case are strange for me
@Jed
Thank you Jed, see the below case

\define mac(p)
<$list filter='[<__p__>] +[addprefix[xx-]]'>
item: <<currentTiddler>><br>
</$list>
\end

<<mac [[a b]]>>

---
<$list filter='[[a b]] +[addprefix[xx-]]'>
item: <<currentTiddler>><br>
</$list>

Both gives the same result, e.g. they interpret [[a b]] as a single title. This is inline with what S.S quoted from Tiddlywiki.com

From Title List
A title list is a line of text that presents one or more tiddler titles, strung together with a space between each one and the next.
If a title contains a space, it needs double square brackets around it:

 It seems filter='$p$ +[otherstep]' causes the strange result. $p$ interpreted for [[a b]] as "a" and "b" so there is no difference between [[a b]] and "a b".
I expect two things.

--Mohammad

Mark S.

unread,
Jan 11, 2019, 9:51:53 AM1/11/19
to TiddlyWiki
#1 Works as expected


#2 The filter sees:


"a b +[addprefix[mr-fadeIn-]]"


So thus two outputs.


#3 Wikitext is not a cannibal. It does not eat other wikitext! ;-)  The text is rendered as a link and then passed. The rendering html code is stripped and it becomes like case #2. That's my theory and I'm sticking to it.


-- Mark

Jed Carty

unread,
Jan 11, 2019, 10:03:00 AM1/11/19
to TiddlyWiki
Mohammad,

I don't see how that is unexpected behaviour. You are giving one title in [[a b]] in that context.

The [[ and ]] show it as one title, it is the same as if you used

Hello +[addprefix[xx-]] as the filter. It is a list of one title as input followed by something to do on that title.

using the input:

Hello [[a b]] a b 

may make it a bit more clear.

Mohammad

unread,
Jan 11, 2019, 10:22:20 AM1/11/19
to TiddlyWiki
Thank you Mark.
Thanks Jed.

Cheers
Mohammad

Mark S.

unread,
Jan 11, 2019, 10:23:17 AM1/11/19
to TiddlyWiki
I forgot case #4, I'll finish it up:

The filter sees:

"[[a b]] +[addprefix[mr-fadeIn-]]"

"[[a b]]" looks like a single tiddler with title "a b", and the macro performs the prefix:

mr-fadeIn-a b

-- Mark

Mohammad

unread,
Jan 11, 2019, 10:46:47 AM1/11/19
to TiddlyWiki
That's right Mark.
Thank you.
Reply all
Reply to author
Forward
0 new messages