diff options
-rw-r--r-- | doc/lua-filters.md | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Lua/PandocModule.hs | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/doc/lua-filters.md b/doc/lua-filters.md index d17c44adf..e1007f452 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -1133,7 +1133,9 @@ storage. The "media bag" is used when pandoc is called with the [`fetch (source, base_url)`]{#mediabag-fetch} : Fetches the given source and inserts it into the media bag - using a SHA1 hash of the content as filename. + using a SHA1 hash of the content as filename. Returns two + values: the filename (based on SHA1 hash) and the mime + type (or an empty string). Usage: 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 |