fix(removeContentTags): keep newlines to preserve formatting

The space normalization logic is updated to replace only multiple spaces
and tabs with a single space, while preserving newlines. This change
ensures that the formatting of the content is maintained, especially
when dealing with empty line requirements and max line length.
This commit is contained in:
Jethro Yu
2025-04-25 18:39:04 +08:00
parent 2726e51c2a
commit 83b6e0bbaf

View File

@@ -43,9 +43,9 @@ export function removeContentTags<T extends string | null | undefined>(content:
result += content[i];
}
}
// Normalize spaces (replace multiple spaces with a single space)
result = result.replace(/\s+/g, ' ').trim();
// Normalize multiple spaces/tabs into a single space (preserves newlines), then trim.
result = result.replace(/[ \t]+/g, ' ').trim();
return result as unknown as T;
}