enclose string in [[...]] only if contains spaces

91 views
Skip to first unread message

Rustem

unread,
Jul 5, 2015, 5:14:29 PM7/5/15
to tiddl...@googlegroups.com
I'm looking for a macro or something that would enclose a string containing spaces in double-square brackets, but leave a single-word string as is.
Any hints?

--R

Danielo Rodríguez

unread,
Jul 6, 2015, 2:53:20 AM7/6/15
to tiddl...@googlegroups.com
What is the problem about enclosing a string without spaces in double square brackets? it will work the same and it is easier.

Rustem

unread,
Jul 6, 2015, 2:58:30 AM7/6/15
to tiddl...@googlegroups.com
I agree. I think this problem is commonly referred to as OCD. Can't live with extraneous brackets. :D

Jeremy Ruston

unread,
Jul 6, 2015, 3:52:36 AM7/6/15
to TiddlyWiki
Hi Rustem

The core already contains a function stringifyList() that does what you want:


You could wrap it into a JS macro,

Best wishes

Jeremy


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/3d73c032-c94d-4f55-914b-5b9e4cba856d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Rustem

unread,
Jul 6, 2015, 4:05:06 PM7/6/15
to tiddl...@googlegroups.com, jeremy...@gmail.com

Actually, I realized set widget will do it for me, as described in http://tiddlywiki.com/static/SetWidget (see “Filtered List Variable Assignment”).

However, can anybody explain why this does not work as expected (assuming currentTiddler title contains spaces)

<$set name=myVariable filter="[[$(currentTiddler)$]] [[another one]]">
<$text text=<<myVariable>>/>
</$set>

but this does:

<$set name=myVariable filter="[all[current]] [[another one]]">
<$text text=<<myVariable>>/>
</$set>

Rustem

unread,
Jul 6, 2015, 5:46:04 PM7/6/15
to tiddl...@googlegroups.com, jeremy...@gmail.com

I should have just used [<currentTiddler>] instead of [[$(currentTiddler)$]]. Not sure what the deal with the latter is. Used in a list filter, it causes too much recursion.

Reply all
Reply to author
Forward
0 new messages