Skip to content

Commit

Permalink
LaTeX reader: don't limit includes to .tex extension.
Browse files Browse the repository at this point in the history
Previously `\input` and `\include` would only work if the
included files had the extension `.tex`.  This change relaxes
that restriction, though if the extension is not `.tex`, it
must be given explicitly in the `\input` or `\include`.

Closes #1882.
  • Loading branch information
jgm committed Jan 23, 2015
1 parent e88119f commit d90dc6b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Text/Pandoc/Readers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,12 @@ backslash' = string "\\"
braced' :: IncludeParser
braced' = try $ char '{' *> manyTill (satisfy (/='}')) (char '}')

maybeAddExtension :: String -> FilePath -> FilePath
maybeAddExtension ext fp =
if null (takeExtension fp)
then addExtension fp ext
else fp

include' :: IncludeParser
include' = do
fs' <- try $ do
Expand All @@ -909,8 +915,8 @@ include' = do
skipMany $ try $ char '[' *> (manyTill anyChar (char ']'))
fs <- (map trim . splitBy (==',')) <$> braced'
return $ if name == "usepackage"
then map (flip replaceExtension ".sty") fs
else map (flip replaceExtension ".tex") fs
then map (maybeAddExtension ".sty") fs
else map (maybeAddExtension ".tex") fs
pos <- getPosition
containers <- getState
let fn = case containers of
Expand Down

0 comments on commit d90dc6b

Please sign in to comment.