Find [[type:keyword]]s and generate their reminder text.
The string is searched for keywords, when one is found its reminder text is generated.
This is done by calling @keyword.reminder(param1:.., param2:..., ...)@.
Where the @param@s are the matching keyword parameters.
The it is determined whether the reminder text should be shown.
This is either because the user explicitly selected it, or when @default_expand(mode: keyword.mode)@ returns true.
Whether reminder text is shown is stored in a @<kw->@ tag around the keyword.
! Tag Reminder text Changed by user
| @"<kw-a>"@ hidden no
| @"<kw-A>"@ shown no
| @"<kw-0>"@ hidden yes
| @"<kw-1>"@ shown yes
If the reminder text is shown the function @combine@ is called which should combine the reminder text with (in the variable @reminder@) with the keyword and its parameters (in the variable @keyword@).
@@ -10,14 +10,36 @@ When the @order@ parameter is not given, the input is sorted in alphabetical ord
Otherwise the @order@ parameter determines what characters to show in the output.
The @order@ is a string consisting of multiple ''parts'', each part selects a specific thing from the input.
! Part <tt>sort("zzyyxx")</tt> Description
| @"x"@ @"xx"@ A normal character, selects all matching characters from the input
| @"<wxy>"@ @"xy"@ Selects the characters from the input, but only once.
@"<xy>"@ is the same as @"<x><y>"@.
| @"[wxy]"@ @"yyxx"@ Selects the given characters, but keep them in the same order as in the input.
| @"(xwz)"@ @"zzxx"@ Selects the given characters, and put them in the order that minimizes the distance.
around a 'circle'. Imagine w x and y in a circle, then "zx" is shorter then "x.z" because the latter passes the "w" space.
This sorting option is used to sort colored mana symbols in Magic.
Parts
! Part <tt>sort("zzyyxxy")</tt> Description
| @"x"@ @"xx"@ A normal character, selects all matching characters from the input
| @" "@ @""@ Whitespace is ignored.
| @"\\<"@ @""@ Characters can be escaped with a backslash, normally the character @"<"@ has special behaviour.
Note that you also need to escape the backslash for the [[type:string]].
| @"<wxy>"@ @"xy"@ Selects the characters from the input, but only once.
@"<xy>"@ is the same as @"<x><y>"@.
| @"[wxy]"@ @"yyyxx"@ Selects the given characters, but keep them in the same order as in the input.
| @"ordered(wxy)"@ @"xxyyy"@ The same as just @"wxy"@.
| @"once(wxy)"@ @"xy"@ The same as @"<wxy>"@.
| @"mixed(wxy)"@ @"yyyxx"@ The same as @"[wxy]"@.
| @"compound(yx)"@ @"yx"@ Selects the literal substring @"xy"@ only where it matches exactly. Selects it as many times as it appears
| @"any()"@ @"zzyyxxy"@ Selects the remaining part of the input.
| @"cycle(xwz)"@ @"zzxx"@ Selects the given characters, and put them in the order that minimizes the distance.
around a 'circle'. Imagine w x and y in a circle, then "zx" is shorter then "x.z" because the latter passes the "w" space.
This sorting option is used to sort colored mana symbols in Magic.
| @"reverse_order(x y)"@ @"yyyxx"@ Inside the parentheses can be multiple parts (that can again include part-functions).
@"reverse_order(x y)"@ is ''not'' the same as just @"y x"@, because in the first case x is evaluated first.
For example @"x compound(xy)"@ doesn't work, because the xs are all matched by the time the compound part is evaluated.
So instead you can use @"reverse_order(compound(xy) x)"@.
| @"pattern(.z. xyz)"@ @"yzz"@ Selects all things that match the pattern, where @"."@ is a wildcard.
The things matching the wildcards are then sorted using the given pattern (separated by a space), and subsituted back in.
So in <tt>"zzyyxxy"</tt> the pattern matches <tt>"<b>zzy</b>xxy"</tt> with wildcards <tt>"zy"</tt> these sort as <tt>"yz"</tt> and in the pattern this becomes <tt>"yzz"</tt>.
The parts are read from left to right, each part that matches something removes it from the input, so for example
> sort_text(order: "xx")
behaves the same as
> sort_text(order: "x")
because the first @"x"@ already selects all xs from the input.
This function is available in [[script:rule form]].
...
...
@@ -27,11 +49,19 @@ This function is available in [[script:rule form]].
| @order@ [[type:string]] (optional) Order specification