From 83b6e0bbaf003b8b1983c0e4c9bd72775a86eecc Mon Sep 17 00:00:00 2001 From: Jethro Yu Date: Fri, 25 Apr 2025 18:39:04 +0800 Subject: [PATCH] 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. --- src/utils/removeContentTags.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/removeContentTags.ts b/src/utils/removeContentTags.ts index d478434..c665bf7 100644 --- a/src/utils/removeContentTags.ts +++ b/src/utils/removeContentTags.ts @@ -43,9 +43,9 @@ export function removeContentTags(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; }