From 43347888d5cbc16c83e7465d98b73e402d7ab1da Mon Sep 17 00:00:00 2001 From: blmage Date: Mon, 17 Jun 2019 07:37:01 +0200 Subject: [PATCH] Handle the case where the "cover" meta does not link to the manifest --- src/Text/Pandoc/Readers/EPUB.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs index 8958a92a3..8e9746090 100644 --- a/src/Text/Pandoc/Readers/EPUB.hs +++ b/src/Text/Pandoc/Readers/EPUB.hs @@ -21,7 +21,7 @@ import Prelude import Codec.Archive.Zip (Archive (..), Entry, findEntryByPath, fromEntry, toArchiveOrFail) import Control.DeepSeq (NFData, deepseq) -import Control.Monad (guard, liftM, liftM2) +import Control.Monad (guard, liftM, liftM2, mplus) import Control.Monad.Except (throwError) import qualified Data.ByteString.Lazy as BL (ByteString) import Data.List (isInfixOf, isPrefixOf) @@ -134,7 +134,7 @@ parseManifest content coverId = do let items = findChildren (dfName "item") manifest r <- mapM parseItem items let cover = findAttr (emptyName "href") =<< filterChild findCover manifest - return (cover, M.fromList r) + return (cover `mplus` coverId, M.fromList r) where findCover e = maybe False (isInfixOf "cover-image") (findAttr (emptyName "properties") e)