diff options
| author | Albert Krewinkel <[email protected]> | 2025-07-31 11:49:20 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-08-01 10:04:14 -0700 |
| commit | 75aee7a23c96ff31aa9fcb7608891c33a011d6a1 (patch) | |
| tree | 155da93d4f6b5e262498aba353e6e92447fb2dc9 /pandoc-lua-engine/src/Text/Pandoc/Lua/Module/MediaBag.hs | |
| parent | 57e7d895db367eb09cb4cb31678ac3b5f6dc9ef7 (diff) | |
Lua: use proper interface functions to access the CommonState.
- The `PANDOC_STATE` is no longer a userdata object, but a table that
behaves like the old object.
- Log messages in `PANDOC_STATE.log` are now in temporal order.
Diffstat (limited to 'pandoc-lua-engine/src/Text/Pandoc/Lua/Module/MediaBag.hs')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/Module/MediaBag.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/MediaBag.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/MediaBag.hs index da666779a..0e21c6340 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/MediaBag.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/MediaBag.hs @@ -18,8 +18,7 @@ import Data.Version (makeVersion) import HsLua ( LuaE, DocumentedFunction, Module (..) , (<#>), (###), (=#>), (=?>), (#?), defun, functionResult , opt, parameter, since, stringParam, textParam) -import Text.Pandoc.Class ( CommonState (..), fetchItem, fillMediaBag - , getMediaBag, modifyCommonState, setMediaBag) +import Text.Pandoc.Class ( fetchItem, fillMediaBag, getMediaBag, setMediaBag ) import Text.Pandoc.Class.IO (writeMedia) import Text.Pandoc.Error (PandocError) import Text.Pandoc.Lua.Marshal.Pandoc (peekPandoc, pushPandoc) @@ -71,8 +70,9 @@ documentedModule = Module -- | Delete a single item from the media bag. delete :: DocumentedFunction PandocError delete = defun "delete" - ### (\fp -> unPandocLua $ modifyCommonState - (\st -> st { stMediaBag = MB.deleteMedia fp (stMediaBag st) })) + ### (\fp -> unPandocLua $ do + mb <- getMediaBag + setMediaBag $ MB.deleteMedia fp mb) <#> stringParam "filepath" ("Filename of the item to deleted. The media bag will be " <> "left unchanged if no entry with the given filename exists.") @@ -82,7 +82,7 @@ delete = defun "delete" -- | Delete all items from the media bag. empty :: DocumentedFunction PandocError empty = defun "empty" - ### unPandocLua (modifyCommonState (\st -> st { stMediaBag = mempty })) + ### unPandocLua (setMediaBag mempty) =#> [] #? "Clear-out the media bag, deleting all items." |
