git.iko.soy/typeable/pandoc
on master help sign in
Fixed -Wall errors in PDF module.
commit50e16e68559d0696d197ef9ff8b147b4ffc48b2a authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 20 Jan 2012, 19:04 (15 years ago) parent9d1118a
1 file changed+13−20
src/Text/Pandoc/PDF.hs+13−20
src/Text/Pandoc/PDF.hs+13−20
@@ -30,23 +30,17 @@ Conversion of LaTeX documents to PDF.
3030-}
3131module Text.Pandoc.PDF ( tex2pdf ) where
3232
33−import Data.Char (isDigit)
3433import System.IO.Temp
35−import Data.Maybe (catMaybes)
3634import Data.Char (toLower)
3735import Data.ByteString.Lazy (ByteString)
3836import qualified Data.ByteString.Lazy as B
3937import qualified Data.ByteString.Lazy.Char8 as BC
40−import qualified Data.ByteString as BS
41−import System.Exit (ExitCode (..), exitWith)
38+import System.Exit (ExitCode (..))
4239import System.FilePath
4340import System.Directory
4441import System.Process
45−import Control.Exception (tryJust, evaluate)
46−import Control.Monad.Trans (liftIO)
47−import Control.Monad (guard)
48−import System.IO.Error (isAlreadyExistsError)
49−import System.IO (hClose, stderr, stdout)
42+import Control.Exception (evaluate)
43+import System.IO (hClose)
5044import Control.Concurrent (putMVar, takeMVar, newEmptyMVar, forkIO)
5145import Text.Pandoc.UTF8 as UTF8
5246
@@ -54,17 +48,16 @@ tex2pdf :: TeXProgram
5448 -> String -- ^ latex source
5549 -> IO (Either TeXError ByteString)
5650tex2pdf program source = withSystemTempDirectory "tex2pdf" $ \tmpdir ->
57− tex2pdf' 1 tmpdir program source
51+ tex2pdf' tmpdir program source
5852
59−tex2pdf' :: Int -- ^ number of run
60− -> FilePath -- ^ temp directory for output
53+tex2pdf' :: FilePath -- ^ temp directory for output
6154 -> TeXProgram
6255 -> String -- ^ tex source
6356 -> IO (Either TeXError ByteString)
64−tex2pdf' run tmpDir program source = do
65− (exit, log, mbPdf) <- runTeXProgram program 3 tmpDir source
57+tex2pdf' tmpDir program source = do
58+ (exit, log', mbPdf) <- runTeXProgram program 3 tmpDir source
6659 case (exit, mbPdf) of
67− (ExitFailure ec, _) -> return $ Left $ extractTeXError ec log
60+ (ExitFailure ec, _) -> return $ Left $ extractTeXError ec log'
6861 (ExitSuccess, Nothing) -> error "tex2pdf: ExitSuccess but no PDF created!"
6962 (ExitSuccess, Just pdf) -> return $ Right pdf
7063
@@ -84,13 +77,13 @@ data TeXError = TeXError { exitCode :: Int
8477-- parsing output
8578
8679extractTeXError :: Int -> ByteString -> TeXError
87−extractTeXError ec log = TeXError { exitCode = ec
88− , message = extractMsg log
89− , fullLog = log }
80+extractTeXError ec log' = TeXError { exitCode = ec
81+ , message = extractMsg log'
82+ , fullLog = log' }
9083
9184extractMsg :: ByteString -> ByteString
92−extractMsg log = do
93− let msg' = dropWhile (not . ("!" `BC.isPrefixOf`)) $ BC.lines log
85+extractMsg log' = do
86+ let msg' = dropWhile (not . ("!" `BC.isPrefixOf`)) $ BC.lines log'
9487 let (msg'',rest) = break ("l." `BC.isPrefixOf`) msg'
9588 let lineno = take 1 rest
9689 if not (null msg')