Expand description
Unified formatting utilities for UI and logging
Functionsยง
- collapse_
whitespace - Collapse consecutive whitespace into single spaces, trimming leading/trailing.
- format_
size - Format file size in human-readable form (KB, MB, GB, etc.)
- head_
tail_ truncate - Truncate
valuetomax_charschars by keeping a head and a tail joined bymarker, preserving context from both ends of the text. - indent_
block - Indent a block of text with the given prefix
- truncate_
byte_ budget - Truncate a string so that the retained prefix is at most
max_bytesbytes, rounded down to the nearest UTF-8 char boundary. Returns the truncated prefix withsuffixappended, or the original string when it already fits. - truncate_
text - Truncate text to a maximum length (in chars) with an optional ellipsis.
- truncate_
within - Truncate text to
max_lenchars, reserving room forellipsisso the returned string never exceedsmax_lenchars. - wrap_
text_ words - Word-wrap
textinto lines, allowingfirst_widthchars on the first line andcontinuation_widthchars on subsequent lines. Wrapping prefers whitespace boundaries and is UTF-8 safe (widths count chars, not bytes).