LaTeX reader: further fixes to include.

This commit is contained in:
John MacFarlane 2016-12-03 22:59:05 +01:00
parent 62b30d8418
commit 7a68617556

View file

@ -977,14 +977,18 @@ readTeXFile f = do
readFileFromDirs (splitBy (==':') texinputs) f
readFileFromDirs :: PandocMonad m => [FilePath] -> FilePath -> m String
readFileFromDirs ds f =
mconcat <$> mapM (\d -> readFileLazy' (d </> f)) ds
readFileLazy' :: PandocMonad m => FilePath -> m String
readFileLazy' f = catchError (UTF8.toStringLazy <$> readFileLazy f) $
\(e :: PandocError) -> do
warning $ "Could not load include file " ++ f ++ ", skipping.\n" ++ show e
readFileFromDirs [] f = do
warning $ "Could not load include file " ++ f ++ ", skipping."
return ""
readFileFromDirs (d:ds) f = do
res <- readFileLazy' (d </> f)
case res of
Right s -> return s
Left _ -> readFileFromDirs ds f
readFileLazy' :: PandocMonad m => FilePath -> m (Either PandocError String)
readFileLazy' f = catchError ((Right . UTF8.toStringLazy) <$> readFileLazy f) $
\(e :: PandocError) -> return (Left e)
----