@@ -137,8 +137,8 @@ convertWithOpts opts args = do
137137 , optTopLevelDivision = topLevelDivision
138138 , optHTMLMathMethod = mathMethod'
139139 , optReferenceDoc = referenceDoc
140− , optEpubStylesheet = epubStylesheet
141− , optEpubMetadata = epubMetadata
140+ , optEpubStylesheet = mbEpubStylesheet
141+ , optEpubMetadata = mbEpubMetadata
142142 , optEpubFonts = epubFonts
143143 , optEpubChapterLevel = epubChapterLevel
144144 , optTOCDepth = epubTOCDepth
@@ -176,6 +176,14 @@ convertWithOpts opts args = do
176176 mapM_ (UTF8.hPutStrLn stdout) args
177177 exitSuccess
178178
179+ epubStylesheet <- case mbEpubStylesheet of
180+ Nothing -> return Nothing
181+ Just fp -> Just <$> UTF8.readFile fp
182+
183+ epubMetadata <- case mbEpubMetadata of
184+ Nothing -> return Nothing
185+ Just fp -> Just <$> UTF8.readFile fp
186+
179187 let csscdn = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css"
180188 let mathMethod =
181189 case (katexJS, katexStylesheet) of
@@ -547,8 +555,8 @@ data Opt = Opt
547555 , optTopLevelDivision :: TopLevelDivision -- ^ Type of the top-level divisions
548556 , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
549557 , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc
550− , optEpubStylesheet :: Maybe String -- ^ EPUB stylesheet
551− , optEpubMetadata :: String -- ^ EPUB metadata
558+ , optEpubStylesheet :: Maybe FilePath -- ^ EPUB stylesheet
559+ , optEpubMetadata :: Maybe FilePath -- ^ EPUB metadata
552560 , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed
553561 , optEpubChapterLevel :: Int -- ^ Header level at which to split chapters
554562 , optTOCDepth :: Int -- ^ Number of levels to include in TOC
@@ -607,7 +615,7 @@ defaultOpts = Opt
607615 , optHTMLMathMethod = PlainMath
608616 , optReferenceDoc = Nothing
609617 , optEpubStylesheet = Nothing
610− , optEpubMetadata = ""
618+ , optEpubMetadata = Nothing
611619 , optEpubFonts = []
612620 , optEpubChapterLevel = 1
613621 , optTOCDepth = 3
@@ -1024,9 +1032,7 @@ options =
10241032
10251033 , Option "" ["epub-stylesheet"]
10261034 (ReqArg
1027− (\arg opt -> do
1028− text <- UTF8.readFile arg
1029− return opt { optEpubStylesheet = Just text })
1035+ (\arg opt -> return opt { optEpubStylesheet = Just arg })
10301036 "FILENAME")
10311037 "" -- "Path of epub.css"
10321038
@@ -1040,9 +1046,7 @@ options =
10401046
10411047 , Option "" ["epub-metadata"]
10421048 (ReqArg
1043− (\arg opt -> do
1044− text <- UTF8.readFile arg
1045− return opt { optEpubMetadata = text })
1049+ (\arg opt -> return opt { optEpubMetadata = Just arg })
10461050 "FILENAME")
10471051 "" -- "Path of epub metadata file"
10481052