diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-12-03 22:59:05 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-25 17:07:40 +0100 |
commit | 7a686175567295a5169625b5e5428f5b3300ea2a (patch) | |
tree | 760f0d9733c61bb506b35e79da7883c9cdd71993 /src/Text | |
parent | 62b30d841823f6b9452e5a3d26b2ef5b52ca531c (diff) | |
download | pandoc-7a686175567295a5169625b5e5428f5b3300ea2a.tar.gz |
LaTeX reader: further fixes to include.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 222b91e5d..9dc043783 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -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) ---- |