Skip to content

Commit 83b6e0b

Browse files
committed
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.
1 parent 2726e51 commit 83b6e0b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils/removeContentTags.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export function removeContentTags<T extends string | null | undefined>(content:
4343
result += content[i];
4444
}
4545
}
46-
47-
// Normalize spaces (replace multiple spaces with a single space)
48-
result = result.replace(/\s+/g, ' ').trim();
49-
46+
47+
// Normalize multiple spaces/tabs into a single space (preserves newlines), then trim.
48+
result = result.replace(/[ \t]+/g, ' ').trim();
49+
5050
return result as unknown as T;
5151
}

0 commit comments

Comments
 (0)