git.iko.soy/typeable/pandoc
on master help sign in
Free: Remove readFileUTF8.
2ffd630Jesse Rosenthal
src/Text/Pandoc/Free.hs−12
@@ -46,7 +46,6 @@ module Text.Pandoc.Free ( PandocActionF(..)
46 , newStdGen
46 , newStdGen
47 , newUniqueHash
47 , newUniqueHash
48 , readFileLazy
48 , readFileLazy
49− , readFileUTF8
50 , readDataFile
49 , readDataFile
51 , fetchItem
50 , fetchItem
52 , fetchItem'
51 , fetchItem'
@@ -79,7 +78,6 @@ import qualified Data.ByteString.Lazy as BL
79import Control.Monad.Free
78import Control.Monad.Free
80import qualified Control.Exception as E
79import qualified Control.Exception as E
81import qualified System.Environment as IO (lookupEnv)
80import qualified System.Environment as IO (lookupEnv)
82−import qualified Text.Pandoc.UTF8 as UTF8 (readFile, toString)
83import System.FilePath.Glob (match, compile)
81import System.FilePath.Glob (match, compile)
84import System.FilePath ((</>))
82import System.FilePath ((</>))
85import qualified System.FilePath.Glob as IO (glob)
83import qualified System.FilePath.Glob as IO (glob)
@@ -97,7 +95,6 @@ data PandocActionF nxt =
97 | NewStdGen (StdGen -> nxt)
95 | NewStdGen (StdGen -> nxt)
98 | NewUniqueHash (Int -> nxt)
96 | NewUniqueHash (Int -> nxt)
99 | ReadFileLazy FilePath (BL.ByteString -> nxt)
97 | ReadFileLazy FilePath (BL.ByteString -> nxt)
100− | ReadFileUTF8 FilePath (String -> nxt)
101 | ReadDataFile (Maybe FilePath) FilePath (B.ByteString -> nxt)
98 | ReadDataFile (Maybe FilePath) FilePath (B.ByteString -> nxt)
102 | FetchItem (Maybe String) (String)
99 | FetchItem (Maybe String) (String)
103 (Either E.SomeException (B.ByteString, Maybe MimeType) -> nxt)
100 (Either E.SomeException (B.ByteString, Maybe MimeType) -> nxt)
@@ -134,9 +131,6 @@ newUniqueHash = liftF $ NewUniqueHash id
134readFileLazy :: FilePath -> PandocAction BL.ByteString
131readFileLazy :: FilePath -> PandocAction BL.ByteString
135readFileLazy fp = liftF $ ReadFileLazy fp id
132readFileLazy fp = liftF $ ReadFileLazy fp id
136
133
137−readFileUTF8 :: FilePath -> PandocAction String
138−readFileUTF8 fp = liftF $ ReadFileUTF8 fp id
139−
140readDataFile :: Maybe FilePath -> FilePath -> PandocAction B.ByteString
134readDataFile :: Maybe FilePath -> FilePath -> PandocAction B.ByteString
141readDataFile mfp fp = liftF $ ReadDataFile mfp fp id
135readDataFile mfp fp = liftF $ ReadDataFile mfp fp id
142
136
@@ -172,7 +166,6 @@ runIO (Free (GetDefaultReferenceODT mfp f)) =
172runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
166runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
173runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
167runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
174runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
168runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
175−runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f
176runIO (Free (ReadDataFile mfp fp f)) = IO.readDataFile mfp fp >>= runIO . f
169runIO (Free (ReadDataFile mfp fp f)) = IO.readDataFile mfp fp >>= runIO . f
177runIO (Free (Fail s)) = M.fail s
170runIO (Free (Fail s)) = M.fail s
178runIO (Free (FetchItem sourceUrl nm f)) =
171runIO (Free (FetchItem sourceUrl nm f)) =
@@ -241,11 +234,6 @@ runTest (Free (ReadFileLazy fp f)) = do
241 case lookup fp fps of
234 case lookup fp fps of
242 Just bs -> return (BL.fromStrict bs) >>= runTest . f
235 Just bs -> return (BL.fromStrict bs) >>= runTest . f
243 Nothing -> error "openFile: does not exist"
236 Nothing -> error "openFile: does not exist"
244−runTest (Free (ReadFileUTF8 fp f)) = do
245− fps <- asks envFiles
246− case lookup fp fps of
247− Just bs -> return (UTF8.toString bs) >>= runTest . f
248− Nothing -> error "openFile: does not exist"
249-- A few different cases of readDataFile to reimplement, for when
237-- A few different cases of readDataFile to reimplement, for when
250-- there is no filepath and it falls through to readDefaultDataFile
238-- there is no filepath and it falls through to readDefaultDataFile
251runTest (Free (ReadDataFile Nothing "reference.docx" f)) = do
239runTest (Free (ReadDataFile Nothing "reference.docx" f)) = do
src/Text/Pandoc/Writers/EPUB.hs+1−1
@@ -710,7 +710,7 @@ pandocToEPUB opts doc@(Pandoc meta _) = do
710
710
711 -- stylesheet
711 -- stylesheet
712 stylesheet <- case epubStylesheet metadata of
712 stylesheet <- case epubStylesheet metadata of
713− Just (StylesheetPath fp) -> lift $ P.readFileUTF8 fp
713+ Just (StylesheetPath fp) -> UTF8.toStringLazy <$> (lift $ P.readFileLazy fp)
714 Just (StylesheetContents s) -> return s
714 Just (StylesheetContents s) -> return s
715 Nothing -> UTF8.toString `fmap`
715 Nothing -> UTF8.toString `fmap`
716 (lift $ P.readDataFile (writerUserDataDir opts) "epub.css")
716 (lift $ P.readDataFile (writerUserDataDir opts) "epub.css")