textutil

package
v0.8.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package textutil holds small string helpers shared by tools and the TUI.

Package textutil holds small string helpers shared by tools and the TUI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ellipsize

func Ellipsize(s string, n int) string

Ellipsize truncates s to at most n bytes (UTF-8 safe), appending "..." when cut.

func GlobToRegex

func GlobToRegex(glob string) string

GlobToRegex converts a slash-separated glob to an unanchored regex body using only syntax understood by both Go and the macOS sandbox profile language.

func HTMLToText added in v0.7.0

func HTMLToText(src string) string

HTMLToText extracts readable text from HTML: scripts and styles are dropped, block elements become line breaks, headings and list items keep light Markdown markers, and links keep their absolute targets.

func SanitizeTerminal

func SanitizeTerminal(s string) string

SanitizeTerminal strips control characters that a terminal would interpret (ESC sequences, BEL, backspace, carriage return, C1 controls) so untrusted text from models, files, or tool output cannot rewrite the screen, change the window title, or write to the clipboard via OSC 52. Newlines and tabs are kept. Invalid UTF-8 is replaced with U+FFFD.

func Tail added in v0.8.3

func Tail(s string, n int) string

Tail is the end of s, at most n bytes on a rune boundary, after "…" when cut: where a command's output says what went wrong.

func TrimPartialRune

func TrimPartialRune(s string) string

TrimPartialRune drops an incomplete multi-byte rune from the end of s, as left behind when a byte stream is cut at an arbitrary offset.

func TruncateUTF8

func TruncateUTF8(s string, n int) string

TruncateUTF8 returns s cut to at most n bytes without splitting a multi-byte rune.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL