Skip to content

Commit

Permalink
fix: avoid error when parsing tables with only one row
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault GRANADA authored and TZK- committed Feb 29, 2024
1 parent 100734a commit 727d28e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Presentation/Resource/Slide.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ public function table(Closure $data, Closure $finder = null): void
$tables = $this->content->xpath('//a:tbl/../../../p:nvGraphicFramePr/p:cNvPr');
foreach ($tables as $table) {
$tableId = (string)$table->attributes()['name'];
$tableRow = $this->content->xpath("//p:cNvPr[@name='$tableId']/../..//a:tr")[1];

// Try to select the second table row which must be the rows to be copied & templated.
// If the row is not found, it means we only have a header to our table, so we can skip it.
$tableRow = $this->content->xpath("//p:cNvPr[@name='$tableId']/../..//a:tr")[1] ?? null;
if (!$tableRow) {
continue;
}

$table = $tableRow->xpath('..')[0];
$rows = $data($tableId);
if (!$rows) {
Expand Down

0 comments on commit 727d28e

Please sign in to comment.