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/Marshal | |
| 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/Marshal')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs index b0d2b0990..3f705616d 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs @@ -16,41 +16,15 @@ module Text.Pandoc.Lua.Marshal.CommonState ) where import HsLua -import Text.Pandoc.Class (CommonState (..)) -import Text.Pandoc.Lua.Marshal.List (pushPandocList) -import Text.Pandoc.Lua.Marshal.LogMessage (pushLogMessage) +import Text.Pandoc.Class (CommonState) -- | Lua type used for the @CommonState@ object. +-- +-- This is an opaque value that is required for the Lua interpreter +-- to become an instance of "PandocMonad". +-- typeCommonState :: LuaError e => DocumentedType e CommonState -typeCommonState = deftype "CommonState" [] - [ readonly "input_files" "input files passed to pandoc" - (pushPandocList pushString, stInputFiles) - - , readonly "output_file" "the file to which pandoc will write" - (maybe pushnil pushString, stOutputFile) - - , readonly "log" "list of log messages" - (pushPandocList pushLogMessage, stLog) - - , readonly "request_headers" "headers to add for HTTP requests" - (pushPandocList (pushPair pushText pushText), stRequestHeaders) - - , readonly "resource_path" - "path to search for resources like included images" - (pushPandocList pushString, stResourcePath) - - , readonly "source_url" "absolute URL + dir of 1st source file" - (maybe pushnil pushText, stSourceURL) - - , readonly "user_data_dir" "directory to search for data files" - (maybe pushnil pushString, stUserDataDir) - - , readonly "trace" "controls whether tracing messages are issued" - (pushBool, stTrace) - - , readonly "verbosity" "verbosity level" - (pushString . show, stVerbosity) - ] +typeCommonState = deftype "CommonState" [] [] peekCommonState :: LuaError e => Peeker e CommonState peekCommonState = peekUD typeCommonState |
