diff --git a/src/Formats/Epub/Parser/EpubChapter.php b/src/Formats/Epub/Parser/EpubChapter.php index 7377b60..472e2ae 100644 --- a/src/Formats/Epub/Parser/EpubChapter.php +++ b/src/Formats/Epub/Parser/EpubChapter.php @@ -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; } } diff --git a/src/Formats/Epub/Parser/OpfItem.php b/src/Formats/Epub/Parser/OpfItem.php index a06a1b1..07a7178 100644 --- a/src/Formats/Epub/Parser/OpfItem.php +++ b/src/Formats/Epub/Parser/OpfItem.php @@ -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'] ?? []; @@ -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 [];