Skip to content

Commit 1d1535a

Browse files
committed
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.
1 parent be10cf4 commit 1d1535a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/@tailwindcss-upgrade/src/utils/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function wordWrap(text: string, width: number): string[] {
4444
// Handle text with newlines by maintaining the newlines, then splitting
4545
// each line separately.
4646
if (text.includes('\n')) {
47-
return text.split('\n').flatMap((line) => wordWrap(line, width))
47+
return text.split('\n').flatMap((line) => (line ? wordWrap(line, width) : ['']))
4848
}
4949

5050
let words = text.split(' ')

0 commit comments

Comments
 (0)