currentTiddler in function - Is this odd or am I missing something?

Folks,

to solve this issue;

I wrote a function as follows;

\function pretty.permalink() [<open-sq>] [<currentTiddler>] [<close-sq>] [[(]] [{$:/info/url/full}] [[#]] [<currentTiddler>] [[)]]  +[join[]]
\define open-sq() [
\define close-sq() ]

<<pretty.permalink>>

I dont understand the result;

[](file:///I:////!Master/KeyWikis/BlogToSelf.html#New Blog Tiddler 13)

Why does the [] not contain the current tiddler?

Even this simple form

\function pretty.permalink() [<currentTiddler>] [[something]] [<currentTiddler>] +[join[]]

<<pretty.permalink>>

Fails with the first use of [<currentTiddler>] not being returned.

Tested in TW 5.3.7, 5.3.8 and 5.4.0-prerelease now

You need to add the =/:all filter run prefix before [<currentTiddler>] (and any other repeated strings) to prevent deduplication. Otherwise, only the last instance of a given string will be preserved in the results.

Incidentally, for functions that use “problematic” characters like square brackets, I often like to define the special characters as parameters of the function (following any parameters that might be set dynamically). So I might rewrite your function like this:

\function pretty.permalink(open-sq:"[", close-sq:"]") [<open-sq>] =[<currentTiddler>] [<close-sq>] [[(]] [{$:/info/url/full}] [[#]] =[<currentTiddler>] [[)]] +[join[]]

<<pretty.permalink>>

Of course, if you use <<open-sq>> and <<close-sq>> frequently, it makes more sense to make them global variables (which you may already have done!) But for more ad hoc situations, like regex, I find it very convenient to keep all my static variables in the same function.