diff options
| author | Albert Krewinkel <[email protected]> | 2023-03-12 18:06:07 +0100 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2023-03-12 18:23:40 +0100 |
| commit | be6ec92608b99833d22384e2cd1997491c2743f6 (patch) | |
| tree | 1b6606dc5c7bf47cb1e21a575fd4498d5155bfc9 /pandoc-lua-engine/src | |
| parent | 7a8be778691e7c3d144b1ee077a646d88a01dc5c (diff) | |
Lua: allow to get the JSON encoding of log messages
Diffstat (limited to 'pandoc-lua-engine/src')
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs | 5 |
1 files changed, 5 insertions, 0 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 28cb5925b..376f2dd74 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/CommonState.hs @@ -19,6 +19,7 @@ import HsLua import Text.Pandoc.Class (CommonState (..)) import Text.Pandoc.Logging (LogMessage, showLogMessage) import Text.Pandoc.Lua.Marshal.List (pushPandocList) +import qualified Data.Aeson as Aeson -- | Lua type used for the @CommonState@ object. typeCommonState :: LuaError e => DocumentedType e CommonState @@ -64,5 +65,9 @@ typeLogMessage = deftype "pandoc LogMessage" ### liftPure showLogMessage <#> udparam typeLogMessage "msg" "object" =#> functionResult pushText "string" "stringified log message" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure Aeson.encode + <#> udparam typeLogMessage "msg" "object" + =#> functionResult pushLazyByteString "string" "JSON encoded object" ] mempty -- no members |
