git.iko.soy/typeable/pandoc
on master help sign in
PandocMonad: add info message in `downloadOrRead`...

indicating what path local resources have been loaded from.

commitf2c1b5746912db945be780961b6503e38c3c7e1e authorJohn MacFarlane <jgm@berkeley.edu> dateTue 25 May 2021, 10:08 (5 years ago) parentfb40c81
1 file changed+8−5
src/Text/Pandoc/Class/PandocMonad.hs+8−5
src/Text/Pandoc/Class/PandocMonad.hs+8−5
@@ -1,4 +1,5 @@
11{-# LANGUAGE CPP #-}
2+{-# LANGUAGE TupleSections #-}
23{-# LANGUAGE FlexibleContexts #-}
34{-# LANGUAGE FlexibleInstances #-}
45{-# LANGUAGE MultiParamTypeClasses #-}
@@ -409,9 +410,10 @@ downloadOrRead s = do
409410 _ -> readLocalFile fp -- get from local file system
410411 where readLocalFile f = do
411412 resourcePath <- getResourcePath
412− cont <- if isRelative f
413− then withPaths resourcePath readFileStrict f
414− else readFileStrict f
413+ (fp', cont) <- if isRelative f
414+ then withPaths resourcePath readFileStrict f
415+ else (f,) <$> readFileStrict f
416+ report $ LoadedResource f fp'
415417 return (cont, mime)
416418 httpcolon = URI{ uriScheme = "http:",
417419 uriAuthority = Nothing,
@@ -621,10 +623,11 @@ makeCanonical = Posix.joinPath . transformPathParts . splitDirectories
621623-- that filepath. Returns the result of the first successful execution
622624-- of the action, or throws a @PandocResourceNotFound@ exception if the
623625-- action errors for all filepaths.
624−withPaths :: PandocMonad m => [FilePath] -> (FilePath -> m a) -> FilePath -> m a
626+withPaths :: PandocMonad m
627+ => [FilePath] -> (FilePath -> m a) -> FilePath -> m (FilePath, a)
625628withPaths [] _ fp = throwError $ PandocResourceNotFound $ T.pack fp
626629withPaths (p:ps) action fp =
627− catchError (action (p </> fp))
630+ catchError ((p </> fp,) <$> action (p </> fp))
628631 (\_ -> withPaths ps action fp)
629632
630633-- | Traverse tree, filling media bag for any images that