git.iko.soy/typeable/pandoc
on master help sign in
Removed need for TH in ODT module.

Instead get reference zip file directly from the file at run time. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1690 788f1e2b-df1e-0410-8736-df70ead52e1b

commit9551e363891c2cf31c8a82941c9101571d32987e authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 01:11 (17 years ago) parentecbf338
2 files changed+6−16
src/Text/Pandoc/ODT.hs+5−3 src/Text/Pandoc/TH.hs+1−13
src/Text/Pandoc/ODT.hs+5−3
@@ -1,4 +1,3 @@
1−{-# LANGUAGE TemplateHaskell #-}
21{-
32Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
43
@@ -29,7 +28,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2928Functions for producing an ODT file from OpenDocument XML.
3029-}
3130module Text.Pandoc.ODT ( saveOpenDocumentAsODT ) where
32−import Text.Pandoc.TH ( makeZip )
3331import Data.List ( find )
3432import System.FilePath ( (</>), takeFileName )
3533import qualified Data.ByteString.Lazy as B
@@ -39,6 +37,8 @@ import Codec.Archive.Zip
3937import Control.Applicative ( (<$>) )
4038import Text.ParserCombinators.Parsec
4139import System.Time
40+import Text.Pandoc.Shared ( inDirectory )
41+import Paths_pandoc ( getDataFileName )
4242
4343-- | Produce an ODT file from OpenDocument XML.
4444saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
@@ -46,7 +46,9 @@ saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
4646 -> String -- ^ OpenDocument XML contents.
4747 -> IO ()
4848saveOpenDocumentAsODT destinationODTPath sourceDirRelative xml = do
49− let refArchive = read $(makeZip $ "data" </> "odt-styles")
49+ refArchivePath <- getDataFileName $ "data" </> "odt-styles"
50+ refArchive <- inDirectory refArchivePath $
51+ addFilesToArchive [OptRecursive] emptyArchive ["."]
5052 -- handle pictures
5153 let (newContents, pics) =
5254 case runParser pPictures [] "OpenDocument XML contents" xml of
src/Text/Pandoc/TH.hs+1−13
@@ -30,8 +30,7 @@ Template haskell functions used by Pandoc modules.
3030-}
3131module Text.Pandoc.TH (
3232 contentsOf,
33− binaryContentsOf,
34− makeZip
33+ binaryContentsOf
3534 ) where
3635
3736import Language.Haskell.TH
@@ -40,8 +39,6 @@ import qualified Data.ByteString as B
4039import Data.ByteString.Internal ( w2c )
4140import Prelude hiding ( readFile )
4241import System.IO.UTF8
43−import Codec.Archive.Zip
44−import Text.Pandoc.Shared ( inDirectory )
4542
4643-- | Insert contents of text file into a template.
4744contentsOf :: FilePath -> ExpQ
@@ -54,12 +51,3 @@ binaryContentsOf p = lift =<< (runIO $ B.readFile p)
5451
5552instance Lift B.ByteString where
5653 lift x = return (LitE (StringL $ map w2c $ B.unpack x))
57−
58−instance Lift Archive where
59− lift x = return (LitE (StringL $ show x ))
60−
61−-- | Construct zip file from files in a directory, and
62−-- insert into a template.
63−makeZip :: FilePath -> ExpQ
64−makeZip path = lift =<< (runIO $ inDirectory path $ addFilesToArchive [OptRecursive] emptyArchive ["."])
65−