The Best Practice for a Filter which Contains Entry with Links

I am using a filter to return all lines of a tiddler text field like below:

"[<myTiddler>splitregexp[\n]!is[blank]]"

I use this several times and in several places in my code, so I use a $set widget to calculate the result and store them in a variable (e.g Lines) like this:

<$set name=Lines filter="[<myTiddler>splitregexp[\n]!is[blank]]">

</$set>

The above practice is a recommended one for the sake of performance.

Then I use Lines in different parts of my code like

<$list filter="[enlist:raw<Lines>]" variable=line>

other complex operation on line comes here ...

</$list>

The problem is, if in any line a wikilink is exist the above solution will break. The reason is the $set adds [[...]] to output and when they have wikilink a double brackets inside double bracket is occurred.

Note: For example if a line is See the [[Home Tiddler]] to learn, the output of $set is [[See the [[Home Tiddler]] to learn]].

Question: What solution do you propose to have a better or equal performance here? Note that sometimes the tiddler has few tens of lines.

1 Like

It’s the [enlist:raw<Lines>] that causes the problems …

I don’t think that having to call enlist[] several times is necessarily any faster than calling splitregexp[] instead. While it is good to consider performance, it is also pragmatic to not overcomplicate things unless performance proven to be a concern in a given situation.

I suggest skipping the $set widget and just parsing the tiddler text directly in the $list filter.

1 Like

Saq is right, since enlist will create a problem if there are links in a line. So without the extra variable it should work.

1 Like

I thought using $set and calculating the filter result will save me from several calculation of this filter!

okay! just for readability what you think if I use something like below

<$vars LinesFilter="[<myTiddler>splitregexp[\n]!is[blank]]">
.
.
<$list filter="[subfilter<LinesFilter>]" variable=line>
...
```

That should be fine, though the more modern approach would be to use $let! :slight_smile:

On second thought, you could just do this:

<$vars LinesFilter="[<myTiddler>splitregexp[\n]!is[blank]]">
.
.
<$list filter=<<LinesFilter>> variable=line>
1 Like

The reason I used subfilter is was to do more processing like

[subfilter<LinesFilter>first[]split[:]]
1 Like