summaryrefslogtreecommitdiff
path: root/docs/reference/scripting.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/reference/scripting.md')
-rw-r--r--docs/reference/scripting.md18
1 files changed, 11 insertions, 7 deletions
diff --git a/docs/reference/scripting.md b/docs/reference/scripting.md
index ee9478bb..6e64cebb 100644
--- a/docs/reference/scripting.md
+++ b/docs/reference/scripting.md
@@ -188,13 +188,6 @@ together into one larger array.
For loops can iterate over a variety of collections:
-- `{for letter in "abc" {..}}` \
- Iterates over the characters of the [string]($str).
- (Technically, iterates over the grapheme clusters of the string. Most of the
- time, a grapheme cluster is just a single character/codepoint. However, some
- constructs like flag emojis that consist of multiple codepoints are still only
- one cluster.)
-
- `{for value in array {..}}` \
Iterates over the items in the [array]($array). The destructuring syntax
described in [Let binding]($scripting/#bindings) can also be used here.
@@ -203,6 +196,17 @@ For loops can iterate over a variety of collections:
Iterates over the key-value pairs of the [dictionary]($dictionary).
The pairs can also be destructured by using `{for (key, value) in dict {..}}`.
+- `{for letter in "abc" {..}}` \
+ Iterates over the characters of the [string]($str). Technically, it iterates
+ over the grapheme clusters of the string. Most of the time, a grapheme cluster
+ is just a single codepoint. However, a grapheme cluster could contain multiple
+ codepoints, like a flag emoji.
+
+- `{for byte in bytes("😀") {..}}` \
+ Iterates over the [bytes]($bytes), which can be converted from a [string]($str)
+ or [read]($read) from a file without encoding. Each byte value is an
+ [integer]($int) between `{0}` and `{255}`.
+
To control the execution of the loop, Typst provides the `{break}` and
`{continue}` statements. The former performs an early exit from the loop while
the latter skips ahead to the next iteration of the loop.