diff options
| -rw-r--r-- | docs/src/reference/types.md | 3 | ||||
| -rw-r--r-- | tests/typ/compiler/string.typ | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/docs/src/reference/types.md b/docs/src/reference/types.md index cc30ef1f..a5741337 100644 --- a/docs/src/reference/types.md +++ b/docs/src/reference/types.md @@ -219,7 +219,8 @@ Typst provides utility methods for string manipulation. Many of these methods either a string or a [regular expression]($func/regex). This makes the methods quite versatile. -All lengths and indices are expressed in terms of UTF-8 bytes. +All lengths and indices are expressed in terms of UTF-8 characters. Indices are +zero-based and negative indices wrap around to the end of the string. ### Example ```example diff --git a/tests/typ/compiler/string.typ b/tests/typ/compiler/string.typ index 0bc3a9be..ddd0f7ff 100644 --- a/tests/typ/compiler/string.typ +++ b/tests/typ/compiler/string.typ @@ -24,6 +24,8 @@ // Test the `at` method. #test("Hello".at(1), "e") #test("Hello".at(4), "o") +#test("Hello".at(-1), "o") +#test("Hello".at(-2), "l") #test("Hey: 🏳️🌈 there!".at(5), "🏳️🌈") --- |
