@@ -618,12 +618,13 @@ private function buildTableRows(array $rows): TableRows
618
618
if (isset ($ this ->columnMaxWidths [$ column ]) && Helper::width (Helper::removeDecoration ($ formatter , $ cell )) > $ this ->columnMaxWidths [$ column ]) {
619
619
$ cell = $ formatter ->formatAndWrap ($ cell , $ this ->columnMaxWidths [$ column ] * $ colspan );
620
620
}
621
- if (!strstr ($ cell ?? '' , \ PHP_EOL )) {
621
+ if (!strstr ($ cell ?? '' , "\n" )) {
622
622
continue ;
623
623
}
624
- $ escaped = implode (\PHP_EOL , array_map ([OutputFormatter::class, 'escapeTrailingBackslash ' ], explode (\PHP_EOL , $ cell )));
624
+ $ eol = strstr ($ cell ?? '' , "\r\n" ) ? "\r\n" : "\n" ;
625
+ $ escaped = implode ($ eol , array_map ([OutputFormatter::class, 'escapeTrailingBackslash ' ], explode ($ eol , $ cell )));
625
626
$ cell = $ cell instanceof TableCell ? new TableCell ($ escaped , ['colspan ' => $ cell ->getColspan ()]) : $ escaped ;
626
- $ lines = explode (\ PHP_EOL , str_replace (\ PHP_EOL , '<fg=default;bg=default></> ' .\ PHP_EOL , $ cell ));
627
+ $ lines = explode ($ eol , str_replace ($ eol , '<fg=default;bg=default></> ' .$ eol , $ cell ));
627
628
foreach ($ lines as $ lineKey => $ line ) {
628
629
if ($ colspan > 1 ) {
629
630
$ line = new TableCell ($ line , ['colspan ' => $ colspan ]);
@@ -684,9 +685,10 @@ private function fillNextRows(array $rows, int $line): array
684
685
if ($ cell instanceof TableCell && $ cell ->getRowspan () > 1 ) {
685
686
$ nbLines = $ cell ->getRowspan () - 1 ;
686
687
$ lines = [$ cell ];
687
- if (strstr ($ cell , \PHP_EOL )) {
688
- $ lines = explode (\PHP_EOL , str_replace (\PHP_EOL , '<fg=default;bg=default> ' .\PHP_EOL .'</> ' , $ cell ));
689
- $ nbLines = \count ($ lines ) > $ nbLines ? substr_count ($ cell , \PHP_EOL ) : $ nbLines ;
688
+ if (strstr ($ cell , "\n" )) {
689
+ $ eol = strstr ($ cell , "\r\n" ) ? "\r\n" : "\n" ;
690
+ $ lines = explode ($ eol , str_replace ($ eol , '<fg=default;bg=default> ' .$ eol .'</> ' , $ cell ));
691
+ $ nbLines = \count ($ lines ) > $ nbLines ? substr_count ($ cell , $ eol ) : $ nbLines ;
690
692
691
693
$ rows [$ line ][$ column ] = new TableCell ($ lines [0 ], ['colspan ' => $ cell ->getColspan (), 'style ' => $ cell ->getStyle ()]);
692
694
unset($ lines [0 ]);
0 commit comments