langur

string/regex literal interpolation

Strings with interpolations are preceded by a $ token. Regex literals follow the same pattern for interpolations, such as $re/\.x;/.

There are 5 forms of interpolation, all preceded by the \ escape character.

Newlines are allowed within interpolated sections of strings that allow newlines, but never with the dot-semicolon form of interpolation.

opening/closing marks and examples
. ;
opening dot included as part of interpolated value

$"\.var;"
$"\.x+.y;"
{ }

$"\{.var}"
$"\{.x+.y}"
( )

$"\(.var)"
$"\(.x+.y)"
[ ]

$"\[.var]"
$"\[.x+.y]"
< >

$"\<.var>"
$"\<.x+.y>"

Interpolations may nest pairs of (), {}, or [] marks (not <>).

Nested marks in an interpolation would look something like $"\[.x[1]]".

Also, a semicolon or colon may be used inside of nesting marks without terminating the interpolation value.

interpolation modifiers

As of 0.6.8, you use interpolation modifiers to format an interpolated value. Starting an interpolation with a backslash as an indicator to escape meta-characters, such as $re/\[\ .x]/, is deprecated (will eventually not work). Using the esc modifier instead, this would become $re/\[.x:esc]/ or $re/\.x:esc;/.

Interpolation modifiers start with an unenclosed colon. You can use multiple modifiers on a single interpolation (chained), and they will be executed in order.

If you want to convert from a number, you must use that modifier first, because after the first one, the rest of the modifiers will be dealing with a string.

Modifiers don't allow spaces around them.

There are more to come later, Lord willing. Langur 0.6.10 adds custom base, custom function, and type modifiers. 0.6.12 adds a limit string length modifier.

modifier
code point alignment
number
number(cp)

If the number is positive, it will right-align, and negative will left-align. The default code point to use is the ASCII space. There are 2 ways to specify a different code point. (Placing an alternate code point after a comma, after the alignment number, is deprecated, as it is less clear and less flexible.)
  1. Use one code point within parentheses.
  2. Specify a code point using a hexadecimal number of 2 digits of more within parentheses.

Examples:
$"\.x:7;"
$"\.x:7(.);"
$"\.x:7(2E);"
$"\.x:-7;"
$"\.x:-7(.):20(#);"


code point limit
Lnumber
Lnumber(...)

If the number is positive, it will limit the right side of the string, and negative will limit the left side. By default, it does not add an overflow indicator. To specify one, enclose it in parentheses. The length of the overflow indicator will be considered when limiting a string. That is, for example, if the limit is 20 and the indicator is 3 code points, and the string is over 20 code points, it will be shortened to 17 code points (20 with the indicator). The indicator will be placed on the side that is shortened.

Examples:
$"\.x:L7;"
$"\.x:L7(...);"
$"\.x:L7(…);"
$"\.x:L-7;"
$"\.x:L20(*);"


uppercase/lowercase hexadecimal
X
Xnumber
x
xnumber

integer indicates a minimum number of digits

Examples:
$"\.x:x2;"
$"\.x:X;"
$"\.x:x2:7(.);"


uppercase/lowercase custom base
Basenumber
Basenumber,number
basenumber
basenumber,number

use any base from 2 to 36
second integer indicates a minimum number of digits

Examples:
$"\.x:base2;"
$"\.x:Base11,10;"


custom formatting function
.fn

Examples:
val .F = ucase .s; $"\.x:.F;"


type
T

Examples:
$"\.x:T;"


escape meta-characters
esc

Examples:
$"\.x:esc;"
$re/\.x:esc;/