@@ -960,22 +960,24 @@ include = do
960 return $ if name == "usepackage"
960 return $ if name == "usepackage"
961 then map (maybeAddExtension ".sty") fs
961 then map (maybeAddExtension ".sty") fs
962 else map (maybeAddExtension ".tex") fs
962 else map (maybeAddExtension ".tex") fs
963+ mconcat <$> mapM insertIncludedFile fs'
965+insertIncludedFile :: PandocMonad m => FilePath -> LP m Blocks
966+insertIncludedFile f = do
963 oldPos <- getPosition
967 oldPos <- getPosition
964 oldInput <- getInput
968 oldInput <- getInput
965− -- now process each include file in order...
966− mconcat <$> forM fs' (\f -> do
967− containers <- stateContainers <$> getState
969+ containers <- stateContainers <$> getState
968− when (f `elem` containers) $
970+ when (f `elem` containers) $
969− throwError $ PandocParseError $ "Include file loop at " ++ show oldPos
971+ throwError $ PandocParseError $ "Include file loop at " ++ show oldPos
970− updateState $ \s -> s{ stateContainers = f : stateContainers s }
972+ updateState $ \s -> s{ stateContainers = f : stateContainers s }
971− contents <- lift $ readTeXFile f
973+ contents <- lift $ readTeXFile f
972− setPosition $ newPos f 1 1
974+ setPosition $ newPos f 1 1
973− setInput contents
975+ setInput contents
974− bs <- blocks
976+ bs <- blocks
975− setInput oldInput
977+ setInput oldInput
976− setPosition oldPos
978+ setPosition oldPos
977− updateState $ \s -> s{ stateContainers = tail $ stateContainers s }
979+ updateState $ \s -> s{ stateContainers = tail $ stateContainers s }
978− return bs)
980+ return bs
980readTeXFile :: PandocMonad m => FilePath -> m String
982readTeXFile :: PandocMonad m => FilePath -> m String
981readTeXFile f = do
983readTeXFile f = do