aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-02-06 08:36:29 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-02-06 08:36:29 -0800
commit8dfbe3bbe8155c82123028985b380ce9abdc4fa9 (patch)
tree717fffc6c9c5bc30f3dad95baadff2b70947c6e0 /src/Text/Pandoc
parent1a2eea23a19aeb838bfdb9f7c2fa4ef9e83e72f1 (diff)
downloadpandoc-8dfbe3bbe8155c82123028985b380ce9abdc4fa9.tar.gz
Implement `--default-image-extension` for LaTeX reader.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 253e50ef2..1eba22251 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -51,6 +51,7 @@ import System.FilePath (replaceExtension, (</>))
import Data.List (intercalate)
import qualified Data.Map as M
import qualified Control.Exception as E
+import System.FilePath (takeExtension, addExtension)
-- | Parse LaTeX from string and return 'Pandoc' document.
readLaTeX :: ReaderOptions -- ^ Reader options
@@ -430,8 +431,7 @@ inlineCommands = M.fromList $
, ("href", (unescapeURL <$> braced <* optional sp) >>= \url ->
tok >>= \lab ->
pure (link url "" lab))
- , ("includegraphics", skipopts *> (unescapeURL <$> braced) >>=
- (\src -> pure (image src "" (str "image"))))
+ , ("includegraphics", skipopts *> (unescapeURL <$> braced) >>= mkImage)
, ("enquote", enquote)
, ("cite", citation "cite" AuthorInText False)
, ("citep", citation "citep" NormalCitation False)
@@ -488,6 +488,14 @@ inlineCommands = M.fromList $
-- in which case they will appear as raw latex blocks:
[ "noindent", "index", "nocite" ]
+mkImage :: String -> LP Inlines
+mkImage src =
+ case takeExtension src of
+ "" -> do
+ defaultExt <- getOption readerDefaultImageExtension
+ return $ image (addExtension src defaultExt) "" (str "image")
+ _ -> return $ image src "" (str "image")
+
inNote :: Inlines -> Inlines
inNote ils =
note $ para $ ils <> str "."