@@ -50,7 +50,7 @@ import qualified Text.Pandoc.UTF8 as UTF8
5050import Text.Pandoc.Definition
5151import Text.Pandoc.MediaBag
5252import Text.Pandoc.Walk (walkM)
53−import Text.Pandoc.Shared (warn, withTempDir, inDirectory, stringify)
53+import Text.Pandoc.Shared (withTempDir, inDirectory, stringify)
5454import Text.Pandoc.Writers.Shared (getField, metaToJSON)
5555import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..))
5656import Text.Pandoc.Logging (Verbosity(..))
@@ -62,8 +62,9 @@ import qualified Codec.Picture as JP
6262#ifdef _WINDOWS
6363import Data.List (intercalate)
6464#endif
65−import Text.Pandoc.Class (PandocIO, runIOorExplode, fetchItem,
65+import Text.Pandoc.Class (PandocIO, runIOorExplode, fetchItem, report,
6666 setVerbosity, setMediaBag, runIO)
67+import Text.Pandoc.Logging
6768
6869#ifdef _WINDOWS
6970changePathSeparators :: FilePath -> FilePath
@@ -124,7 +125,7 @@ handleImages :: Verbosity
124125 -> Pandoc -- ^ document
125126 -> IO Pandoc
126127handleImages verbosity opts mediabag tmpdir =
127− walkM (convertImages tmpdir) <=<
128+ walkM (convertImages verbosity tmpdir) <=<
128129 walkM (handleImage' verbosity opts mediabag tmpdir)
129130
130131handleImage' :: Verbosity
@@ -151,20 +152,26 @@ handleImage' verbosity opts mediabag tmpdir (Image attr ils (src,tit)) = do
151152 BS.writeFile fname contents
152153 return $ Image attr ils (fname,tit)
153154 _ -> do
154− warn $ "Could not find image `" ++ src ++ "', skipping..."
155+ runIO $ do
156+ setVerbosity verbosity
157+ report $ CouldNotFetchResource src "skipping..."
155158 -- return alt text
156159 return $ Emph ils
157160handleImage' _ _ _ _ x = return x
158161
159−convertImages :: FilePath -> Inline -> IO Inline
160−convertImages tmpdir (Image attr ils (src, tit)) = do
162+convertImages :: Verbosity -> FilePath -> Inline -> IO Inline
163+convertImages verbosity tmpdir (Image attr ils (src, tit)) = do
161164 img <- convertImage tmpdir src
162165 newPath <-
163166 case img of
164− Left e -> src <$ warn e
167+ Left e -> do
168+ runIO $ do
169+ setVerbosity verbosity
170+ report $ CouldNotConvertImage src e
171+ return src
165172 Right fp -> return fp
166173 return (Image attr ils (newPath, tit))
167−convertImages _ x = return x
174+convertImages _ _ x = return x
168175
169176-- Convert formats which do not work well in pdf to png
170177convertImage :: FilePath -> FilePath -> IO (Either String FilePath)
@@ -175,8 +182,7 @@ convertImage tmpdir fname =
175182 Just "application/pdf" -> doNothing
176183 _ -> JP.readImage fname >>= \res ->
177184 case res of
178− Left _ -> return $ Left $ "Unable to convert `" ++
179− fname ++ "' for use with pdflatex."
185+ Left e -> return $ Left e
180186 Right img ->
181187 E.catch (Right fileOut <$ JP.savePngImage fileOut img) $
182188 \(e :: E.SomeException) -> return (Left (show e))