Skip to content

Commit cce7a9f

Browse files
Perturbationicolas-grekas
authored andcommitted
[Console] Fixes "Incorrectly nested style tag found" error when using multi-line header content
1 parent 7216004 commit cce7a9f

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

Helper/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ private function buildTableRows(array $rows): TableRows
586586
}
587587
$escaped = implode("\n", array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode("\n", $cell)));
588588
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
589-
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
589+
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default></>\n", $cell));
590590
foreach ($lines as $lineKey => $line) {
591591
if ($colspan > 1) {
592592
$line = new TableCell($line, ['colspan' => $colspan]);

Tests/Helper/TableTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,8 @@ public function renderProvider()
615615
'default',
616616
<<<'TABLE'
617617
+-------+------------+
618-
[39;49m| [39;49m[37;41mDont break[39;49m[39;49m |[39;49m
619-
[39;49m| [39;49m[37;41mhere[39;49m |
618+
[37;41m| [39;49m[37;41mDont break[39;49m[37;41m |[39;49m
619+
[37;41m| here[39;49m |
620620
+-------+------------+
621621
| foo | Dont break |
622622
| bar | here |
@@ -1078,6 +1078,26 @@ public function renderSetTitle()
10781078
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
10791079
+---------------+--------- Page 1/2 -------+------------------+
10801080

1081+
TABLE
1082+
,
1083+
true,
1084+
],
1085+
'header contains multiple lines' => [
1086+
'Multiline'."\n".'header'."\n".'here',
1087+
'footer',
1088+
'default',
1089+
<<<'TABLE'
1090+
+---------------+--- Multiline
1091+
header
1092+
here +------------------+
1093+
| ISBN | Title | Author |
1094+
+---------------+--------------------------+------------------+
1095+
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
1096+
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
1097+
| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
1098+
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
1099+
+---------------+---------- footer --------+------------------+
1100+
10811101
TABLE
10821102
],
10831103
[

0 commit comments

Comments
 (0)