LaTeX reader: don't limit includes to .tex extension.
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.
This commit is contained in:
parent
e88119f2d1
commit
d90dc6b8b5
1 changed files with 8 additions and 2 deletions
|
@ -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
|
||||
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue