How Text Substitution can Look Like with v5.3.0-prerelease

There are 2 new version using TiddlyWiki v5.3.0-prerelease https://tiddlywiki5-9kmb2mhrt-jermolene.vercel.app/

I do prefer test-text-substitution, because it’s shorter and imo simpler using known filter operators.
The +[limit[1]] is only there for testing to get shorter output

\function sub() "[" [<operator>] ":" [<suffix>] "<term>]" +[join[]]

\procedure search-macro(f, operator, suffix, term)
  debug: <$text text=<<sub>>/>
  <$list filter="[subfilter<f>] +[subfilter<sub>] +[limit[1]]"/>
\end

<<search-macro "[all[tiddlers]!is[system]]" "regexp" "title" "\.[a-zA-Z]{2,4}$">>

----

<<search-macro "[!is[system]limit[250]]" "search" "text" "operator">>

procedures-with-text-substitution-talk-6602.json (1.1 KB)

2 Likes

Documentation about the prerelease syntax can be found at: Parameterised transclusions by Jermolene · Pull Request #6666 · Jermolene/TiddlyWiki5 · GitHub

1 Like

@pmario I had hoped we would not stick with the name function as I understand it will typically be a filter of some sort.

Not withstanding this I find the way to implement it through the subfilter operator a slight misdirection [subfilter<function-name>] when sometimes there is no filter for it to be sub of.

  • Once we use a method such as this, instead of substitution in filters, I expect we will start to use it pervasively, everywhere, so I wonder if this is the time to tidy up a little.
  • I wonder if there were another operator, a synonym for subfilter or way to introduce functions in the filter that would be more user friendly?
  • If there were we could place more meaning in the name we give a function, and make filters using them more readable and meaningful.

Just to illustrate, not a suggestion, what if one could place a function in a filter with <functionname> then the fuction ‘active-todo’ "A filter for todo items not done or archived etc… would look like this;

  • <active-todo>
  • or for this project maybe <active-todo>[tag<currentProject>]

The idea is to have a synonym for subfilter and/or another shortcut way of introducing “functions” into filters.

  • It may be as simple as a synonym of subfilter like 𝑓 eg;
    • [𝑓<active-todo>𝑓<currentProject>]

There has not been a decision yet. So at the moment it works with the \function pragma.

It’s not typically used like a filter. … It can be used as a function with parameters, or it can be used like a variable without any parameters. See debug: <$text text=<<sub>>/> in my example.

It can be used as a filter operator like: .abcd[] or as function[abcd] … depending on the usecase and definition.

IMO it does not matter how the pragma looks like. In the end, the important part will be the name of the function.

For some of my tests I did use all UPPERCASE if I use it as an operator, so they are immediately visible. … The problem with all uppercase names is, that they are usually used for constants.

I did also test .f-sub in the name to indicate, that it’s a function. It would be called like <<f-sub>> as a variable. … I’m not sure yet

2 Likes