aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs22
-rw-r--r--test/command/4933.md6
2 files changed, 22 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 73780a8b8..fe677e470 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -43,7 +43,7 @@ import Text.Pandoc.BCP47 (Lang (..), renderLang)
import Text.Pandoc.Builder
import Text.Pandoc.Class (PandocMonad, PandocPure, getResourcePath, lookupEnv,
readFileFromDirs, report, setResourcePath,
- setTranslations, translateTerm, trace)
+ setTranslations, translateTerm, trace, fileExists)
import Text.Pandoc.Error (PandocError ( PandocParseError, PandocParsecError))
import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension)
import Text.Pandoc.ImageSize (numUnit, showFl)
@@ -205,11 +205,21 @@ mkImage options src = do
$ filter (\(k,_) -> k `elem` ["width", "height"]) options
let attr = ("",[], kvs)
let alt = str "image"
- case takeExtension src of
- "" -> do
- defaultExt <- getOption readerDefaultImageExtension
- return $ imageWith attr (addExtension src defaultExt) "" alt
- _ -> return $ imageWith attr src "" alt
+ defaultExt <- getOption readerDefaultImageExtension
+ let exts' = [".pdf", ".png", ".jpg", ".mps", ".jpeg", ".jbig2", ".jb2"]
+ let exts = exts' ++ map (map toUpper) exts'
+ let findFile s [] = return s
+ findFile s (e:es) = do
+ let s' = addExtension s e
+ exists <- fileExists s'
+ if exists
+ then return s'
+ else findFile s es
+ src' <- case takeExtension src of
+ "" | not (null defaultExt) -> return $ addExtension src defaultExt
+ | otherwise -> findFile src exts
+ _ -> return src
+ return $ imageWith attr src' "" alt
doxspace :: PandocMonad m => LP m Inlines
doxspace =
diff --git a/test/command/4933.md b/test/command/4933.md
new file mode 100644
index 000000000..4ab41e8a5
--- /dev/null
+++ b/test/command/4933.md
@@ -0,0 +1,6 @@
+```
+% pandoc -f latex -t native
+\includegraphics{lalune}
+^D
+[Para [Image ("",[],[]) [Str "image"] ("lalune.jpg","")]]
+```