summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-02-04 13:01:00 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-02-04 13:01:00 -0800
commit253a9e32aadea1064e429b4f561bf043c98d255f (patch)
tree620bfdb85831780093284197c0722913739508ba
parent1e772aa59c85fb94fe59a287c11d7c4a85b1c579 (diff)
Have handleIncludes look for local .sty files from \usepackage.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs10
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