From 26dfab2e61b45722967e2a2f9330bf5e101b9f31 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 20 Jan 2019 17:35:51 -0800 Subject: LaTeX reader: cleaned up 'input' code. --- src/Text/Pandoc/Readers/LaTeX.hs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/Text') 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 } -- cgit v1.2.3