From 0bd53cfd876be6c0bd41c7523f5a75ace87fdf3b Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Wed, 3 Jun 2020 01:15:35 -0700 Subject: [PATCH] doc/Factoids.md: improve expansion-modifiers section --- doc/Factoids.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/Factoids.md b/doc/Factoids.md index 3ed2a47c..459e75e9 100644 --- a/doc/Factoids.md +++ b/doc/Factoids.md @@ -383,16 +383,16 @@ Another example, creating the RTFM trigger: ### Expansion modifiers List `$variables` and [Selectors](Commands.md#selectors) can accept trailing expansion modifier keywords prefixed with a colon. These can be chained together to combine their effects. -There are two categories of expansion modifiers. Selection modifiers and text modifiers. +There are three categories of expansion modifiers. Selector, Selection and text modifiers. -Selection modifiers control how values are chosen from the `$variable` or Selector list. +Selector modifiers control how values are chosen from the `$variable` or Selector list. !echo $colors:pick(3) red pink green Note that modifiers may not contain spaces. `:pick(2, 3)` is invalid and must be written as `:pick(2,3)`. -Modifier | Description +Selector Modifier | Description --- | --- `:` | Looks for variable in `` first; use `global` to refer to the global channel. This modifier must be the first modifier when chained with other modifiers. `:index(n)` | Selects the `n`th element from the `$variable` list. @@ -401,24 +401,9 @@ Modifier | Description `:pick_unique(x)` | Selects `x` count of random elements without any repeated selections. `:pick_unique(x,y)` | Selects between `x` and `y`, inclusive, count of random elements without any repeated selections. `x` may be `0` to occasionally pick no value. In this case the `$variable` and any leading whitespace will be stripped. -Text modifiers alter the selected values. +Selection modifiers apply only to selector modifiers that return more than one selection. Using them otherwise has no effect. - !echo $colors:uc - RED - - !echo $colors:ucfirst - Blue - -Modifier | Description ---- | --- -`:uc` | Uppercases the expansion. -`:lc` | Lowercases the expansion. -`:ucfirst` | Uppercases the first letter in the expansion. -`:title` | Lowercases the expansion and then uppercases the initial letter of each word. - -The following text modifiers apply only to selection modifiers that return more than one selection. Using them otherwise has no effect. - -Modifier | Description +Selection Modifier | Description --- | --- `:sort` | Sorts the selected list in ascending order. `:-sort` | Sorts the selected list in descending order. @@ -431,6 +416,21 @@ Modifier | Description !echo $colors:pick(5):enumerate blue, green, dark purple, orange and bright yellow +And finally, text modifiers alter the selected values. + + !echo $colors:uc + RED + + !echo $colors:ucfirst + Blue + +Text Modifier | Description +--- | --- +`:uc` | Uppercases the expansion. +`:lc` | Lowercases the expansion. +`:ucfirst` | Uppercases the first letter in the expansion. +`:title` | Lowercases the expansion and then uppercases the initial letter of each word. + ## action_with_args You can use the [`factset`](#factset) command to set a special [factoid metadata](#factoid-metadata) key named `action_with_args` to trigger an alternate message if an argument has been supplied.