aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2019-02-16 13:20:33 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2019-05-29 23:18:44 +0200
commit0a6a11cfabead239eab3baec065d8d6e95bb6447 (patch)
tree576c75d18bc76e840ec7ed60b7d089dd90933ecf /src/Text
parent3097ee100ed260a5c2cea7df5bf80c989687df44 (diff)
downloadpandoc-0a6a11cfabead239eab3baec065d8d6e95bb6447.tar.gz
pandoc.mediabag module: add function `empty`
Function `pandoc.mediabag.empty` was added. It allows to clean-out the media bag, removing all entries.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Lua/Module/MediaBag.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Lua/Module/MediaBag.hs b/src/Text/Pandoc/Lua/Module/MediaBag.hs
index ce6303ec6..4678d46e8 100644
--- a/src/Text/Pandoc/Lua/Module/MediaBag.hs
+++ b/src/Text/Pandoc/Lua/Module/MediaBag.hs
@@ -34,6 +34,7 @@ import qualified Text.Pandoc.MediaBag as MB
pushModule :: Lua NumResults
pushModule = do
Lua.newtable
+ addFunction "empty" empty
addFunction "insert" insertMediaFn
addFunction "items" items
addFunction "lookup" lookupMediaFn
@@ -60,6 +61,11 @@ setCommonState st = do
modifyCommonState :: (CommonState -> CommonState) -> Lua ()
modifyCommonState f = getCommonState >>= setCommonState . f
+-- | Delete all items from the media bag.
+empty :: Lua NumResults
+empty = 0 <$ modifyCommonState (\st -> st { stMediaBag = mempty })
+
+-- | Insert a new item into the media bag.
insertMediaFn :: FilePath
-> Optional MimeType
-> BL.ByteString