aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs7
-rw-r--r--src/pandoc.hs17
2 files changed, 12 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 998a5aa3a..1ac2c8244 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -47,11 +47,14 @@ import Text.Pandoc.Writers.Markdown ( writePlain )
import Data.Char ( toLower )
-- | Produce an EPUB file from a Pandoc document.
-writeEPUB :: String -- ^ EPUB stylesheet
+writeEPUB :: Maybe String -- ^ EPUB stylesheet specified at command line
-> WriterOptions -- ^ Writer options
-> Pandoc -- ^ Document to convert
-> IO B.ByteString
-writeEPUB stylesheet opts doc = do
+writeEPUB mbStylesheet opts doc = do
+ stylesheet <- case mbStylesheet of
+ Just s -> return s
+ Nothing -> readDataFile (writerUserDataDir opts) "epub.css"
(TOD epochtime _) <- getClockTime
let opts' = opts{ writerEmailObfuscation = NoObfuscation
, writerStandalone = True
diff --git a/src/pandoc.hs b/src/pandoc.hs
index dd2787e7b..bfb619f04 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -695,16 +695,13 @@ main = do
Just r -> return r
Nothing -> error ("Unknown reader: " ++ readerName')
- writer <- case (lookup writerName' writers) of
- Just _ | writerName' == "epub" -> do
- epubstyle <- case epubStylesheet of
- Just s -> return s
- Nothing -> readDataFile datadir "epub.css"
- return (writeEPUB epubstyle)
- Just _ | writerName' == "odt" -> return (writeODT referenceODT)
- Just r -> return $ \o d ->
- return $ fromString (r o d)
- Nothing -> error ("Unknown writer: " ++ writerName')
+ let writer = case lookup writerName' writers of
+ Just _ | writerName' == "epub" -> writeEPUB epubStylesheet
+ Just _ | writerName' == "odt" -> writeODT referenceODT
+ Just r -> \o ->
+ return . fromString . r o
+ Nothing -> error $ "Unknown writer: " ++
+ writerName'
templ <- getDefaultTemplate datadir writerName'
let defaultTemplate = case templ of