File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -562,6 +562,9 @@ private function buildTableRows(array $rows): TableRows
562562 if (0 === $ lineKey ) {
563563 $ rows [$ rowKey ][$ column ] = $ line ;
564564 } else {
565+ if (!\array_key_exists ($ rowKey , $ unmergedRows ) || !\array_key_exists ($ lineKey , $ unmergedRows [$ rowKey ])) {
566+ $ unmergedRows [$ rowKey ][$ lineKey ] = $ this ->copyRow ($ rows , $ rowKey );
567+ }
565568 $ unmergedRows [$ rowKey ][$ lineKey ][$ column ] = $ line ;
566569 }
567570 }
@@ -573,8 +576,8 @@ private function buildTableRows(array $rows): TableRows
573576 yield $ this ->fillCells ($ row );
574577
575578 if (isset ($ unmergedRows [$ rowKey ])) {
576- foreach ($ unmergedRows [$ rowKey ] as $ row ) {
577- yield $ row ;
579+ foreach ($ unmergedRows [$ rowKey ] as $ unmergedRow ) {
580+ yield $ this -> fillCells ( $ unmergedRow ) ;
578581 }
579582 }
580583 }
@@ -658,6 +661,7 @@ private function fillNextRows(array $rows, int $line): array
658661 private function fillCells ($ row )
659662 {
660663 $ newRow = [];
664+
661665 foreach ($ row as $ column => $ cell ) {
662666 $ newRow [] = $ cell ;
663667 if ($ cell instanceof TableCell && $ cell ->getColspan () > 1 ) {
Original file line number Diff line number Diff line change @@ -333,6 +333,45 @@ public function renderProvider()
333333| Cupiditate dicta atque porro, tempora exercitationem modi animi nulla nemo vel nihil! |
334334+-------------------------------+-------------------------------+-----------------------------+
335335
336+ TABLE
337+ ],
338+ 'Cell after colspan contains new line break ' => [
339+ ['Foo ' , 'Bar ' , 'Baz ' ],
340+ [
341+ [
342+ new TableCell ("foo \nbar " , ['colspan ' => 2 ]),
343+ "baz \nqux " ,
344+ ],
345+ ],
346+ 'default ' ,
347+ <<<'TABLE'
348+ +-----+-----+-----+
349+ | Foo | Bar | Baz |
350+ +-----+-----+-----+
351+ | foo | baz |
352+ | bar | qux |
353+ +-----+-----+-----+
354+
355+ TABLE
356+ ],
357+ 'Cell after colspan contains multiple new lines ' => [
358+ ['Foo ' , 'Bar ' , 'Baz ' ],
359+ [
360+ [
361+ new TableCell ("foo \nbar " , ['colspan ' => 2 ]),
362+ "baz \nqux \nquux " ,
363+ ],
364+ ],
365+ 'default ' ,
366+ <<<'TABLE'
367+ +-----+-----+------+
368+ | Foo | Bar | Baz |
369+ +-----+-----+------+
370+ | foo | baz |
371+ | bar | qux |
372+ | | quux |
373+ +-----+-----+------+
374+
336375TABLE
337376 ],
338377 'Cell with rowspan ' => [
You can’t perform that action at this time.
0 commit comments