git.iko.soy/typeable/pandoc
on master help sign in
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.

commit0f248162912bf86c78643749c75ad3b7d3ba86f4 authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 1 Nov 2012, 10:18 (14 years ago) parentda87837
1 file changed+8−14
src/Text/Pandoc/Readers/LaTeX.hs+8−14
src/Text/Pandoc/Readers/LaTeX.hs+8−14
@@ -681,22 +681,16 @@ rawEnv name = do
681681
682682-- | Replace "include" commands with file contents.
683683handleIncludes :: String -> IO String
684−handleIncludes = handleIncludes' []
685−
686−-- parents parameter prevents infinite include loops
687−handleIncludes' :: [FilePath] -> String -> IO String
688−handleIncludes' _ [] = return []
689−handleIncludes' parents ('\\':xs) =
684+handleIncludes [] = return []
685+handleIncludes ('\\':xs) =
690686 case runParser include defaultParserState "input" ('\\':xs) of
691− Right (fs, rest) -> do yss <- mapM readTeXFile
692− [f | f <- fs, f `notElem` parents]
693− handleIncludes' (parents ++ fs) $
694− intercalate "\n" yss ++ rest
687+ Right (fs, rest) -> do yss <- mapM readTeXFile fs
688+ handleIncludes $ intercalate "\n" yss ++ rest
695689 _ -> case runParser (verbCmd <|> verbatimEnv) defaultParserState
696− "input" ('\\':xs) of
697− Right (r, rest) -> (r ++) `fmap` handleIncludes' parents rest
698− _ -> ('\\':) `fmap` handleIncludes' parents xs
699−handleIncludes' parents (x:xs) = (x:) `fmap` handleIncludes' parents xs
690+ "input" ('\\':xs) of
691+ Right (r, rest) -> (r ++) `fmap` handleIncludes rest
692+ _ -> ('\\':) `fmap` handleIncludes xs
693+handleIncludes (x:xs) = (x:) `fmap` handleIncludes xs
700694
701695readTeXFile :: FilePath -> IO String
702696readTeXFile f = do