diff options
| author | Albert Krewinkel <[email protected]> | 2024-06-08 14:39:58 +0200 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2024-06-08 14:39:58 +0200 |
| commit | 6a88abae3d8ceb4463da423e934cc03e6e5ce5fa (patch) | |
| tree | 4f73254b6a870f1a42de7191110f7c10380a54ca /pandoc-lua-engine/src | |
| parent | d50bd30324ef9e8053d750ff0139e7d9bff1d912 (diff) | |
Lua: keep CommonState object in the registry
The state is an internal value and should be treated as such. The
`PANDOC_STATE` global is merely a copy; unsetting the global no longer
breaks the Lua engine.
Diffstat (limited to 'pandoc-lua-engine/src')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs index 5062672e9..9c4bebdd2 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs @@ -77,10 +77,12 @@ instance PandocMonad PandocLua where getModificationTime = IO.getModificationTime getCommonState = PandocLua $ do - Lua.getglobal "PANDOC_STATE" + Lua.getfield registryindex "PANDOC_STATE" forcePeek $ peekCommonState Lua.top `lastly` pop 1 putCommonState cst = PandocLua $ do pushCommonState cst + Lua.pushvalue Lua.top + Lua.setfield registryindex "PANDOC_STATE" Lua.setglobal "PANDOC_STATE" logOutput = IO.logOutput |
