package preview import "strings" // textLines normalises text for display (CRLF → LF, tab → 4 spaces) and // splits it into at most max lines. func textLines(src string, max int) (lines []string, truncated bool) { src = strings.ReplaceAll(src, "\r\n", "\n") src = strings.ReplaceAll(src, "\t", " ") src = strings.TrimSuffix(src, "\n") lines = strings.Split(src, "\n") if len(lines) > max { lines, truncated = lines[:max], true } return lines, truncated }