diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-01-22 23:17:25 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-01-22 23:17:25 -0800 |
commit | d90dc6b8b569805d2ffb36b6ad56da064343f13c (patch) | |
tree | bb88f77fff24f140379cecb9f35b3e8facadeaea /src/Text/Pandoc | |
parent | e88119f2d144dc4a1463b0c451f11fdc6becc4c7 (diff) | |
download | pandoc-d90dc6b8b569805d2ffb36b6ad56da064343f13c.tar.gz |
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.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 6f3090e10..942b9f3b3 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -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 |