diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-07-24 09:56:00 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-07-24 09:56:00 -0700 |
commit | 999edd960836ee6b43e7854f204b86f4cd845d06 (patch) | |
tree | 1eabddcc2dbefb7c0eabc6c77ca5008d3c2f0d68 /src | |
parent | cd19d4596bc696670756c8ad6440d3f3b75cb5e8 (diff) | |
download | pandoc-999edd960836ee6b43e7854f204b86f4cd845d06.tar.gz |
Changed signatures of writeODT, writeDocx, writeEPUB.
These now take WriterOptions and Pandoc only.
The extra parameters for epub stylesheet, epub fonts,
reference Docx, and reference ODT have been removed, since
these things are now in WriterOptions.
Note: breaking API change!
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 7 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 10 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/ODT.hs | 7 | ||||
-rw-r--r-- | src/pandoc.hs | 12 |
4 files changed, 18 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 396e7a482..63329bb44 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -93,14 +93,13 @@ mknode s attrs = add_attrs (map (\(k,v) -> Attr (unqual k) v) attrs) . node (unqual s) -- | Produce an Docx file from a Pandoc document. -writeDocx :: Maybe FilePath -- ^ Path specified by --reference-docx - -> WriterOptions -- ^ Writer options +writeDocx :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> IO B.ByteString -writeDocx mbRefDocx opts doc@(Pandoc (Meta tit auths date) _) = do +writeDocx opts doc@(Pandoc (Meta tit auths date) _) = do let datadir = writerUserDataDir opts refArchive <- liftM toArchive $ - case mbRefDocx of + case writerReferenceDocx opts of Just f -> B.readFile f Nothing -> do let defaultDocx = getDataFileName "reference.docx" >>= B.readFile diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index b423f136f..27356f072 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -52,12 +52,10 @@ import Prelude hiding (catch) import Control.Exception (catch, SomeException) -- | Produce an EPUB file from a Pandoc document. -writeEPUB :: Maybe String -- ^ EPUB stylesheet specified at command line - -> [FilePath] -- ^ Paths to fonts to embed - -> WriterOptions -- ^ Writer options +writeEPUB :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> IO B.ByteString -writeEPUB mbStylesheet fonts opts doc@(Pandoc meta _) = do +writeEPUB opts doc@(Pandoc meta _) = do epochtime <- floor `fmap` getPOSIXTime let mkEntry path content = toEntry path epochtime content let opts' = opts{ writerEmailObfuscation = NoObfuscation @@ -107,7 +105,7 @@ writeEPUB mbStylesheet fonts opts doc@(Pandoc meta _) = do -- handle fonts let mkFontEntry f = mkEntry (takeFileName f) `fmap` B.readFile f - fontEntries <- mapM mkFontEntry fonts + fontEntries <- mapM mkFontEntry $ writerEpubFonts opts -- body pages let isH1 (Header 1 _) = True @@ -232,7 +230,7 @@ writeEPUB mbStylesheet fonts opts doc@(Pandoc meta _) = do let appleEntry = mkEntry "META-INF/com.apple.ibooks.display-options.xml" apple -- stylesheet - stylesheet <- case mbStylesheet of + stylesheet <- case writerEpubStylesheet opts of Just s -> return s Nothing -> readDataFile (writerUserDataDir opts) "epub.css" let stylesheetEntry = mkEntry "stylesheet.css" $ fromString stylesheet diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index f8f22494f..b45a6bc92 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -49,14 +49,13 @@ import Text.Pandoc.XML import Text.Pandoc.Pretty -- | Produce an ODT file from a Pandoc document. -writeODT :: Maybe FilePath -- ^ Path specified by --reference-odt - -> WriterOptions -- ^ Writer options +writeODT :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> IO B.ByteString -writeODT mbRefOdt opts doc = do +writeODT opts doc = do let datadir = writerUserDataDir opts refArchive <- liftM toArchive $ - case mbRefOdt of + case writerReferenceODT opts of Just f -> B.readFile f Nothing -> do let defaultODT = getDataFileName "reference.odt" >>= B.readFile diff --git a/src/pandoc.hs b/src/pandoc.hs index 5cebab28f..fde906eb1 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -979,7 +979,11 @@ main = do writerHighlight = highlight, writerHighlightStyle = highlightStyle, writerSetextHeaders = setextHeaders, - writerTeXLigatures = texLigatures + writerTeXLigatures = texLigatures, + writerEpubStylesheet = epubStylesheet, + writerEpubFonts = epubFonts, + writerReferenceODT = referenceODT, + writerReferenceDocx = referenceDocx } when (writerName' `elem` nonTextFormats&& outputFile == "-") $ @@ -1043,12 +1047,12 @@ main = do writerFn outputFile d (Nothing, Nothing) | writerName' == "epub" -> - writeEPUB epubStylesheet epubFonts writerOptions doc2 + writeEPUB writerOptions doc2 >>= writeBinary | writerName' == "odt" -> - writeODT referenceODT writerOptions doc2 >>= writeBinary + writeODT writerOptions doc2 >>= writeBinary | writerName' == "docx" -> - writeDocx referenceDocx writerOptions doc2 >>= writeBinary + writeDocx writerOptions doc2 >>= writeBinary | otherwise -> err 9 ("Unknown writer: " ++ writerName') (Just w, _) | pdfOutput -> do |