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.
pandoc-lua-engine
This package provides a Lua pandoc scripting engine based. It allows to write filters, custom readers, and custom writers in Lua.