mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2026-10-28 09:46:23 +08:00
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.
This commit is contained in:
1 file changed
+1
-1
@@ -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(' ')
|
||||
|
||||
Reference in new issue
Block a user