diff options
Diffstat (limited to 'src/Text/Pandoc/Class.hs')
-rw-r--r-- | src/Text/Pandoc/Class.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs index 348da71ba..f75db4b3a 100644 --- a/src/Text/Pandoc/Class.hs +++ b/src/Text/Pandoc/Class.hs @@ -44,6 +44,7 @@ module Text.Pandoc.Class ( PandocMonad(..) , warningWithPos , report , getLog + , readFileFromDirs , setVerbosity , getMediaBag , setMediaBag @@ -206,6 +207,15 @@ getZonedTime = do tz <- getCurrentTimeZone return $ utcToZonedTime tz t +-- | Read file, checking in any number of directories. +readFileFromDirs :: PandocMonad m => [FilePath] -> FilePath -> m String +readFileFromDirs [] f = do + warning $ "Could not load include file " ++ f ++ ", skipping." + return "" +readFileFromDirs (d:ds) f = catchError + (UTF8.toStringLazy <$> readFileLazy (d </> f)) + (\_ -> readFileFromDirs ds f) + -- newtype DeferredMediaPath = DeferredMediaPath {unDefer :: String} |