git.iko.soy/typeable/pandoc
on master help sign in
Revert API change in EPUB writer.

Instead of passing the epub cover image as a parameter, we now pass it in the list of variables. This avoids the API change introduced in f5cbb68534c52b292c57aaf741ab94442ddadd7a without losing the new functionality.

commit679113ab02c1e37ef56b6cadc500394382343c3f authorJohn MacFarlane <jgm@berkeley.edu> dateSat 16 Apr 2011, 09:53 (16 years ago) parent4b90ffe
2 files changed+6−8
src/Text/Pandoc/Writers/EPUB.hs+3−3 src/pandoc.hs+3−5
src/Text/Pandoc/Writers/EPUB.hs+3−3
@@ -49,12 +49,11 @@ import Data.Char ( toLower )
4949import System.Directory ( copyFile )
5050
5151-- | Produce an EPUB file from a Pandoc document.
52−writeEPUB :: Maybe FilePath -- ^ Path of cover image
53− -> Maybe String -- ^ EPUB stylesheet specified at command line
52+writeEPUB :: Maybe String -- ^ EPUB stylesheet specified at command line
5453 -> WriterOptions -- ^ Writer options
5554 -> Pandoc -- ^ Document to convert
5655 -> IO B.ByteString
57−writeEPUB mbCoverImage mbStylesheet opts doc@(Pandoc meta _) = do
56+writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
5857 (TOD epochtime _) <- getClockTime
5958 let mkEntry path content = toEntry path epochtime content
6059 let opts' = opts{ writerEmailObfuscation = NoObfuscation
@@ -62,6 +61,7 @@ writeEPUB mbCoverImage mbStylesheet opts doc@(Pandoc meta _) = do
6261 , writerWrapText = False }
6362 let sourceDir = writerSourceDirectory opts'
6463 let vars = writerVariables opts'
64+ let mbCoverImage = lookup "epub-cover-image" vars
6565
6666 -- cover page
6767 (cpgEntry, cpicEntry) <-
src/pandoc.hs+3−5
@@ -107,7 +107,6 @@ data Opt = Opt
107107 , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
108108 , optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt
109109 , optEPUBStylesheet :: Maybe String -- ^ EPUB stylesheet
110− , optEPUBCoverImage :: Maybe FilePath -- ^ Path of epub cover image
111110 , optEPUBMetadata :: String -- ^ EPUB metadata
112111 , optDumpArgs :: Bool -- ^ Output command-line arguments
113112 , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
@@ -152,7 +151,6 @@ defaultOpts = Opt
152151 , optHTMLMathMethod = PlainMath
153152 , optReferenceODT = Nothing
154153 , optEPUBStylesheet = Nothing
155− , optEPUBCoverImage = Nothing
156154 , optEPUBMetadata = ""
157155 , optDumpArgs = False
158156 , optIgnoreArgs = False
@@ -495,7 +493,8 @@ options =
495493 , Option "" ["epub-cover-image"]
496494 (ReqArg
497495 (\arg opt ->
498− return opt { optEPUBCoverImage = Just arg })
496+ return opt { optVariables =
497+ ("epub-cover-image", arg) : optVariables opt })
499498 "FILENAME")
500499 "" -- "Path of epub cover image"
501500
@@ -683,7 +682,6 @@ main = do
683682 , optHTMLMathMethod = mathMethod
684683 , optReferenceODT = referenceODT
685684 , optEPUBStylesheet = epubStylesheet
686− , optEPUBCoverImage = epubCoverImage
687685 , optEPUBMetadata = epubMetadata
688686 , optDumpArgs = dumpArgs
689687 , optIgnoreArgs = ignoreArgs
@@ -868,7 +866,7 @@ main = do
868866
869867 case lookup writerName' writers of
870868 Nothing | writerName' == "epub" ->
871− writeEPUB epubCoverImage epubStylesheet writerOptions doc2
869+ writeEPUB epubStylesheet writerOptions doc2
872870 >>= B.writeFile (encodeString outputFile)
873871 Nothing | writerName' == "odt" ->
874872 writeODT referenceODT writerOptions doc2