Other languages are translated automatically from English.
string fields and methods
Text. A string that holds a number can use number methods too.
Text is a string: anything in quotes. 'Single quotes' keep what you write exactly as it is, and "double quotes" fill in what is in { }, so "Hello { $name }" reads the variable. For text over several lines, write a text block between ``` lines, which keeps every line break as written.
Text methods never change the text they are called on; each gives new text (or a number, a list or a bool), so chain them or keep the result in a variable:
<let name="name" value="' ada LOVELACE '" />
<let name="tidy" value="$name->trim()->title()" />
<echo value="$tidy" /> <!-- 'Ada Lovelace' because the spaces go and each word gets a capital -->
<echo value="$name" /> <!-- ' ada LOVELACE ' because the text itself is unchanged -->
$name = ' ada LOVELACE '
$tidy = $name->trim()->title()
echo $tidy // 'Ada Lovelace' because the spaces go and each word gets a capital
echo $name // ' ada LOVELACE ' because the text itself is unchanged
Positions count from 0, and a negative position counts from the end. A character such as an emoji counts as two places, and no method cuts one in half. Comparisons match case exactly unless you pass the ignore_case flag.
A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).
The text after the first time text occurs (or the last time, with last), or the whole text when it doesn't: 'a.tar.gz'->after('.', last) is gz.
->after(text, last?) gives the text after the first time text occurs, or after the last time with last. When text isn't there, you get the whole text back:
<let name="file" value="'archive.tar.gz'" />
<echo value="$file->after('.')" /> <!-- 'tar.gz' because it cuts at the first dot -->
<echo value="$file->after('.', last)" /> <!-- 'gz' because it cuts at the last dot -->
<echo value="'no-at-sign'->after('@')" /> <!-- 'no-at-sign' because there is no @ to cut at -->
$file = 'archive.tar.gz'
echo $file->after('.') // 'tar.gz' because it cuts at the first dot
echo $file->after('.', last) // 'gz' because it cuts at the last dot
echo 'no-at-sign'->after('@') // 'no-at-sign' because there is no @ to cut at
The text before the first time text occurs (or the last time, with last), or the whole text when it doesn't: 'a.tar.gz'->before('.', last) is a.tar.
->before(text, last?) gives the text before the first time text occurs, or before the last time with last. When text isn't there, you get the whole text back:
<let name="email" value="'joan@example.com'" />
<echo value="$email->before('@')" /> <!-- 'joan' -->
<echo value="'archive.tar.gz'->before('.', last)" /> <!-- 'archive.tar' because it cuts at the last dot -->
$email = 'joan@example.com'
echo $email->before('@') // 'joan'
echo 'archive.tar.gz'->before('.', last) // 'archive.tar' because it cuts at the last dot
The parts of the text between blank lines, each trimmed of the line breaks around it: 'a\nb\n\nc'->blocks() is ['a\nb', 'c'].
->blocks() splits the text at blank lines, so each block is a group of lines. A single line break stays inside a block; only an empty line starts a new one. Each block is trimmed of the line breaks around it:
<let name="pantry">```text
tea
milk
flour
sugar
eggs
```</let>
<let name="shelves" value="$pantry->blocks()" />
<echo value="$shelves->count()" /> <!-- 2 because one blank line splits the text in two -->
<echo value="$shelves->map(.lines()->count())" /> <!-- [2, 3] because the first block has 2 lines and the second 3 -->
$pantry = ```text
tea
milk
flour
sugar
eggs
```
$shelves = $pantry->blocks()
echo $shelves->count() // 2 because one blank line splits the text in two
echo $shelves->map(.lines()->count()) // [2, 3] because the first block has 2 lines and the second 3
->capitalize() makes the first letter upper case and leaves the rest as it is:
<echo value="'élan and style'->capitalize()" /> <!-- 'Élan and style' because only the first letter changes -->
<echo value="'iPhone'->capitalize()" /> <!-- 'IPhone' -->
echo 'élan and style'->capitalize() // 'Élan and style' because only the first letter changes
echo 'iPhone'->capitalize() // 'IPhone'
The text as an identifier in one style: 'User ID'->case(snake) is user_id, kebab gives user-id, camel userId and pascal UserId.
->case(style) rewrites text as a name in one style: snake (user_id), kebab (user-id), camel (userId) or pascal (UserId). It finds the words in spaces, separators and changes of case alike, so you can go from any style to any other:
->chars() gives the characters as a list, one text each. A character such as an emoji is one item, however it is stored:
<echo value="'tea'->chars()" /> <!-- ['t', 'e', 'a'] -->
<echo value="'👍🏽x'->chars()->count()" /> <!-- 2 because the thumb and its skin tone are one character -->
echo 'tea'->chars() // ['t', 'e', 'a']
echo '👍🏽x'->chars()->count() // 2 because the thumb and its skin tone are one character
The text as rows of characters, one list per line, for maps and mazes: '#.\n.#'->grid() is [['#', '.'], ['.', '#']]. A line break at the end adds no empty row. Read a cell with $grid[row][column], and go through its rows or columns with ->cells(rows) or ->cells(columns).
->grid() turns lines of characters into rows of single characters, so $grid[row][column] is one character. Row 0 is the top line and column 0 the first character. A line break at the end adds no empty row:
<let name="garden">```text
#.#
..#
```</let>
<let name="plot" value="$garden->grid()" />
<echo value="$plot" /> <!-- [['#', '.', '#'], ['.', '.', '#']] -->
<echo value="$plot[0][1]" /> <!-- '.' because row 0 is #.# and column 1 is its middle -->
<echo value="$plot[1][2]" /> <!-- '#' because row 1 is ..# and column 2 is its last -->
$garden = ```text
#.#
..#
```
$plot = $garden->grid()
echo $plot // [['#', '.', '#'], ['.', '.', '#']]
echo $plot[0][1] // '.' because row 0 is #.# and column 1 is its middle
echo $plot[1][2] // '#' because row 1 is ..# and column 2 is its last
The HMAC of the text with a secret key, in hex (SHA-256 by default), as webhook signatures are made. Compare signatures with @secure_equals().
->hmac(key, algorithm?) signs the text with a secret key and gives the signature in hex, SHA-256 unless you pass sha1 or sha512. It is how webhooks prove where a message came from. Compare signatures with @secure_equals(), which takes the same time however much of the two matches:
<let name="body" value="'{"id": 1}'" />
<let name="signature" value="$body->hmac('whsec_test')" />
<echo value="$signature->count()" /> <!-- 64 because SHA-256 in hex is 64 characters -->
<echo value="@secure_equals($signature, $body->hmac('whsec_test'))" /> <!-- true because the same key signs the same text the same way -->
$body = '{"id": 1}'
$signature = $body->hmac('whsec_test')
echo $signature->count() // 64 because SHA-256 in hex is 64 characters
echo @secure_equals($signature, $body->hmac('whsec_test')) // true because the same key signs the same text the same way
Parameter
Takes
keyrequired
any value
algorithmoptional
one of these words: sha256|sha1|sha512
Arguments can be named: ->hmac(…, algorithm: …).
Example
<echo>{ '{"id": 1}'->hmac('whsec_test') }</echo>
echo '{"id": 1}'->hmac('whsec_test')
#string->index_of(text, ignore_case?: bool, last?: bool)→ number
Where text first occurs, or with last, where it last occurs; -1 when it doesn't. With ignore_case, upper and lower case match.
->index_of(text, ignore_case?, last?) gives the position where text first occurs, or with last, where it last occurs. It gives -1 when text isn't there:
True when the whole text is a number, such as '42', '-3.5' or '1e3'. Spaces around it are allowed.
->is_numeric() is true when the whole text is a number, such as '42', '-3.5' or '1e3'. Spaces around it are allowed:
<echo value="'42'->is_numeric()" /> <!-- true -->
<echo value="' -3.5 '->is_numeric()" /> <!-- true because the spaces around it are fine -->
<echo value="'42 cats'->is_numeric()" /> <!-- false because cats isn't part of a number -->
echo '42'->is_numeric() // true
echo ' -3.5 '->is_numeric() // true because the spaces around it are fine
echo '42 cats'->is_numeric() // false because cats isn't part of a number
->lines() gives one text per line. A blank line gives an empty text, so you can find the breaks between groups:
<let name="note">```text
tea
milk
juice
```</let>
<echo value="$note->lines()" /> <!-- ['tea', 'milk', '', 'juice'] -->
<echo value="$note->lines()->count()" /> <!-- 4 because the blank line is a line too -->
$note = ```text
tea
milk
juice
```
echo $note->lines() // ['tea', 'milk', '', 'juice']
echo $note->lines()->count() // 4 because the blank line is a line too
The text with each character replaced by char (* by default), apart from the last keep_end characters: ->mask('*', keep_end: 4) shows only the last four.
->mask(char?, keep_end?) hides the text behind a character, * unless you give another, keeping the last keep_end characters so the reader can recognise it:
<echo value="'4242424242424242'->mask('*', keep_end: 4)" /> <!-- '************4242' because only the last 4 show -->
<echo value="'secret'->mask()" /> <!-- '******' -->
echo '4242424242424242'->mask('*', keep_end: 4) // '************4242' because only the last 4 show
echo 'secret'->mask() // '******'
True when the text matches a regular expression: ->matches(/^[a-z]+$/i).
->matches(pattern) is true when a regular expression finds a match in the text. Anchor it with ^ and $ to test the whole text:
<echo value="'Tea'->matches(/^[a-z]+$/i)" /> <!-- true because i ignores case -->
<echo value="'Tea2'->matches(/^[a-z]+$/i)" /> <!-- false because 2 isn't a letter -->
echo 'Tea'->matches(/^[a-z]+$/i) // true because i ignores case
echo 'Tea2'->matches(/^[a-z]+$/i) // false because 2 isn't a letter
Normalizes Unicode using the given form (NFC by default).
->normalize_unicode(form?) makes text that looks the same compare the same. é can be stored as one character or as e plus an accent; NFC (the default) joins them, NFD splits them:
<echo value="'café'->normalize_unicode(NFD)->count()" /> <!-- 5 because NFD stores é as e and an accent -->
<echo value="'café'->normalize_unicode()->count()" /> <!-- 4 -->
echo 'café'->normalize_unicode(NFD)->count() // 5 because NFD stores é as e and an accent
echo 'café'->normalize_unicode()->count() // 4
Every number in the text, in order, as numbers: 'x=-3, y=12'->numbers() is [-3, 12]. A minus makes a number negative unless a letter or digit comes right before it, so '1-3'->numbers() is [1, 3].
->numbers() gives every number written in the text, in order, as numbers. A minus counts as a sign when nothing is joined to its left, as in x=-3; between two numbers, as in 1-3, it is a dash:
<echo value="'move 3 boxes from -1 to 12'->numbers()" /> <!-- [3, -1, 12] because -1 has a space before its minus -->
<echo value="'pages 4-9'->numbers()" /> <!-- [4, 9] because the minus joins 4 and 9, so it is a dash -->
<echo value="'price 2.50, qty 4'->numbers()" /> <!-- [2.5, 4] -->
echo 'move 3 boxes from -1 to 12'->numbers() // [3, -1, 12] because -1 has a space before its minus
echo 'pages 4-9'->numbers() // [4, 9] because the minus joins 4 and 9, so it is a dash
echo 'price 2.50, qty 4'->numbers() // [2.5, 4]
The text padded at the end to width, or at the start with start: '7'->pad(3, '0', start) is 007.
->pad(width, char?, start?) adds a character, a space unless you give another, until the text is width characters long. It pads at the end, or at the start with start. Text already that long is left alone:
<echo value="'7'->pad(3, '0', start)" /> <!-- '007' because two zeros go in front -->
<echo value="'tea'->pad(5, '.')" /> <!-- 'tea..' -->
<echo value="'teapot'->pad(3)" /> <!-- 'teapot' because it is already longer than 3 -->
echo '7'->pad(3, '0', start) // '007' because two zeros go in front
echo 'tea'->pad(5, '.') // 'tea..'
echo 'teapot'->pad(3) // 'teapot' because it is already longer than 3
The text with every old replaced by new. old can be a regex: ->replace(/\s+/, ' '), and new can use its groups as $1 or ${name}. With ignore_case, plain text matches in any case.
->replace(old, new, ignore_case?) replaces every old with new. old can be a regular expression, and then new can use what its groups matched as $1 or ${name}:
<echo value="'banana'->replace('a', 'o')" /> <!-- 'bonono' because every a changes -->
<echo value="'Tea'->replace('t', 'p', ignore_case)" /> <!-- 'pea' because T matches t -->
<echo value="'too many spaces'->replace(/\s+/, ' ')" /> <!-- 'too many spaces' -->
<echo value="'2026-12-01'->replace(/(\d+)-(\d+)-(\d+)/, '$3/$2/$1')" /> <!-- '01/12/2026' because the groups swap places -->
echo 'banana'->replace('a', 'o') // 'bonono' because every a changes
echo 'Tea'->replace('t', 'p', ignore_case) // 'pea' because T matches t
echo 'too many spaces'->replace(/\s+/, ' ') // 'too many spaces'
echo '2026-12-01'->replace(/(\d+)-(\d+)-(\d+)/, '$3/$2/$1') // '01/12/2026' because the groups swap places
Parameter
Takes
oldrequired
any value
newrequired
any value
ignore_caseoptional
a flag: ignore_case or not ignore_case
Arguments can be named: ->replace(…, new: …, ignore_case: …).
->sha256() gives the SHA-256 hash of the text in hex, 64 characters. The same text always gives the same hash, and any change gives a different one:
<echo value="'tea'->sha256()->count()" /> <!-- 64 -->
<echo value="'tea'->sha256() == 'tea'->sha256()" /> <!-- true because the same text gives the same hash -->
<echo value="'tea'->sha256() == 'Tea'->sha256()" /> <!-- false because one letter changed -->
echo 'tea'->sha256()->count() // 64
echo 'tea'->sha256() == 'tea'->sha256() // true because the same text gives the same hash
echo 'tea'->sha256() == 'Tea'->sha256() // false because one letter changed
Every place a mask fits (->shapes(Tree), or ->shapes([Block, Ell]) for several), and every square, rectangle, line or circle (name one or several: ->shapes(square, circle, of: '#')) made by the cells that hold of: (a value, or a regex). It looks through text (each line a row, each character a cell, a blank line between layers), a list of values (one row), a grid ($grid[row][column]) or a 3D list ($cube[layer][row][column]); the built-in shapes also take a list of points { row, column }. A mask is a type that extends Mask: its layout is a picture, one character a cell, and each character matches a cell holding the same character, unless its symbols say otherwise (a value, a regex, a fn(cell), same for cells that all hold one value, or any for a cell that isn't part of the shape). A layout can be a regex too, which reads cells along a row, any length. With repeated, the mask is stamped again and again from the top left until it covers the input, the copies at the edges cut off: every copy must hold what the first does, and each match is the first copy, with copies, how many there were (a regex layout gives one match per size that fits, smallest first). blank: (a value, a regex or a fn(cell)) names the input cells that fit anything, and copies and same cells fill each other's blanks in. Each match is { kind, points }: kind is the mask's name or the shape, and each point is { row, column, value } (with symbol for a mask, and layer in 3D). With rotated, a mask is tried turned every way the input allows (back to front in a row, the four quarter turns in a grid, all 24 ways round in 3D), and squares, rectangles and lines may lean. A line needs size:, and a circle radius: and distance: straight (the default), steps or moves.
->shapes(mask?, square?, rectangle?, line?, circle?, of?, rotated?, size?, radius?, distance?, repeated?, blank?) finds shapes drawn in text. Each line is a row and each character a cell, so the text doesn't need ->grid() first, and a blank line starts the next layer of a 3D input. It works as the list method does: name a mask first (a type that extends Mask, or a list of them), or one of the built-in shapes with of: to say which cells make it. Each match comes back as { kind, points }, and each point says its row, column, value and the mask's symbol drawn over it. A mask's layout can be a regex, which reads along each line, any length. repeated stamps the mask over the whole text and gives the first copy, and blank: '?' lets the ?s fit anything. See list ->shapes() for every argument, and masks for the guide.
<let name="orchard">```text
#.#.#
.#...
#.#.#
```</let>
<type name="Tree" extends="Mask">
<field name="layout" default="```text
#.#
.#.
```" />
<field name="symbols" default="{ '.': any }" />
</type>
<echo value="$orchard->shapes(Tree)->count()" /> <!-- 1 because the V of three trees fits only at the top left -->
<echo value="$orchard->shapes(Tree, rotated)->count()" /> <!-- 4 because turned upside down and on its sides it fits three more places -->
<echo value="$orchard->shapes(Tree)->first().points->map(.column)" /> <!-- [0, 2, 1] because the points come in reading order: the top two, then the middle -->
<type name="Instructions" description="A printer's instructions: one or more colours." extends="Mask">
<field name="layout" default="/[roygbv]+/" />
</type>
<echo value="'rgbrgbrgbr'->shapes(Instructions, repeated)->first().points->count()" /> <!-- 3 because rgb, repeated and cut off, prints the whole barcode -->
<echo value="'?rv'->shapes(Instructions, repeated, blank: '?')->first().points->count()" /> <!-- 2 because vr fits: the ? is a v -->
$orchard = ```text
#.#.#
.#...
#.#.#
```
type Tree extends Mask {
layout: ```text
#.#
.#.
```
symbols: { '.': any }
}
echo $orchard->shapes(Tree)->count() // 1 because the V of three trees fits only at the top left
echo $orchard->shapes(Tree, rotated)->count() // 4 because turned upside down and on its sides it fits three more places
echo $orchard->shapes(Tree)->first().points->map(.column) // [0, 2, 1] because the points come in reading order: the top two, then the middle
/// A printer's instructions: one or more colours.
type Instructions extends Mask {
layout: /[roygbv]+/
}
echo 'rgbrgbrgbr'->shapes(Instructions, repeated)->first().points->count() // 3 because rgb, repeated and cut off, prints the whole barcode
echo '?rv'->shapes(Instructions, repeated, blank: '?')->first().points->count() // 2 because vr fits: the ? is a v
Part of the text; negative positions count from the end.
->slice(start, end?) gives the characters from position start up to, but not including, end, or to the end of the text. Negative positions count from the end:
<let name="word" value="'teapot'" />
<echo value="$word->slice(0, 3)" /> <!-- 'tea' because it stops before position 3 -->
<echo value="$word->slice(3)" /> <!-- 'pot' -->
<echo value="$word->slice(-3)" /> <!-- 'pot' because -3 is three from the end -->
$word = 'teapot'
echo $word->slice(0, 3) // 'tea' because it stops before position 3
echo $word->slice(3) // 'pot'
echo $word->slice(-3) // 'pot' because -3 is three from the end
The parts between each separator (or between spaces), as a list. The separator can be a regex: ->split(/\s*,\s*/).
->split(separator?) cuts the text at each separator and gives the parts as a list. Without a separator it cuts at spaces. The separator can be a regular expression:
<echo value="'tea,milk,juice'->split(',')" /> <!-- ['tea', 'milk', 'juice'] -->
<echo value="'tea milk'->split()" /> <!-- ['tea', 'milk'] -->
<echo value="'a, b,c'->split(/\s*,\s*/)" /> <!-- ['a', 'b', 'c'] because the spaces around each comma go too -->
echo 'tea,milk,juice'->split(',') // ['tea', 'milk', 'juice']
echo 'tea milk'->split() // ['tea', 'milk']
echo 'a, b,c'->split(/\s*,\s*/) // ['a', 'b', 'c'] because the spaces around each comma go too
The text without one exact prefix, suffix or both, where present: 'v1.2'->strip(prefix: 'v'), 'a.txt'->strip(suffix: '.txt').
->strip(prefix?, suffix?) takes off one exact prefix, suffix or both, where they are there. Unlike ->trim() it removes the whole piece once, not each character:
<echo value="'v1.2'->strip(prefix: 'v')" /> <!-- '1.2' -->
<echo value="'notes.txt'->strip(suffix: '.txt')" /> <!-- 'notes' -->
<echo value="'[tea]'->strip(prefix: '[', suffix: ']')" /> <!-- 'tea' -->
<echo value="'tea'->strip(prefix: 'x')" /> <!-- 'tea' because there is no x to take off -->
echo 'v1.2'->strip(prefix: 'v') // '1.2'
echo 'notes.txt'->strip(suffix: '.txt') // 'notes'
echo '[tea]'->strip(prefix: '[', suffix: ']') // 'tea'
echo 'tea'->strip(prefix: 'x') // 'tea' because there is no x to take off
The text encoded as base64. With url: true, it is URL-safe base64 without padding.
->to_base64(url?) encodes text as base64, which uses only letters, digits, +, / and =, so it can travel where other characters can't, such as an HTTP header. With url, it uses - and _ instead and leaves off the = padding, so it fits in a URL. The result is a base64 value, whose ->decode() gives the text back:
<echo value="'tea'->to_base64()" /> <!-- 'dGVh' -->
<echo value="'tea?'->to_base64()" /> <!-- 'dGVhPw==' -->
<echo value="'tea?'->to_base64(url)" /> <!-- 'dGVhPw' because url leaves off the padding -->
<echo value="'tea'->to_base64()->decode()" /> <!-- 'tea' because the base64 value decodes back to the text -->
echo 'tea'->to_base64() // 'dGVh'
echo 'tea?'->to_base64() // 'dGVhPw=='
echo 'tea?'->to_base64(url) // 'dGVhPw' because url leaves off the padding
echo 'tea'->to_base64()->decode() // 'tea' because the base64 value decodes back to the text
Reads the text as a date: '2026-11-22'->to_date(), or with the way it is written, '22-11-2026'->to_date(dd-MM-yyyy).
->to_date(format?) reads text as a date. Dates written the ISO way, such as '2026-11-22' or '2026-11-22 14:30', need no format; for any other way, give the pattern it is written in:
<let name="day" value="'2026-11-22'->to_date()" />
<echo value="$day.year" /> <!-- 2026 -->
<echo value="'22-11-2026'->to_date(dd-MM-yyyy).month" /> <!-- 11 because the pattern says the month is in the middle -->
$day = '2026-11-22'->to_date()
echo $day.year // 2026
echo '22-11-2026'->to_date(dd-MM-yyyy).month // 11 because the pattern says the month is in the middle
The text as a whole number, or default when it isn't one.
->to_int(default?) reads text as a whole number, dropping anything after the decimal point. When the text isn't a number, you get default; without one, that is a Type error, so pass a default for text you aren't sure of:
<echo value="'42'->to_int()" /> <!-- 42 -->
<echo value="'3.7'->to_int()" /> <!-- 3 because the .7 is dropped -->
<echo value="'abc'->to_int(-1)" /> <!-- -1 because abc isn't a number -->
echo '42'->to_int() // 42
echo '3.7'->to_int() // 3 because the .7 is dropped
echo 'abc'->to_int(-1) // -1 because abc isn't a number
The text as a number, or default when it isn't one.
->to_number(default?) reads text as a number, decimals and all. When the text isn't a number, you get default; without one, that is a Type error that says so:
<echo value="'3.7'->to_number()" /> <!-- 3.7 -->
<echo value="'x'->to_number(0)" /> <!-- 0 because x isn't a number, so the default is used -->
<echo value="'x'->to_number(null)" /> <!-- null -->
echo '3.7'->to_number() // 3.7
echo 'x'->to_number(0) // 0 because x isn't a number, so the default is used
echo 'x'->to_number(null) // null
The text without spaces (or the given characters) at either end, or only at the start or the end: ->trim(start), ->trim('/', end).
->trim(characters?, start?, end?) takes spaces, tabs and line breaks off both ends, or the characters you give. With start or end it trims only that end:
<echo value="' tea '->trim()" /> <!-- 'tea' -->
<echo value="'//path//'->trim('/')" /> <!-- 'path' -->
<echo value="' tea '->trim(start)" /> <!-- 'tea ' because only the start is trimmed -->
echo ' tea '->trim() // 'tea'
echo '//path//'->trim('/') // 'path'
echo ' tea '->trim(start) // 'tea ' because only the start is trimmed
Parameter
Takes
charactersoptional
any value
startoptional
a flag: start or not start
endoptional
a flag: end or not end
Arguments can be named: ->trim(…, start: …, end: …).
Shortens the text to length, adding suffix (… by default).
->truncate(length, suffix?) keeps the first length characters and adds a suffix, … unless you give another, when there was more. Text that already fits is left alone:
The words in the text, as a list, without spaces or punctuation. Letters in any script count, and don't or well-known is one word.
->words() gives the words in the text, without the spaces and punctuation between them. Letters in any script count, and don't or well-known stay one word:
<echo value="'Hello, world!'->words()" /> <!-- ['Hello', 'world'] -->
<echo value=""Don't stop"->words()->count()" /> <!-- 2 because don't is one word -->
echo 'Hello, world!'->words() // ['Hello', 'world']
echo "Don't stop"->words()->count() // 2 because don't is one word
Example
<echo>{ 'Hello, world! A well-known phrase.'->words() }</echo>
echo 'Hello, world! A well-known phrase.'->words()
The text with line breaks between words so no line is longer than width (unless one word is). Works well with @terminal_width().
->wrap(width) puts line breaks between words so that no line is longer than width, unless a single word is. It suits text for a terminal, such as one @terminal_width() wide:
<let name="lines" value="'Ann went home early'->wrap(width: 9)->lines()" />
<echo value="$lines" /> <!-- ['Ann went', 'home', 'early'] because home early would be 10 characters -->
$lines = 'Ann went home early'->wrap(width: 9)->lines()
echo $lines // ['Ann went', 'home', 'early'] because home early would be 10 characters
The code as highlighted HTML for a <pre>, coloured with the grammars the VS Code extension uses: each token in a <span class="hl-kw"> (hl-com, hl-str, hl-num, hl-kw, hl-op, hl-fn, hl-type, hl-var, hl-tag, hl-attr, hl-expr, hl-re) for a stylesheet to colour. lang is kscript (the default), ks.xml, html (a page), ks.css, text, or a language VS Code knows: css, js, ts, json, sql, sh, yaml, python...