git.iko.soy/typeable/pandoc
on master help sign in
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!

commit999edd960836ee6b43e7854f204b86f4cd845d06 authorJohn MacFarlane <fiddlosopher@gmail.com> dateTue 24 Jul 2012, 09:56 (14 years ago) parentcd19d45
4 files changed+18−18
src/Text/Pandoc/Writers/Docx.hs+3−4 src/Text/Pandoc/Writers/EPUB.hs+4−6 src/Text/Pandoc/Writers/ODT.hs+3−4 src/pandoc.hs+8−4
src/Text/Pandoc/Writers/Docx.hs+3−4
@@ -93,14 +93,13 @@ mknode s attrs =
9393 add_attrs (map (\(k,v) -> Attr (unqual k) v) attrs) . node (unqual s)
9494
9595-- | Produce an Docx file from a Pandoc document.
96−writeDocx :: Maybe FilePath -- ^ Path specified by --reference-docx
97− -> WriterOptions -- ^ Writer options
96+writeDocx :: WriterOptions -- ^ Writer options
9897 -> Pandoc -- ^ Document to convert
9998 -> IO B.ByteString
100−writeDocx mbRefDocx opts doc@(Pandoc (Meta tit auths date) _) = do
99+writeDocx opts doc@(Pandoc (Meta tit auths date) _) = do
101100 let datadir = writerUserDataDir opts
102101 refArchive <- liftM toArchive $
103− case mbRefDocx of
102+ case writerReferenceDocx opts of
104103 Just f -> B.readFile f
105104 Nothing -> do
106105 let defaultDocx = getDataFileName "reference.docx" >>= B.readFile
src/Text/Pandoc/Writers/EPUB.hs+4−6
@@ -52,12 +52,10 @@ import Prelude hiding (catch)
5252import Control.Exception (catch, SomeException)
5353
5454-- | Produce an EPUB file from a Pandoc document.
55−writeEPUB :: Maybe String -- ^ EPUB stylesheet specified at command line
56− -> [FilePath] -- ^ Paths to fonts to embed
57− -> WriterOptions -- ^ Writer options
55+writeEPUB :: WriterOptions -- ^ Writer options
5856 -> Pandoc -- ^ Document to convert
5957 -> IO B.ByteString
60−writeEPUB mbStylesheet fonts opts doc@(Pandoc meta _) = do
58+writeEPUB opts doc@(Pandoc meta _) = do
6159 epochtime <- floor `fmap` getPOSIXTime
6260 let mkEntry path content = toEntry path epochtime content
6361 let opts' = opts{ writerEmailObfuscation = NoObfuscation
@@ -107,7 +105,7 @@ writeEPUB mbStylesheet fonts opts doc@(Pandoc meta _) = do
107105
108106 -- handle fonts
109107 let mkFontEntry f = mkEntry (takeFileName f) `fmap` B.readFile f
110− fontEntries <- mapM mkFontEntry fonts
108+ fontEntries <- mapM mkFontEntry $ writerEpubFonts opts
111109
112110 -- body pages
113111 let isH1 (Header 1 _) = True
@@ -232,7 +230,7 @@ writeEPUB mbStylesheet fonts opts doc@(Pandoc meta _) = do
232230 let appleEntry = mkEntry "META-INF/com.apple.ibooks.display-options.xml" apple
233231
234232 -- stylesheet
235− stylesheet <- case mbStylesheet of
233+ stylesheet <- case writerEpubStylesheet opts of
236234 Just s -> return s
237235 Nothing -> readDataFile (writerUserDataDir opts) "epub.css"
238236 let stylesheetEntry = mkEntry "stylesheet.css" $ fromString stylesheet
src/Text/Pandoc/Writers/ODT.hs+3−4
@@ -49,14 +49,13 @@ import Text.Pandoc.XML
4949import Text.Pandoc.Pretty
5050
5151-- | Produce an ODT file from a Pandoc document.
52−writeODT :: Maybe FilePath -- ^ Path specified by --reference-odt
53− -> WriterOptions -- ^ Writer options
52+writeODT :: WriterOptions -- ^ Writer options
5453 -> Pandoc -- ^ Document to convert
5554 -> IO B.ByteString
56−writeODT mbRefOdt opts doc = do
55+writeODT opts doc = do
5756 let datadir = writerUserDataDir opts
5857 refArchive <- liftM toArchive $
59− case mbRefOdt of
58+ case writerReferenceODT opts of
6059 Just f -> B.readFile f
6160 Nothing -> do
6261 let defaultODT = getDataFileName "reference.odt" >>= B.readFile
src/pandoc.hs+8−4
@@ -979,7 +979,11 @@ main = do
979979 writerHighlight = highlight,
980980 writerHighlightStyle = highlightStyle,
981981 writerSetextHeaders = setextHeaders,
982− writerTeXLigatures = texLigatures
982+ writerTeXLigatures = texLigatures,
983+ writerEpubStylesheet = epubStylesheet,
984+ writerEpubFonts = epubFonts,
985+ writerReferenceODT = referenceODT,
986+ writerReferenceDocx = referenceDocx
983987 }
984988
985989 when (writerName' `elem` nonTextFormats&& outputFile == "-") $
@@ -1043,12 +1047,12 @@ main = do
10431047 writerFn outputFile d
10441048 (Nothing, Nothing)
10451049 | writerName' == "epub" ->
1046− writeEPUB epubStylesheet epubFonts writerOptions doc2
1050+ writeEPUB writerOptions doc2
10471051 >>= writeBinary
10481052 | writerName' == "odt" ->
1049− writeODT referenceODT writerOptions doc2 >>= writeBinary
1053+ writeODT writerOptions doc2 >>= writeBinary
10501054 | writerName' == "docx" ->
1051− writeDocx referenceDocx writerOptions doc2 >>= writeBinary
1055+ writeDocx writerOptions doc2 >>= writeBinary
10521056 | otherwise -> err 9 ("Unknown writer: " ++ writerName')
10531057 (Just w, _)
10541058 | pdfOutput -> do