How to properly escape special filter syntax chars in filter operator parameters?

For example see https://tiddlywiki.com/#field%20Operator .

parameter link points to https://tiddlywiki.com/#Filter%20Parameter . My use case is the first one - hard - since I’m experimenting with a handwritten filter in $:/AdvancedSearch -> Filter.

Going back to https://tiddlywiki.com/#field%20Operator%20(Examples) , first example is:

[field:author[JeremyRuston]]

What if field value would be [[JeremyRuston]] rather than JeremyRuston?

Neither quoting the value like

[field:author["[[JeremyRuston]]"]]

nor trying to escape the square brackets like

[field:author[\[\[JeremyRuston]\]\]]

seem to work.

TiddlyWiki tends not to use escaping in the traditional manner of a programming language. My original thinking was that escaping was complex and often caused problems for experienced programmers, and so it wasn’t a good match for TiddlyWiki target users. The workaround is to define a separate function or procedure containing the text [[JeremyRuston]], and then reference that within the filter.

One of our long term goals is to figure out a syntax for defining local variables within a filter which will make things like this a bit easier.

2 Likes

If I understand you correctly, you’re suggesting to use an intermediary step instead of using $:/AdvancedSearch -> Filter directly? As in create a tiddler, a variable with value “[[JeremyRuston]]”, then just reference it in the filter using <var> syntax? Fortunately, this shouldn’t be hard.

Edit: I did it this way and it worked. :+1:

@vuk when setting a variable to a string as in your example you can use define, procedure pragma but also $set, $vars and the best $let

\procedure tiddler-title() [[JeremyRuston]]

and use `<tiddler-title>` in your filters

or
<$let tiddler-title="[[JeremyRuston]]">

and use `<tiddler-title>` in your filters

</$let>

However;

There are otherways to populate fields, lists and handle titles that handle the use of [[name with spaces]] namewithoutspaces including but not limited to the listops action widget.