aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-11-01 10:18:17 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-11-01 10:18:17 -0700
commit0f248162912bf86c78643749c75ad3b7d3ba86f4 (patch)
tree594e13745736bbd261e9a8660c6152594aed2cc3
parentda87837318cf035be407136b39c5ec6a0009adb4 (diff)
downloadpandoc-0f248162912bf86c78643749c75ad3b7d3ba86f4.tar.gz
Revert "LaTeX reader: Added code to handleIncludes to avoid inf loops."
This reverts commit da87837318cf035be407136b39c5ec6a0009adb4. Reason: The code was overzealous and would rule out some things we want to be able to do, like include the same file multiple times.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 4dce1726e..22d9b237a 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -681,22 +681,16 @@ rawEnv name = do
-- | Replace "include" commands with file contents.
handleIncludes :: String -> IO String
-handleIncludes = handleIncludes' []
-
--- parents parameter prevents infinite include loops
-handleIncludes' :: [FilePath] -> String -> IO String
-handleIncludes' _ [] = return []
-handleIncludes' parents ('\\':xs) =
+handleIncludes [] = return []
+handleIncludes ('\\':xs) =
case runParser include defaultParserState "input" ('\\':xs) of
- Right (fs, rest) -> do yss <- mapM readTeXFile
- [f | f <- fs, f `notElem` parents]
- handleIncludes' (parents ++ fs) $
- intercalate "\n" yss ++ rest
+ Right (fs, rest) -> do yss <- mapM readTeXFile fs
+ handleIncludes $ intercalate "\n" yss ++ rest
_ -> case runParser (verbCmd <|> verbatimEnv) defaultParserState
- "input" ('\\':xs) of
- Right (r, rest) -> (r ++) `fmap` handleIncludes' parents rest
- _ -> ('\\':) `fmap` handleIncludes' parents xs
-handleIncludes' parents (x:xs) = (x:) `fmap` handleIncludes' parents xs
+ "input" ('\\':xs) of
+ Right (r, rest) -> (r ++) `fmap` handleIncludes rest
+ _ -> ('\\':) `fmap` handleIncludes xs
+handleIncludes (x:xs) = (x:) `fmap` handleIncludes xs
readTeXFile :: FilePath -> IO String
readTeXFile f = do