Files
claw3d/src/lib/text/assistantText.ts
T
Luke The Dev 4fa4f13558 First Release of Claw3D (#11)
Co-authored-by: iamlukethedev <iamlukethedev@users.noreply.github.com>
2026-03-19 23:14:04 -05:00

18 lines
524 B
TypeScript

export const normalizeAssistantDisplayText = (value: string): string => {
const lines = value.replace(/\r\n?/g, "\n").split("\n");
const normalized: string[] = [];
let lastWasBlank = false;
for (const rawLine of lines) {
const line = rawLine.replace(/[ \t]+$/g, "");
if (line.trim().length === 0) {
if (lastWasBlank) continue;
normalized.push("");
lastWasBlank = true;
continue;
}
normalized.push(line);
lastWasBlank = false;
}
return normalized.join("\n").trim();
};