Tanguv0.32.0
/string/regex/text/text/case/text/cmark/i18n/html

Text, strings & localization

String manipulation (/string), regular expressions (/regex), CommonMark (/text/cmark), HTML escaping, and ICU4X (/i18n).

Module /string #

UTF-8 string manipulation: case conversion, trimming, padding, splitting, joining, and substring search.

(use /string)

byte-count-of #

(Func String Any)

Exported function in /string.

byte-slice #

(Func [String Int Int] Any)

Exported function in /string.

chars #

(chars str) -> Array

Converts string into an array of individual Unicode Char elements.

(chars "tan") ; -> ['t' 'a' 'n']

contains? #

(contains? str substring) -> Bool

Returns true if str contains the given substring.

(contains? "hello world" "world") ; -> true

count-of #

(Func String Any)

Exported function in /string.

ends-with? #

(ends-with? str suffix) -> Bool

Returns true if str ends with suffix.

(ends-with? "main.tan" ".tan") ; -> true

format-string #

(Func Any Any)

Exported function in /string.

ignore-case-contains? #

(string/ignore-case-contains? str substring) -> Bool

Returns true if str contains the given substring (case-insensitive, zero-allocation for ASCII).

(use {ignore-case-contains?} /string)
(ignore-case-contains? "TikTok.com" "tiktok.com") ; -> true

ignore-case-index-of #

(string/ignore-case-index-of str sub) -> (Or Int)

Returns 0-based character index of substring sub in str (case-insensitive), or () if not found.

(use {ignore-case-index-of} /string)
(ignore-case-index-of "Hello World" "world") ; -> 6

index-of #

(Func [String String] Any)

Exported function in /string.

is-blank? #

(string/is-blank? x) -> Bool

Returns true if x is (), "", or contains only whitespace characters.

(use {is-blank?} /string)
(is-blank? "   ") ; -> true

last-index-of #

(string/last-index-of str sub) -> (Or Int)

Returns last 0-based character index of substring sub in str (optionally up to end-index), or () if not found.

(use {last-index-of} /string)
(last-index-of "hello world" "o") ; -> 7

pad-left #

(pad-left str width) -> String

Pads string on the left with spaces until it reaches width.

(pad-left "42" 5) ; -> "   42"

pad-right #

(pad-right str width) -> String

Pads string on the right with spaces until it reaches width.

(pad-right "42" 5) ; -> "42   "

repeat #

(Func [String Int] String)

Exported function in /string.

replace #

(replace str from to) -> String

Replaces all occurrences of from with to in str.

(replace "foo bar" "bar" "baz") ; -> "foo baz"

slice #

(slice str start) -> String

Returns substring from start to end index. Supports negative indices and Range literals like (slice str 0..5).

(slice "hello" 0 2) ; -> "he"

split #

(split str delimiter) -> List

Splits str by separator delimiter, returning a List of substrings.

(split "a,b,c" ",") ; -> ["a" "b" "c"]

starts-with? #

(starts-with? str prefix) -> Bool

Returns true if str begins with prefix.

(starts-with? "/api/users" "/api") ; -> true

strip-prefix #

(Func [String String] String)

Exported function in /string.

strip-suffix #

(Func [String String] String)

Exported function in /string.

to-lower-case #

(to-lower-case str) -> String

Converts all characters in string to lowercase.

(to-lower-case "TANGU") ; -> "tangu"

to-upper-case #

(to-upper-case str) -> String

Converts all characters in string to uppercase.

(to-upper-case "tangu") ; -> "TANGU"

trim #

(trim str) -> String

Returns a copy of the string with leading and trailing whitespace removed.

(trim "  hello  ") ; -> "hello"

trim-end #

(trim-end str) -> String

Returns string with trailing whitespace removed.

trim-start #

(trim-start str) -> String

Returns string with leading whitespace removed.

Module /regex #

Compiled regular expressions (Regex) supporting matching, replacement, splitting, and named/indexed capture groups.

(use /regex)

Regex #

(Regex ...)

Exported function in /regex.

capture #

(capture ...)

Exported function in /regex.

captures #

(captures ...)

Exported function in /regex.

captures-all #

(captures-all ...)

Exported function in /regex.

is-matching? #

(is-matching? ...)

Exported function in /regex.

matching? #

(matching? ...)

Exported function in /regex.

replace #

(replace ...)

Exported function in /regex.

split #

(split ...)

Exported function in /regex.

split-matches #

(split-matches ...)

Exported function in /regex.

Module /text #

Human-readable text capitalization and formatting utilities.

(use /text)

capitalize #

(capitalize ...)

Exported function in /text.

Module /text/case #

Identifier case conversion between camelCase, PascalCase, snake_case, SCREAMING_SNAKE_CASE, and kebab-case.

(use /text/case)

camel-split #

(text)

Exported function in /text/case.

camel-to-kebab #

(text)

Exported function in /text/case.

camel-to-snake #

(text)

Exported function in /text/case.

is-screaming? #

(text)

Exported function in /text/case.

kebab-join #

(words)

Exported function in /text/case.

kebab-split #

(phrase)

Exported function in /text/case.

snake-join #

(words)

Exported function in /text/case.

snake-split #

(phrase)

Exported function in /text/case.

