diff options
Diffstat (limited to 'src/Text/Pandoc/Lua/Module')
-rw-r--r-- | src/Text/Pandoc/Lua/Module/MediaBag.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Lua/Module/MediaBag.hs b/src/Text/Pandoc/Lua/Module/MediaBag.hs index 52aeaa1af..ce6303ec6 100644 --- a/src/Text/Pandoc/Lua/Module/MediaBag.hs +++ b/src/Text/Pandoc/Lua/Module/MediaBag.hs @@ -20,6 +20,7 @@ import Foreign.Lua (Lua, NumResults, Optional, liftIO) import Text.Pandoc.Class (CommonState (..), fetchItem, putCommonState, runIOorExplode, setMediaBag) import Text.Pandoc.Lua.Marshaling () +import Text.Pandoc.Lua.Marshaling.MediaBag (pushIterator) import Text.Pandoc.Lua.Util (addFunction) import Text.Pandoc.MIME (MimeType) @@ -34,6 +35,7 @@ pushModule :: Lua NumResults pushModule = do Lua.newtable addFunction "insert" insertMediaFn + addFunction "items" items addFunction "lookup" lookupMediaFn addFunction "list" mediaDirectoryFn addFunction "fetch" fetch @@ -66,9 +68,13 @@ insertMediaFn fp optionalMime contents = do modifyCommonState $ \st -> let mb = MB.insertMedia fp (Lua.fromOptional optionalMime) contents (stMediaBag st) - in st { stMediaBag = mb} + in st { stMediaBag = mb } return 0 +-- | Returns iterator values to be used with a Lua @for@ loop. +items :: Lua NumResults +items = stMediaBag <$> getCommonState >>= pushIterator + lookupMediaFn :: FilePath -> Lua NumResults lookupMediaFn fp = do |