Skip to content

Commit

Permalink
Merge pull request #89 from basitcodeenv/epub-bugfix
Browse files Browse the repository at this point in the history
🐛 Fix Bug: getChapters() not getting chapters
  • Loading branch information
ewilan-riviere authored Jul 15, 2024
2 parents 54c420b + 4eec489 commit d00fb43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Formats/Epub/Parser/EpubChapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function toArray(?NcxItem $ncx, ?array $html): array
private static function findByFilename(array $html, string $filename)
{
foreach ($html as $item) {
if ($filename == $item->getFilename()) {
if (str_contains($item->getFilename(), $filename)) {
return $item;
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/Formats/Epub/Parser/OpfItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ public static function make(string $content, ?string $filename = null): self

$content = $xml->getContents();
$self->epubVersion = $self->xml->getRootAttribute('version');
$metadata = $content['metadata'] ?? [];
$metadata = $content['metadata'] ?? $content['opf:metadata'] ?? [];
$manifest = $content['manifest'] ?? $content['opf:manifest'] ?? [];

if (array_key_exists('opf:metadata', $content)) {
$metadata = $content['opf:metadata'] ?? [];
}
$manifest = $content['manifest'] ?? [];
$spine = $content['spine'] ?? [];
$guide = $content['guide'] ?? [];
Expand Down Expand Up @@ -196,7 +194,7 @@ private function findContent(): array
return [];
}

$core = $this->manifest['item'] ?? null;
$core = $this->manifest['item'] ?? $this->manifest['opf:item'] ?? null;

if (empty($core)) {
return [];
Expand Down

0 comments on commit d00fb43

Please sign in to comment.