diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-21 14:45:39 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-21 14:45:39 -0400 |
| commit | 6ee5af0a16a5f1a32eb933e30d8b86ff4e691beb (patch) | |
| tree | a4ccc48bef576be1cfd4d30342eebc684474e8f5 /api/api.md | |
| parent | 868ca31562dcc5d484d8f015adfa173c0a43c415 (diff) | |
Add short descriptions for API methods to improve manpages
Diffstat (limited to 'api/api.md')
| -rw-r--r-- | api/api.md | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -189,7 +189,7 @@ sleep(1.5) Bool.parse : func(text: Text -> Bool?) ``` -Converts a string representation of a boolean value into a boolean. Acceptable boolean values are case-insensitive variations of `yes`/`no`, `y`/`n`, `true`/`false`, `on`/`off`. +Converts a text representation of a boolean value into a boolean. Acceptable boolean values are case-insensitive variations of `yes`/`no`, `y`/`n`, `true`/`false`, `on`/`off`. Argument | Type | Description | Default ---------|------|-------------|--------- @@ -4664,13 +4664,14 @@ last | `Int` | The index of the last grapheme cluster to include (1-indexed). | ## Text.translate ```tomo -Text.translate : func(translations: {Text=Text} -> Text) +Text.translate : func(text: Text, translations: {Text=Text} -> Text) ``` Takes a table mapping target texts to their replacements and performs all the replacements in the table on the whole text. At each position, the first matching replacement is applied and the matching moves on to *after* the replacement text, so replacement text is not recursively modified. See Text.replace() for more information about replacement behavior. Argument | Type | Description | Default ---------|------|-------------|--------- +text | `Text` | The text to be translated. | - translations | `{Text=Text}` | A table mapping from target text to its replacement. | - **Return:** The text with all occurrences of the targets replaced with their corresponding replacement text. @@ -4679,12 +4680,12 @@ translations | `{Text=Text}` | A table mapping from target text to its replaceme **Example:** ```tomo >> "A <tag> & an amperand".translate({ -"&" = "&", -"<" = "<", -">" = ">", -'"" = """, -"'" = "'", -} + "&" = "&", + "<" = "<", + ">" = ">", + '"" = """, + "'" = "'", +}) = "A <tag> & an ampersand" ``` |
