aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index f0669164c..3120afaec 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1448,11 +1448,12 @@ include name = do
skipMany opt
fs <- (map (T.unpack . removeDoubleQuotes . T.strip) . T.splitOn "," .
untokenize) <$> braced
- let fs' = if name == "usepackage"
- then map (maybeAddExtension ".sty") fs
- else map (maybeAddExtension ".tex") fs
+ let addExt f = case takeExtension f of
+ "" | name == "usepackage" -> addExtension f ".sty"
+ | otherwise -> addExtension f ".tex"
+ _ -> f
dirs <- (splitBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"
- mapM_ (insertIncluded dirs) fs'
+ mapM_ (insertIncluded dirs) (map addExt fs)
return mempty
insertIncluded :: PandocMonad m
@@ -1474,12 +1475,6 @@ insertIncluded dirs f = do
getInput >>= setInput . (tokenize f (T.pack contents) ++)
updateState dropLatestIncludeFile
-maybeAddExtension :: String -> FilePath -> FilePath
-maybeAddExtension ext fp =
- if null (takeExtension fp)
- then addExtension fp ext
- else fp
-
addMeta :: PandocMonad m => ToMetaValue a => String -> a -> LP m ()
addMeta field val = updateState $ \st ->
st{ sMeta = addMetaField field val $ sMeta st }