diff --git a/src/printer.js b/src/printer.js index 4d0b22b1..a3dd2b2e 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2757,7 +2757,7 @@ function printJSXChildren(path, options, print, jsxWhitespace) { if (/\S/.test(value)) { // treat each line of text as its own entity - value.split(/(\n\s*)/).forEach(line => { + value.split(/(\r?\n\s*)/).forEach(line => { const newlines = line.match(/\n/g); if (newlines) { children.push(hardline); diff --git a/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap b/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap index 2638cada..5d95e552 100644 --- a/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap @@ -187,3 +187,14 @@ regression_extra_newline_2 = ( ); " `; + +exports[`windows.js 1`] = ` +"
+Text +
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
+ Text +
; +" +`; diff --git a/tests/jsx-newlines/windows.js b/tests/jsx-newlines/windows.js new file mode 100644 index 00000000..12bf628e --- /dev/null +++ b/tests/jsx-newlines/windows.js @@ -0,0 +1,3 @@ +
+Text +