diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-19 14:35:34 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-19 14:35:34 -0400 |
| commit | 67fd3c725e6511adf70345f0733ec0b948477a11 (patch) | |
| tree | 913d9f30d8ce3614a9ae3715281f8804323b24ff /docs/text.md | |
| parent | 0974d632c3dda7874f01c58bfc342b73cd1634a4 (diff) | |
Make API documentation into YAML files and autogenerate markdown files
and manpages from those.
Diffstat (limited to 'docs/text.md')
| -rw-r--r-- | docs/text.md | 976 |
1 files changed, 3 insertions, 973 deletions
diff --git a/docs/text.md b/docs/text.md index 35196d25..45ee9a09 100644 --- a/docs/text.md +++ b/docs/text.md @@ -145,7 +145,7 @@ These text literals can be used as interpolation values with or without parentheses, depending on which you find more readable: ``` -two_lines := "one$(\n)two" +two_lines := "one\ntwo" has_quotes := "some $\"quotes$\" here" ``` @@ -262,976 +262,6 @@ created that has text with the codepoint `U+E9` as a key, then a lookup with the same text but with `U+65 U+301` instead of `U+E9` will still succeed in finding the value because the two texts are equivalent under normalization. -## Text Functions +# API -- [`func as_c_string(text: Text -> CString)`](#as_c_string) -- [`func at(text: Text, index: Int -> Text)`](#at) -- [`func by_line(text: Text -> func(->Text?))`](#by_line) -- [`func by_split(text: Text, delimiter: Text = "" -> func(->Text?))`](#by_split) -- [`func by_split_any(text: Text, delimiters: Text = " $\t\r\n" -> func(->Text?))`](#by_split_any) -- [`func bytes(text: Text -> [Byte])`](#bytes) -- [`func caseless_equals(a: Text, b:Text, language:Text = "C" -> Bool)`](#caseless_equals) -- [`func codepoint_names(text: Text -> [Text])`](#codepoint_names) -- [`func ends_with(text: Text, suffix: Text -> Bool)`](#ends_with) -- [`func from(text: Text, first: Int -> Text)`](#from) -- [`func from_bytes(codepoints: [Int32] -> [Text])`](#from_bytes) -- [`func from_c_string(str: CString -> Text)`](#from_c_string) -- [`func from_codepoint_names(codepoint_names: [Text] -> [Text])`](#from_codepoint_names) -- [`func from_codepoints(codepoints: [Int32] -> [Text])`](#from_codepoints) -- [`func has(text: Text, target: Text -> Bool)`](#has) -- [`func join(glue: Text, pieces: [Text] -> Text)`](#join) -- [`func split(text: Text, delimiter: Text = "" -> [Text])`](#split) -- [`func split_any(text: Text, delimiters: Text = " $\t\r\n" -> [Text])`](#split_any) -- [`func middle_pad(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text)`](#middle_pad) -- [`func left_pad(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text)`](#left_pad) -- [`func lines(text: Text -> [Text])`](#lines) -- [`func lower(text: Text, language: Text = "C" -> Text)`](#lower) -- [`func quoted(text: Text, color: Bool = no, quotation_mark: Text = '"' -> Text)`](#quoted) -- [`func repeat(text: Text, count:Int -> Text)`](#repeat) -- [`func replace(text: Text, target: Text, replacement: Text -> Text)`](#replace) -- [`func reversed(text: Text -> Text)`](#reversed) -- [`func right_pad(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text)`](#right_pad) -- [`func slice(text: Text, from: Int = 1, to: Int = -1 -> Text)`](#slice) -- [`func starts_with(text: Text, prefix: Text -> Bool)`](#starts_with) -- [`func title(text: Text, language: Text = "C" -> Text)`](#title) -- [`func to(text: Text, last: Int -> Text)`](#to) -- [`func translate(translations:{Text=Text} -> Text)`](#translate) -- [`func trim(text: Text, to_trim: Text = " $\t\r\n", left: Bool = yes, right: Bool = yes -> Text)`](#trim) -- [`func upper(text: Text, language: Text "C" -> Text)`](#upper) -- [`func utf32_codepoints(text: Text -> [Int32])`](#utf32_codepoints) -- [`func width(text: Text -> Int)`](#width) -- [`func without_prefix(text: Text, prefix: Text -> Text)`](#without_prefix) -- [`func without_suffix(text: Text, suffix: Text -> Text)`](#without_suffix) - ----------------- - -### `as_c_string` -Converts a `Text` value to a C-style string. - -```tomo -func as_c_string(text: Text -> CString) -``` - -- `text`: The text to be converted to a C-style string. - -**Returns:** -A C-style string (`CString`) representing the text. - -**Example:** -```tomo ->> "Hello".as_c_string() -= CString("Hello") -``` - ---- - -### `at` -Get the graphical cluster at a given index. This is similar to `str[i]` with -ASCII text, but has more correct behavior for unicode text. - -```tomo -func at(text: Text, index: Int -> Text) -``` - -- `text`: The text from which to get a cluster. -- `index`: The index of the graphical cluster (1-indexed). - -**Returns:** -A `Text` with the single graphical cluster at the given index. Note: negative -indices are counted from the back of the text, so `-1` means the last cluster, -`-2` means the second-to-last, and so on. - -**Example:** -```tomo ->> "Amélie".at(3) -= "é" -``` - ---- - -### `by_line` -Returns an iterator function that can be used to iterate over the lines in a -text. - -```tomo -func by_line(text: Text -> func(->Text?)) -``` - -- `text`: The text to be iterated over, line by line. - -**Returns:** -An iterator function that returns one line at a time, until it runs out and -returns `none`. **Note:** this function ignores a trailing newline if there is -one. If you don't want this behavior, use `text.by_split($/{1 nl}/)` instead. - -**Example:** -```tomo -text := " - line one - line two -" -for line in text.by_line() - # Prints: "line one" then "line two": - say(line) -``` - ---- - -### `by_split` -Returns an iterator function that can be used to iterate over text separated by -a delimiter. -**Note:** to split based on a set of delimiters, use [`by_split_any()`](#by_split_any). - -```tomo -func by_split(text: Text, delimiter: Text = "" -> func(->Text?)) -``` - -- `text`: The text to be iterated over in delimited chunks. -- `delimiter`: An exact delimiter to use for splitting the text. If an empty text - is given, then each split will be the graphical clusters of the text. - -**Returns:** -An iterator function that returns one chunk of text at a time, separated by the -given delimiter, until it runs out and returns `none`. **Note:** using an empty -delimiter (the default) will iterate over single grapheme clusters in the text. - -**Example:** -```tomo -text := "one,two,three" -for chunk in text.by_split(",") - # Prints: "one" then "two" then "three": - say(chunk) -``` - ---- - -### `by_split_any` -Returns an iterator function that can be used to iterate over text separated by -one or more characters (grapheme clusters) from a given text of delimiters. -**Note:** to split based on an exact delimiter, use [`by_split()`](#by_split). - -```tomo -func by_split_any(text: Text, delimiters: Text = " $\t\r\n" -> func(->Text?)) -``` - -- `text`: The text to be iterated over in delimited chunks. -- `delimiters`: An text containing multiple delimiter characters (grapheme clusters) - to use for splitting the text. - -**Returns:** -An iterator function that returns one chunk of text at a time, separated by the -given delimiter characters, until it runs out and returns `none`. - -**Example:** -```tomo -text := "one,two,;,three" -for chunk in text.by_split_any(",;") - # Prints: "one" then "two" then "three": - say(chunk) -``` - ---- - -### `bytes` -Converts a `Text` value to a list of bytes representing a UTF8 encoding of -the text. - -```tomo -func bytes(text: Text -> [Byte]) -``` - -- `text`: The text to be converted to UTF8 bytes. - -**Returns:** -A list of bytes (`[Byte]`) representing the text in UTF8 encoding. - -**Example:** -```tomo ->> "Amélie".bytes() -= [65[B], 109[B], 195[B], 169[B], 108[B], 105[B], 101[B]] : [Byte] -``` - ---- - -### `caseless_equals` -Checks whether two texts are equal, ignoring the casing of the letters (i.e. -case-insensitive comparison). - -```tomo -func caseless_equals(a: Text, b:Text, language:Text = "C" -> Bool) -``` - -- `a`: The first text to compare case-insensitively. -- `b`: The second text to compare case-insensitively. -- `language`: The ISO 639 language code for which casing rules to use. - -**Returns:** -`yes` if `a` and `b` are equal to each other, ignoring casing, otherwise `no`. - -**Example:** -```tomo ->> "A".caseless_equals("a") -= yes - -# Turkish lowercase "I" is "ı" (dotless I), not "i" ->> "I".caseless_equals("i", language="tr_TR") -= no -``` - ---- - -### `codepoint_names` -Returns a list of the names of each codepoint in the text. - -```tomo -func codepoint_names(text: Text -> [Text]) -``` - -- `text`: The text from which to extract codepoint names. - -**Returns:** -A list of codepoint names (`[Text]`). - -**Example:** -```tomo ->> "Amélie".codepoint_names() -= ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E WITH ACUTE", "LATIN SMALL LETTER L", "LATIN SMALL LETTER I", "LATIN SMALL LETTER E"] -``` - ---- - -### `ends_with` -Checks if the `Text` ends with a literal suffix text. - -```tomo -func ends_with(text: Text, suffix: Text -> Bool) -``` - -- `text`: The text to be searched. -- `suffix`: The literal suffix text to check for. - -**Returns:** -`yes` if the text has the target, `no` otherwise. - -**Example:** -```tomo ->> "hello world".ends_with("world") -= yes -``` - ---- - -### `from` -Get a slice of the text, starting at the given position. - -```tomo -func from(text: Text, first: Int -> Text) -``` - -- `text`: The text to be sliced. -- `frist`: The index of the first grapheme cluster to include (1-indexed). - -**Returns:** -The text from the given grapheme cluster to the end of the text. Note: a -negative index counts backwards from the end of the text, so `-1` refers to the -last cluster, `-2` the second-to-last, etc. Slice ranges will be truncated to -the length of the text. - -**Example:** -```tomo ->> "hello".from(2) -= "ello" - ->> "hello".from(-2) -= "lo" -``` - ---- - -### `from_bytes` -Returns text that has been constructed from the given UTF8 bytes. Note: the -text will be normalized, so the resulting text's UTF8 bytes may not exactly -match the input. - -```tomo -func from_bytes(bytes: [Byte] -> [Text]) -``` - -- `bytes`: The UTF-8 bytes of the desired text. - -**Returns:** -A new text based on the input UTF8 bytes after normalization has been applied. - -**Example:** -```tomo ->> Text.from_bytes([195[B], 133[B], 107[B], 101[B]]) -= "Åke" -``` - ---- - -### `from_c_string` -Converts a C-style string to a `Text` value. - -```tomo -func from_c_string(str: CString -> Text) -``` - -- `str`: The C-style string to be converted. - -**Returns:** -A `Text` value representing the C-style string. - -**Example:** -```tomo ->> Text.from_c_string(CString("Hello")) -= "Hello" -``` - ---- - -### `from_codepoint_names` -Returns text that has the given codepoint names (according to the Unicode -specification) as its codepoints. Note: the text will be normalized, so the -resulting text's codepoints may not exactly match the input codepoints. - -```tomo -func from_codepoint_names(codepoint_names: [Text] -> [Text]) -``` - -- `codepoint_names`: The names of each codepoint in the desired text. Names - are case-insentive. - -**Returns:** -A new text with the specified codepoints after normalization has been applied. -Any invalid names are ignored. - -**Example:** -```tomo ->> Text.from_codepoint_names([ - "LATIN CAPITAL LETTER A WITH RING ABOVE", - "LATIN SMALL LETTER K", - "LATIN SMALL LETTER E", -] -= "Åke" -``` - ---- - -### `from_codepoints` -Returns text that has been constructed from the given UTF32 codepoints. Note: -the text will be normalized, so the resulting text's codepoints may not exactly -match the input codepoints. - -```tomo -func from_codepoints(codepoints: [Int32] -> [Text]) -``` - -- `codepoints`: The UTF32 codepoints in the desired text. - -**Returns:** -A new text with the specified codepoints after normalization has been applied. - -**Example:** -```tomo ->> Text.from_codepoints([197[32], 107[32], 101[32]]) -= "Åke" -``` - ---- - -### `has` -Checks if the `Text` contains some target text. - -```tomo -func has(text: Text, target: Text -> Bool) -``` - -- `text`: The text to be searched. -- `target`: The text to search for. - -**Returns:** -`yes` if the target text is found, `no` otherwise. - -**Example:** -```tomo ->> "hello world".has("wo") -= yes ->> "hello world".has("xxx") -= no -``` - ---- - -### `join` -Joins a list of text pieces with a specified glue. - -```tomo -func join(glue: Text, pieces: [Text] -> Text) -``` - -- `glue`: The text used to join the pieces. -- `pieces`: The list of text pieces to be joined. - -**Returns:** -A single `Text` value with the pieces joined by the glue. - -**Example:** -```tomo ->> ", ".join(["one", "two", "three"]) -= "one, two, three" -``` - ---- - -### `middle_pad` -Pad some text on the left and right side so it reaches a target width. - -```tomo -func middle_pad(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text) -``` - -- `text`: The text to pad. -- `width`: The target width. -- `pad`: The padding text (default: `" "`). -- `language`: The ISO 639 language code for which character width to use. - -**Returns:** -Text with length at least `width`, with extra padding on the left and right as -needed. If `pad` has length greater than 1, it may be partially repeated to -reach the exact desired length. - -**Example:** -```tomo ->> "x".middle_pad(6) -= " x " ->> "x".middle_pad(10, "ABC") -= "ABCAxABCAB" -``` - ---- - -### `left_pad` -Pad some text on the left side so it reaches a target width. - -```tomo -func left_pad(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text) -``` - -- `text`: The text to pad. -- `width`: The target width. -- `pad`: The padding text (default: `" "`). -- `language`: The ISO 639 language code for which character width to use. - -**Returns:** -Text with length at least `width`, with extra padding on the left as needed. If -`pad` has length greater than 1, it may be partially repeated to reach the -exact desired length. - -**Example:** -```tomo ->> "x".left_pad(5) -= " x" ->> "x".left_pad(5, "ABC") -= "ABCAx" -``` - ---- - -### `lines` -Splits the text into a list of lines of text, preserving blank lines, -ignoring trailing newlines, and handling `\r\n` the same as `\n`. - -```tomo -func lines(text: Text -> [Text]) -``` - -- `text`: The text to be split into lines. - -**Returns:** -A list of substrings resulting from the split. - -**Example:** -```tomo ->> "one$(\n)two$(\n)three".lines() -= ["one", "two", "three"] ->> "one$(\n)two$(\n)three$(\n)".lines() -= ["one", "two", "three"] ->> "one$(\n)two$(\n)three$(\n\n)".lines() -= ["one", "two", "three", ""] ->> "one$(\r\n)two$(\r\n)three$(\r\n)".lines() -= ["one", "two", "three"] ->> "".lines() -= [] -``` - ---- - -### `lower` -Converts all characters in the text to lowercase. - -```tomo -func lower(text: Text, language: Text = "C" -> Text) -``` - -- `text`: The text to be converted to lowercase. -- `language`: The ISO 639 language code for which casing rules to use. - -**Returns:** -The lowercase version of the text. - -**Example:** -```tomo ->> "AMÉLIE".lower() -= "amélie" - ->> "I".lower(language="tr_TR") ->> "ı" -``` - ---- - -### `quoted` -Formats the text with quotation marks and escapes. - -```tomo -func quoted(text: Text, color: Bool = no, quotation_mark: Text = '"' -> Text) -``` - -- `text`: The text to be quoted. -- `color`: Whether to add color formatting (default is `no`). -- `quotation_mark`: The quotation mark to use (default is `"`). - -**Returns:** -The text formatted as a quoted text. - -**Example:** -```tomo ->> "one$(\n)two".quoted() -= "\"one\\ntwo\"" -``` - ---- - -### `repeat` -Repeat some text multiple times. - -```tomo -func repeat(text: Text, count:Int -> Text) -``` - -- `text`: The text to repeat. -- `count`: The number of times to repeat it. (Negative numbers are equivalent to zero). - -**Returns:** -The text repeated the given number of times. - -**Example:** -```tomo ->> "Abc".repeat(3) -= "AbcAbcAbc" -``` - ---- - -### `replace` -Replaces occurrences of a target text with a replacement text. - -```tomo -func replace(text: Text, target: Text, replacement: Text -> Text) -``` - -- `text`: The text in which to perform replacements. -- `target`: The target text to be replaced. -- `replacement`: The text to replace the target with. - -**Returns:** -The text with occurrences of the target replaced. - -**Example:** -```tomo ->> "Hello world".replace("world", "there") -= "Hello there" -``` - ---- - -### `reversed` -Return a text that has the grapheme clusters in reverse order. - -```tomo -func reversed(text: Text -> Text) -``` - -- `text`: The text to reverse. - -**Returns:** -A reversed version of the text. - -**Example:** -```tomo ->> "Abc".reversed() -= "cbA" -``` - ---- - -### `right_pad` -Pad some text on the right side so it reaches a target width. - -```tomo -func right_pad(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text) -``` - -- `text`: The text to pad. -- `width`: The target width. -- `pad`: The padding text (default: `" "`). -- `language`: The ISO 639 language code for which character width to use. - -**Returns:** -Text with length at least `width`, with extra padding on the right as needed. If -`pad` has length greater than 1, it may be partially repeated to reach the -exact desired length. - -**Example:** -```tomo ->> "x".right_pad(5) -= "x " ->> "x".right_pad(5, "ABC") -= "xABCA" -``` - ---- - -### `slice` -Get a slice of the text. - -```tomo -func slice(text: Text, from: Int = 1, to: Int = -1 -> Text) -``` - -- `text`: The text to be sliced. -- `from`: The index of the first grapheme cluster to include (1-indexed). -- `to`: The index of the last grapheme cluster to include (1-indexed). - -**Returns:** -The text that spans the given grapheme cluster indices. Note: a negative index -counts backwards from the end of the text, so `-1` refers to the last cluster, -`-2` the second-to-last, etc. Slice ranges will be truncated to the length of -the text. - -**Example:** -```tomo ->> "hello".slice(2, 3) -= "el" - ->> "hello".slice(to=-2) -= "hell" - ->> "hello".slice(from=2) -= "ello" -``` - ---- - -### `split` -Splits the text into a list of substrings based on exact matches of a delimiter. -**Note:** to split based on a set of delimiter characters, use [`split_any()`](#split_any). - -```tomo -func split(text: Text, delimiter: Text = "" -> [Text]) -``` - -- `text`: The text to be split. -- `delimiter`: The delimiter used to split the text. If the delimiter is the - empty text, the text will be split into individual grapheme clusters. - -**Returns:** -A list of subtexts resulting from the split. - -**Example:** -```tomo ->> "one,two,,three".split(",") -= ["one", "two", "", "three"] - ->> "abc".split() -= ["a", "b", "c"] -``` - ---- - -### `split_any` -Splits the text into a list of substrings at one or more occurrences of a set -of delimiter characters (grapheme clusters). -**Note:** to split based on an exact delimiter, use [`split()`](#split). - -```tomo -func split_any(text: Text, delimiters: Text = " $\t\r\n" -> [Text]) -``` - -- `text`: The text to be split. -- `delimiters`: A text containing multiple delimiters to be used for - splitting the text into chunks. - -**Returns:** -A list of subtexts resulting from the split. - -**Example:** -```tomo ->> "one, two,,three".split_any(", ") -= ["one", "two", "three"] -``` - ---- - -### `starts_with` -Checks if the `Text` starts with a literal prefix text. - -```tomo -func starts_with(text: Text, prefix: Text -> Bool) -``` - -- `text`: The text to be searched. -- `prefix`: The literal prefix text to check for. - -**Returns:** -`yes` if the text has the given prefix, `no` otherwise. - -**Example:** -```tomo ->> "hello world".starts_with("hello") -= yes -``` - ---- - -### `title` -Converts the text to title case (capitalizing the first letter of each word). - -```tomo -func title(text: Text, language: Text = "C" -> Text) -``` - -- `text`: The text to be converted to title case. -- `language`: The ISO 639 language code for which casing rules to use. - -**Returns:** -The text in title case. - -**Example:** -```tomo ->> "amélie".title() -= "Amélie" - -# In Turkish, uppercase "i" is "İ" ->> "i".title(language="tr_TR") -= "İ" -``` - ---- - -### `to` -Get a slice of the text, ending at the given position. - -```tomo -func to(text: Text, last: Int -> Text) -``` - -- `text`: The text to be sliced. -- `last`: The index of the last grapheme cluster to include (1-indexed). - -**Returns:** -The text up to and including the given grapheme cluster. Note: a negative index -counts backwards from the end of the text, so `-1` refers to the last cluster, -`-2` the second-to-last, etc. Slice ranges will be truncated to the length of -the text. - -**Example:** -```tomo ->> "goodbye".to(3) -= "goo" - ->> "goodbye".to(-2) -= "goodby" -``` - ---- - -### `translate` -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 -[`replace()`](#replace) for more information about replacement behavior. - -```tomo -func translate(translations:{Text=Text} -> Text) -``` - -- `text`: The text in which to perform replacements. -- `translations`: A table mapping from target text to its replacement. - -**Returns:** -The text with all occurrences of the targets replaced with their corresponding -replacement text. - -**Example:** -```tomo ->> "A <tag> & an amperand".translate({ - "&" = "&", - "<" = "<", - ">" = ">", - '"" = """, - "'" = "'", -} -= "A <tag> & an ampersand" -``` - ---- - -### `trim` -Trims the given characters (grapheme clusters) from the left and/or right side of the text. - -```tomo -func trim(text: Text, to_trim: Text = " $\t\r\n", left: Bool = yes, right: Bool = yes -> Text) -``` - -- `text`: The text to be trimmed. -- `to_trim`: The characters to remove from the left/right of the text. -- `left`: Whether or not to trim from the front of the text. -- `right`: Whether or not to trim from the back of the text. - -**Returns:** -The text without the trim characters at either end. - -**Example:** -```tomo ->> " x y z $(\n)".trim() -= "x y z" - ->> "one,".trim(",") -= "one" - ->> " xyz ".trim(right=no) -= "xyz " -``` - ---- - -### `upper` -Converts all characters in the text to uppercase. - -```tomo -func upper(text: Text, language: Text = "C" -> Text) -``` - -- `text`: The text to be converted to uppercase. -- `language`: The ISO 639 language code for which casing rules to use. - -**Returns:** -The uppercase version of the text. - -**Example:** -```tomo ->> "amélie".upper() -= "AMÉLIE" - -# In Turkish, uppercase "i" is "İ" ->> "i".upper(language="tr_TR") -= "İ" -``` - ---- - -### `utf32_codepoints` -Returns a list of Unicode code points for UTF32 encoding of the text. - -```tomo -func utf32_codepoints(text: Text -> [Int32]) -``` - -- `text`: The text from which to extract Unicode code points. - -**Returns:** -A list of 32-bit integer Unicode code points (`[Int32]`). - -**Example:** -```tomo ->> "Amélie".utf32_codepoints() -= [65[32], 109[32], 233[32], 108[32], 105[32], 101[32]] : [Int32] -``` - ---- - -### `width` -Returns the display width of the text as seen in a terminal with appropriate -font rendering. This is usually the same as the text's `.length`, but there are -some characters like emojis that render wider than 1 cell. - -**Warning:** This will not always be exactly accurate when your terminal's font -rendering can't handle some unicode displaying correctly. - -```tomo -func width(text: Text -> Int) -``` - -- `text`: The text whose length you want. - -**Returns:** -An integer representing the display width of the text. - -**Example:** -```tomo ->> "Amélie".width() -= 6 ->> "🤠".width() -= 2 -``` - ---- - -### `without_prefix` -Returns the text with a given prefix removed (if present). - -```tomo -func without_prefix(text: Text, prefix: Text -> Text) -``` - -- `text`: The text to remove the prefix from. -- `prefix`: The prefix to remove. - -**Returns:** -A text without the given prefix (if present) or the unmodified text if the -prefix is not present. - -**Example:** -```tomo ->> "foo:baz".without_prefix("foo:") -= "baz" ->> "qux".without_prefix("foo:") -= "qux" -``` - ---- - -### `without_suffix` -Returns the text with a given suffix removed (if present). - -```tomo -func without_suffix(text: Text, suffix: Text -> Text) -``` - -- `text`: The text to remove the suffix from. -- `suffix`: The suffix to remove. - -**Returns:** -A text without the given suffix (if present) or the unmodified text if the -suffix is not present. - -**Example:** -```tomo ->> "baz.foo".without_suffix(".foo") -= "baz" ->> "qux".without_suffix(".foo") -= "qux" -``` +[API documentation](../api/text.md) |
