@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -fno-warn-orphans #-}
3Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>
2Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>
@@ -101,9 +100,7 @@ module Text.Pandoc.Shared (
101 WriterOptions (..),
100 WriterOptions (..),
102 defaultWriterOptions,
101 defaultWriterOptions,
103 -- * File handling
102 -- * File handling
104− withTempDir,
103+ withTempDir
105− -- * Template haskell
109import Text.Pandoc.Definition
106import Text.Pandoc.Definition
@@ -118,9 +115,6 @@ import Network.URI ( parseURI, URI (..), isAllowedInURI )
118import System.FilePath ( (</>), (<.>) )
115import System.FilePath ( (</>), (<.>) )
119import System.IO.Error ( catch, ioError, isAlreadyExistsError )
116import System.IO.Error ( catch, ioError, isAlreadyExistsError )
120import System.Directory
117import System.Directory
121−import Language.Haskell.TH
122−import Language.Haskell.TH.Syntax (Lift (..))
123−import qualified Data.ByteString.Char8 as B
126-- List processing
120-- List processing
@@ -912,6 +906,10 @@ defaultWriterOptions =
912 , writerWrapText = True
906 , writerWrapText = True
915-- | Perform a function in a temporary directory and clean up.
913-- | Perform a function in a temporary directory and clean up.
916withTempDir :: FilePath -> (FilePath -> IO a) -> IO a
914withTempDir :: FilePath -> (FilePath -> IO a) -> IO a
917withTempDir baseName func = do
915withTempDir baseName func = do
@@ -929,11 +927,3 @@ createTempDir num baseName = do
929 \e -> if isAlreadyExistsError e
927 \e -> if isAlreadyExistsError e
930 then createTempDir (num + 1) baseName
928 then createTempDir (num + 1) baseName
931 else ioError e
929 else ioError e
933−-- | Template haskell function to insert bytestring contents of file into a template.
934−contentsOf :: FilePath -> ExpQ
935−contentsOf p = lift =<< runIO (B.readFile p)
937−instance Lift B.ByteString where
938− lift x = return (LitE (StringL $ B.unpack x))