1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

added gotcha examples to Filter Expressions and rephrased a little for simplicity (#3055)

This commit is contained in:
Tobias Beer 2017-12-12 14:46:12 +01:00 committed by Jeremy Ruston
parent 38fbc4f35a
commit feace8d26b

View File

@ -1,5 +1,5 @@
created: 20150124182421000 created: 20150124182421000
modified: 20150124184900000 modified: 20171212073225103
tags: [[Filter Syntax]] tags: [[Filter Syntax]]
title: Filter Expression title: Filter Expression
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
@ -14,15 +14,35 @@ type: text/vnd.tiddlywiki
A <<.def "filter expression">> is the outermost level of the [[filter syntax|Filter Syntax]]. It consists of one or more [[runs|Filter Run]]. A <<.def "filter expression">> is the outermost level of the [[filter syntax|Filter Syntax]]. It consists of one or more [[runs|Filter Run]].
A run's input is normally a list of all the non-[[shadow|ShadowTiddlers]] tiddler titles in the wiki (in no particular order). But the `+` prefix can change this. If a run has:
* If a run has no `+` or `-` prefix, its output titles are [[dominantly appended|Dominant Append]] to the filter's output. * no prefix, its output titles are [[dominantly appended|Dominant Append]] to the filter's output
* If a run has a `-` prefix, its output titles are <<.em removed>> from the filter's output (if they were present). * the prefix `-`, output titles are <<.em removed>> from the filter's output (if such tiddlers exist)
* If a run has a `+` prefix, it receives the filter's output so far as its input. The filter's output is then completely <<.em replaced>> by the run's output. Any subsequent run reverts to receiving all tiddler titles as its input, unless it too has a `+` prefix. * the prefix `+`, it receives the filter output so far as its input; its output then <<.em "replaces">> all filter ouput so far and forms the input for the next run
In concise technical terms: In technical / logical terms:
|!Run |!Interpretation |!Output | |!Run |!Interpretation |!Output |
|`run` |union of sets |... OR run | |`run` |union of sets |... OR run |
|`+run` |intersection of sets |... AND run | |`+run` |intersection of sets |... AND run |
|`-run` |difference of sets |... AND NOT run | |`-run` |difference of sets |... AND NOT run |
A run's input is normally a list of all the non-[[shadow|ShadowTiddlers]] tiddler titles in the wiki (in no particular order). But the `+` prefix can change this:
|Prefix|Input|h
|`-` or none| <$link to="all Operator">`[all[]]`</$link> tiddler titles, unless otherwise determined by the first [[filter operator|Filter Operators]]|
|`+`|the filter output of all previous runs so far|
Precisely because of varying inputs, be aware that both prefixes `-` and `+` do not behave inverse to one another!
For example, in both of the following, `$:/baz` will only be removed if it actually exists:
* <$link to="is Operator"> `foo bar $:/baz -[is[system]]`</$link>
* <$link to="prefix Operator">`foo bar $:/baz -[prefix[$:/]]`</$link>
To understand why, consider the input for both final runs with their `-` prefix.
In order to remove `$:/baz` in any case, existing or not, simply use the `+` prefix with [[negated filter operators|Filter Operators]]:
* <$link to="is Operator">`foo bar $:/baz +[!is[system]]`</$link>
* <$link to="prefix Operator">`foo bar $:/baz +[!prefix[$:/]]`</$link>