Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

460 B
Raw Blame
package text

import "strings"

// OneLine collapses newlines/carriage-returns/tabs in s to single spaces,
// then truncates to maxDisplayWidth columns (UTF-8 safe via Truncate).
// Use for human-readable preview rows where multiline content would
// break tabular layout.
func OneLine(maxDisplayWidth int, s string) string {
	return Truncate(maxDisplayWidth, lineReplacer.Replace(s))
}

var lineReplacer = strings.NewReplacer("\n", " ", "\r", " ", "\t", " ")