aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs6
-rw-r--r--src/pandoc.hs8
2 files changed, 6 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 18f08fc6c..5654bb004 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -49,12 +49,11 @@ import Data.Char ( toLower )
import System.Directory ( copyFile )
-- | Produce an EPUB file from a Pandoc document.
-writeEPUB :: Maybe FilePath -- ^ Path of cover image
- -> Maybe String -- ^ EPUB stylesheet specified at command line
+writeEPUB :: Maybe String -- ^ EPUB stylesheet specified at command line
-> WriterOptions -- ^ Writer options
-> Pandoc -- ^ Document to convert
-> IO B.ByteString
-writeEPUB mbCoverImage mbStylesheet opts doc@(Pandoc meta _) = do
+writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
(TOD epochtime _) <- getClockTime
let mkEntry path content = toEntry path epochtime content
let opts' = opts{ writerEmailObfuscation = NoObfuscation
@@ -62,6 +61,7 @@ writeEPUB mbCoverImage mbStylesheet opts doc@(Pandoc meta _) = do
, writerWrapText = False }
let sourceDir = writerSourceDirectory opts'
let vars = writerVariables opts'
+ let mbCoverImage = lookup "epub-cover-image" vars
-- cover page
(cpgEntry, cpicEntry) <-
diff --git a/src/pandoc.hs b/src/pandoc.hs
index 38ce27502..13e867deb 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -107,7 +107,6 @@ data Opt = Opt
, optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
, optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt
, optEPUBStylesheet :: Maybe String -- ^ EPUB stylesheet
- , optEPUBCoverImage :: Maybe FilePath -- ^ Path of epub cover image
, optEPUBMetadata :: String -- ^ EPUB metadata
, optDumpArgs :: Bool -- ^ Output command-line arguments
, optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
@@ -152,7 +151,6 @@ defaultOpts = Opt
, optHTMLMathMethod = PlainMath
, optReferenceODT = Nothing
, optEPUBStylesheet = Nothing
- , optEPUBCoverImage = Nothing
, optEPUBMetadata = ""
, optDumpArgs = False
, optIgnoreArgs = False
@@ -495,7 +493,8 @@ options =
, Option "" ["epub-cover-image"]
(ReqArg
(\arg opt ->
- return opt { optEPUBCoverImage = Just arg })
+ return opt { optVariables =
+ ("epub-cover-image", arg) : optVariables opt })
"FILENAME")
"" -- "Path of epub cover image"
@@ -683,7 +682,6 @@ main = do
, optHTMLMathMethod = mathMethod
, optReferenceODT = referenceODT
, optEPUBStylesheet = epubStylesheet
- , optEPUBCoverImage = epubCoverImage
, optEPUBMetadata = epubMetadata
, optDumpArgs = dumpArgs
, optIgnoreArgs = ignoreArgs
@@ -868,7 +866,7 @@ main = do
case lookup writerName' writers of
Nothing | writerName' == "epub" ->
- writeEPUB epubCoverImage epubStylesheet writerOptions doc2
+ writeEPUB epubStylesheet writerOptions doc2
>>= B.writeFile (encodeString outputFile)
Nothing | writerName' == "odt" ->
writeODT referenceODT writerOptions doc2