mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-26 09:25:48 +00:00
Moved withTempDir from PDF to Shared, export from Shared.
API change.
This commit is contained in:
+1
-10
@@ -30,7 +30,6 @@ Conversion of LaTeX documents to PDF.
|
||||
-}
|
||||
module Text.Pandoc.PDF ( makePDF ) where
|
||||
|
||||
import System.IO.Temp
|
||||
import Data.ByteString.Lazy (ByteString)
|
||||
import qualified Data.ByteString.Lazy as B
|
||||
import qualified Data.ByteString.Lazy.Char8 as BC
|
||||
@@ -46,7 +45,7 @@ import Data.Maybe (fromMaybe)
|
||||
import qualified Text.Pandoc.UTF8 as UTF8
|
||||
import Text.Pandoc.Definition
|
||||
import Text.Pandoc.Walk (walkM)
|
||||
import Text.Pandoc.Shared (fetchItem, warn)
|
||||
import Text.Pandoc.Shared (fetchItem, warn, withTempDir)
|
||||
import Text.Pandoc.Options (WriterOptions(..))
|
||||
import Text.Pandoc.MIME (extensionFromMimeType)
|
||||
import Text.Pandoc.Process (pipeProcess)
|
||||
@@ -55,14 +54,6 @@ import qualified Data.ByteString.Lazy as BL
|
||||
import Data.List (intercalate)
|
||||
#endif
|
||||
|
||||
withTempDir :: String -> (FilePath -> IO a) -> IO a
|
||||
withTempDir =
|
||||
#ifdef _WINDOWS
|
||||
withTempDirectory "."
|
||||
#else
|
||||
withSystemTempDirectory
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
changePathSeparators :: FilePath -> FilePath
|
||||
changePathSeparators = intercalate "/" . splitDirectories
|
||||
|
||||
@@ -84,7 +84,9 @@ module Text.Pandoc.Shared (
|
||||
err,
|
||||
warn,
|
||||
-- * Safe read
|
||||
safeRead
|
||||
safeRead,
|
||||
-- * Temp directory
|
||||
withTempDir
|
||||
) where
|
||||
|
||||
import Text.Pandoc.Definition
|
||||
@@ -112,6 +114,7 @@ import Text.Pandoc.Pretty (charWidth)
|
||||
import System.Locale (defaultTimeLocale)
|
||||
import Data.Time
|
||||
import System.IO (stderr)
|
||||
import System.IO.Temp
|
||||
import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..),
|
||||
renderOptions)
|
||||
import qualified Data.ByteString as BS
|
||||
@@ -846,3 +849,15 @@ safeRead s = case reads s of
|
||||
(d,x):_
|
||||
| all isSpace x -> return d
|
||||
_ -> fail $ "Could not read `" ++ s ++ "'"
|
||||
|
||||
--
|
||||
-- Temp directory
|
||||
--
|
||||
|
||||
withTempDir :: String -> (FilePath -> IO a) -> IO a
|
||||
withTempDir =
|
||||
#ifdef _WINDOWS
|
||||
withTempDirectory "."
|
||||
#else
|
||||
withSystemTempDirectory
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user