aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-01-20 17:35:51 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-01-20 17:35:51 -0800
commit26dfab2e61b45722967e2a2f9330bf5e101b9f31 (patch)
tree130a9b189d4f11fc44dd22ef6a4c58148eb0cecc /src/Text/Pandoc
parentfb1f76ddee89114a0cd1be2b2ec0c3abbad80dca (diff)
downloadpandoc-26dfab2e61b45722967e2a2f9330bf5e101b9f31.tar.gz
LaTeX reader: cleaned up 'input' code.
Diffstat (limited to 'src/Text/Pandoc')
-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 }