snake-to-kebab #

(text)

Exported function in /text/case.

to-kebab #

(text)

Exported function in /text/case.

Module /text/cmark #

CommonMark and GitHub Flavored Markdown (tables, strikethrough, task lists) to HTML compiler (to-html).

(use /text/cmark)

to-html #

(to-html markdown) -> String

Compiles CommonMark and GitHub Flavored Markdown text into an HTML string.

Module /i18n #

Unicode CLDR internationalization powered by ICU4X: locale-aware numbers, currencies, dates, relative time, plurals, collation, and grapheme segmentation.

(use /i18n)

canonical-locale #

(canonical-locale ...)

Exported function in /i18n.

fold-case #

(fold-case ...)

Exported function in /i18n.

format #

(i18n/format value) -> String

Polymorphically formats numbers, /chrono temporal and duration values, and sequences according to locale rules.

(i18n/format 1234567.89d "el-GR")
(i18n/format ["Αθήνα" "Θεσσαλονίκη"] "el")

format-date-time #

(i18n/format-date-time temporal [locale-or-opts]) -> String

Formats a /chrono temporal value according to CLDR calendar and locale conventions.

(i18n/format-date-time (chrono/Date 2025 3 25) {:locale "el-GR" :style :long})

format-duration #

(i18n/format-duration duration [locale-or-opts]) -> String

Formats a /chrono Duration, Span, or unit Map into localized unit lists or digital clock notation.

(i18n/format-duration {:hours 2 :minutes 45} {:locale "el" :style :long})

format-list #

(i18n/format-list items [locale-or-opts]) -> String

Formats a sequence of items using locale-specific list conjunctions or disjunctions.

(i18n/format-list ["Αθήνα" "Πάτρα" "Κρήτη"] "el")

format-number #

(i18n/format-number n [locale-or-opts]) -> String

Formats a number with locale-specific grouping, decimal separators, currency symbols, percentages, or compact notation.

(i18n/format-number 1234.5d {:locale "el-GR" :style :currency :currency "EUR"})
(i18n/format-number 1250000 {:locale "en-US" :notation :compact})

format-relative #

(i18n/format-relative delta unit [locale-or-opts]) -> String

Formats relative time phrases such as "yesterday", "χθες", or "in 3 hours".

(i18n/format-relative -1 :day "el")

graphemes #

(i18n/graphemes text [locale]) -> Array

Segments a string into an Array of UAX #29 extended grapheme clusters.

(i18n/graphemes "👨‍👩‍👧‍👦🇬🇷")

locale-comparator #

(locale-comparator ...)

Exported function in /i18n.

locale-compare #

(i18n/locale-compare a b [locale-or-opts]) -> Int

Compares two strings using the Unicode Collation Algorithm, returning -1, 0, or 1.

(i18n/locale-compare "α" "ά" {:locale "el" :sensitivity :base})

locale-sort #

(i18n/locale-sort items [locale-or-opts]) -> Array

Returns a new sequence sorted by locale collation rules, supporting :key and :reverse.

(i18n/locale-sort ["Ωμέγα" "Αθήνα" "Άρτα"] "el")

maximize-locale #

(maximize-locale ...)

Exported function in /i18n.

minimize-locale #

(minimize-locale ...)

Exported function in /i18n.

parse-locale #

(i18n/parse-locale tag [opts]) -> Map

Parses and canonicalizes a BCP 47 locale tag into a Map of subtags and Unicode extension preferences.

(i18n/parse-locale "el-GR-u-ca-gregory-hc-h23")

plural #

(i18n/plural n forms-map [locale-or-opts]) -> Any

Selects a localized plural form from a category map or formats a singular/plural noun pair.

(i18n/plural 5 "μήνυμα" "μηνύματα" "el")

plural-category #

(i18n/plural-category n [locale-or-opts]) -> Symbol

Returns the CLDR plural category (:zero, :one, :two, :few, :many, :other) for a number.

(i18n/plural-category 1 "el")

segment #

(segment ...)

Exported function in /i18n.

sentences #

(sentences ...)

Exported function in /i18n.

strip-accents #

(i18n/strip-accents s) -> String

Removes combining diacritical marks via NFD decomposition and NFC recomposition.

(i18n/strip-accents "Καλημέρα Αθήνα café")

to-locale-lower-case #

(to-locale-lower-case ...)

Exported function in /i18n.

to-locale-title-case #

(to-locale-title-case ...)

Exported function in /i18n.

to-locale-upper-case #

(i18n/to-locale-upper-case s [locale]) -> String

Converts a string to uppercase using locale-specific Unicode case mapping rules.

(i18n/to-locale-upper-case "Καλημέρα Ελλάδα" "el")

words #

(i18n/words text [locale-or-opts]) -> Array

Extracts word-like tokens from a string using UAX #29 word boundary rules.

(i18n/words "Καλημέρα κόσμε!")

Module /html #

HTML entity escaping, attribute sanitization, and tag stripping for safe user-content rendering.

(use /html)

escape #

(escape ...)

Exported function in /html.

escape-text #

(escape-text ...)

Exported function in /html.

sanitize #

(sanitize ...)

Exported function in /html.

strip-tags #

(strip-tags ...)

Exported function in /html.