diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 10 |
1 files changed, 7 insertions, 3 deletions
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 |