Folks, Despite becoming quite familiar with the new function pragma there is a little gap I would like to fill. Is it in my understanding or does it point to a need for an improvement?
Consider the following
\function contains.string(string) [split<string>count[]compare:number:gt[1]]
{{{ [[This is a tiddler 2 that ]contains.string[tiddler]] }}}
The following custom filter splits the incoming title with the string and counts the parts. If there are more than one part then the string must exist in the incoming title. Noting that even if the title has a leading or trailing string this still works.
- The custom operator will output the count if its greater than 1
Your will note that the custom operator is simply invoked with the input title. As far as I can tell there is no way to access this input title except to act on it with a filter. Our functions are by default what we call āselection modifiersā, it is quite easy to ignore the incoming title by using a filter that is a āselection constructorā such as starting with a variable [<varname>...
.
However
In the above function I would like to return the incoming title if the count is greater than 1 but I do not seem to have any way to reference this title, it seems to have being lost in the filter.
- Common variables or fieldnames do not seem to work such as currentTiddler, title or
{!!title}
as these all refer to the current tiddler, not the current title in the filter.
There are other cases where I would like to have multiple filter runs each of which is applied to the incoming title, this is possible to some extent.
Also consider the following
\function test.function(string) [prefix[test]] [suffix[test]]
{{{ [[a title test]test.function[test]] }}}
{{{ [[test a title]test.function[test]] }}}
- You will see each filter run, the prefix and suffix test, is handed the incoming title.
However if try to do anything else with the incoming title I loose access to it.