From 1d1535af9091beb3fb7e2d711eb20e94de43b2ec Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 27 Aug 2025 19:04:05 +0200 Subject: [PATCH] ensure `\n\n` are kept as `\n\n` When splitting `'foo\n\nbar'` by `\n`, you will get `['foo', '', 'bar']`. The `''` value will result in `[]` after the word wrapping. This information gets lost when we `flatMap`, so let's keep the newline using `['']` as the fallback. --- packages/@tailwindcss-upgrade/src/utils/renderer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@tailwindcss-upgrade/src/utils/renderer.ts b/packages/@tailwindcss-upgrade/src/utils/renderer.ts index 38bd9826a..c9a967801 100644 --- a/packages/@tailwindcss-upgrade/src/utils/renderer.ts +++ b/packages/@tailwindcss-upgrade/src/utils/renderer.ts @@ -44,7 +44,7 @@ export function wordWrap(text: string, width: number): string[] { // Handle text with newlines by maintaining the newlines, then splitting // each line separately. if (text.includes('\n')) { - return text.split('\n').flatMap((line) => wordWrap(line, width)) + return text.split('\n').flatMap((line) => (line ? wordWrap(line, width) : [''])) } let words = text.split(' ')