From 253a9e32aadea1064e429b4f561bf043c98d255f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 4 Feb 2012 13:01:00 -0800 Subject: Have handleIncludes look for local .sty files from \usepackage. --- src/Text/Pandoc/Readers/LaTeX.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index d74bfe983..41f9c40f7 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -536,7 +536,7 @@ handleIncludes :: String -> IO String handleIncludes [] = return [] handleIncludes ('\\':xs) = case runParser include defaultParserState "input" ('\\':xs) of - Right (f, rest) -> do ys <- catch (readFile (replaceExtension f ".tex")) + Right (f, rest) -> do ys <- catch (readFile f) (\e -> warn ("could not open included file `" ++ f ++ "': " ++ show e) >> return "") @@ -548,10 +548,14 @@ handleIncludes (x:xs) = (x:) `fmap` handleIncludes xs include :: LP (FilePath, String) include = do - controlSeq "include" + name <- controlSeq "include" <|> controlSeq "usepackage" + optional opt f <- braced rest <- getInput - return (f, rest) + let f' = if name == "include" + then replaceExtension f ".tex" + else replaceExtension f ".sty" + return (f', rest) verbatimEnv :: LP (String, String) verbatimEnv = do -- cgit v1.2.3