@@ -50,7 +50,7 @@ import qualified Text.Pandoc.UTF8 as UTF8
50import Text.Pandoc.Definition
50import Text.Pandoc.Definition
51import Text.Pandoc.MediaBag
51import Text.Pandoc.MediaBag
52import Text.Pandoc.Walk (walkM)
52import Text.Pandoc.Walk (walkM)
53−import Text.Pandoc.Shared (warn, withTempDir, inDirectory, stringify)
53+import Text.Pandoc.Shared (withTempDir, inDirectory, stringify)
54import Text.Pandoc.Writers.Shared (getField, metaToJSON)
54import Text.Pandoc.Writers.Shared (getField, metaToJSON)
55import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..))
55import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..))
56import Text.Pandoc.Logging (Verbosity(..))
56import Text.Pandoc.Logging (Verbosity(..))
@@ -62,8 +62,9 @@ import qualified Codec.Picture as JP
62#ifdef _WINDOWS
62#ifdef _WINDOWS
63import Data.List (intercalate)
63import Data.List (intercalate)
65−import Text.Pandoc.Class (PandocIO, runIOorExplode, fetchItem,
65+import Text.Pandoc.Class (PandocIO, runIOorExplode, fetchItem, report,
66 setVerbosity, setMediaBag, runIO)
66 setVerbosity, setMediaBag, runIO)
67+import Text.Pandoc.Logging
68#ifdef _WINDOWS
69#ifdef _WINDOWS
69changePathSeparators :: FilePath -> FilePath
70changePathSeparators :: FilePath -> FilePath
@@ -124,7 +125,7 @@ handleImages :: Verbosity
124 -> Pandoc -- ^ document
125 -> Pandoc -- ^ document
125 -> IO Pandoc
126 -> IO Pandoc
126handleImages verbosity opts mediabag tmpdir =
127handleImages verbosity opts mediabag tmpdir =
127− walkM (convertImages tmpdir) <=<
128+ walkM (convertImages verbosity tmpdir) <=<
128 walkM (handleImage' verbosity opts mediabag tmpdir)
129 walkM (handleImage' verbosity opts mediabag tmpdir)
130handleImage' :: Verbosity
131handleImage' :: Verbosity
@@ -151,20 +152,26 @@ handleImage' verbosity opts mediabag tmpdir (Image attr ils (src,tit)) = do
151 BS.writeFile fname contents
152 BS.writeFile fname contents
152 return $ Image attr ils (fname,tit)
153 return $ Image attr ils (fname,tit)
154− warn $ "Could not find image `" ++ src ++ "', skipping..."
155+ runIO $ do
156+ setVerbosity verbosity
157+ report $ CouldNotFetchResource src "skipping..."
155 -- return alt text
158 -- return alt text
156 return $ Emph ils
159 return $ Emph ils
157handleImage' _ _ _ _ x = return x
160handleImage' _ _ _ _ x = return x
159−convertImages :: FilePath -> Inline -> IO Inline
162+convertImages :: Verbosity -> FilePath -> Inline -> IO Inline
160−convertImages tmpdir (Image attr ils (src, tit)) = do
163+convertImages verbosity tmpdir (Image attr ils (src, tit)) = do
161 img <- convertImage tmpdir src
164 img <- convertImage tmpdir src
162 newPath <-
165 newPath <-
163 case img of
166 case img of
164− Left e -> src <$ warn e
167+ Left e -> do
169+ setVerbosity verbosity
170+ report $ CouldNotConvertImage src e
165 Right fp -> return fp
172 Right fp -> return fp
166 return (Image attr ils (newPath, tit))
173 return (Image attr ils (newPath, tit))
167−convertImages _ x = return x
174+convertImages _ _ x = return x
169-- Convert formats which do not work well in pdf to png
176-- Convert formats which do not work well in pdf to png
170convertImage :: FilePath -> FilePath -> IO (Either String FilePath)
177convertImage :: FilePath -> FilePath -> IO (Either String FilePath)
@@ -175,8 +182,7 @@ convertImage tmpdir fname =
175 Just "application/pdf" -> doNothing
182 Just "application/pdf" -> doNothing
176 _ -> JP.readImage fname >>= \res ->
183 _ -> JP.readImage fname >>= \res ->
177 case res of
184 case res of
178− Left _ -> return $ Left $ "Unable to convert `" ++
185+ Left e -> return $ Left e
179− fname ++ "' for use with pdflatex."
180 Right img ->
186 Right img ->
181 E.catch (Right fileOut <$ JP.savePngImage fileOut img) $
187 E.catch (Right fileOut <$ JP.savePngImage fileOut img) $
182 \(e :: E.SomeException) -> return (Left (show e))
188 \(e :: E.SomeException) -> return (Left (show e))