aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-09-30 21:58:35 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-09-30 21:58:35 -0700
commit73c47a44d86f5075e3635e90574de12ac5f0b2eb (patch)
treea91cd0e30727c2e0c8b3cec4c7092abea7732712 /src/Text/Pandoc/Lua
parent896c288625a8c48e290fe86e90b65109bd4fce9f (diff)
downloadpandoc-73c47a44d86f5075e3635e90574de12ac5f0b2eb.tar.gz
Lua: make lua.mediabag.fetch return filename and mime type.
This is necessary because you may need to insert the filename into an image or link element.
Diffstat (limited to 'src/Text/Pandoc/Lua')
-rw-r--r--src/Text/Pandoc/Lua/PandocModule.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Lua/PandocModule.hs b/src/Text/Pandoc/Lua/PandocModule.hs
index bf45cab17..a110905e5 100644
--- a/src/Text/Pandoc/Lua/PandocModule.hs
+++ b/src/Text/Pandoc/Lua/PandocModule.hs
@@ -38,6 +38,7 @@ import Control.Monad (unless, zipWithM_)
import Data.ByteString.Char8 (unpack)
import Data.Default (Default (..))
import Data.IORef
+import Data.Maybe (fromMaybe)
import Data.Text (pack)
import Foreign.Lua (Lua, FromLuaStack, ToLuaStack, NumResults, liftIO)
import Text.Pandoc.Class (fetchMediaResource, readDataFile, runIO,
@@ -146,6 +147,9 @@ insertResource commonState mbRef src = do
fetchMediaResource src
liftIO $ print (fp, mimeType) -- TODO DEBUG
insertMediaFn mbRef fp (OrNil mimeType) bs
+ Lua.push fp
+ Lua.push $ fromMaybe "" mimeType
+ return 2 -- returns 2 values: name in mediabag, mimetype
--
-- Helper types and orphan instances