aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/Marshaling/CommonState.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-11-28 02:08:01 +0100
committerGitHub <noreply@github.com>2021-11-27 17:08:01 -0800
commit3692a1d1e83703fbf235214f2838cd92683c625c (patch)
tree2eb377285e1ca485c03ea60eef1d92ff58827666 /src/Text/Pandoc/Lua/Marshaling/CommonState.hs
parent0d25232bbf2998cccf6ca4b1dc6e8d6f36eb9c60 (diff)
downloadpandoc-3692a1d1e83703fbf235214f2838cd92683c625c.tar.gz
Lua: use package pandoc-lua-marshal (#7719)
The marshaling functions for pandoc's AST are extracted into a separate package. The package comes with a number of changes: - Pandoc's List module was rewritten in C, thereby improving error messages. - Lists of `Block` and `Inline` elements are marshaled using the new list types `Blocks` and `Inlines`, respectively. These types currently behave identical to the generic List type, but give better error messages. This also opens up the possibility of adding element-specific methods to these lists in the future. - Elements of type `MetaValue` are no longer pushed as values which have `.t` and `.tag` properties. This was already true for `MetaString` and `MetaBool` values, which are still marshaled as Lua strings and booleans, respectively. Affected values: + `MetaBlocks` values are marshaled as a `Blocks` list; + `MetaInlines` values are marshaled as a `Inlines` list; + `MetaList` values are marshaled as a generic pandoc `List`s. + `MetaMap` values are marshaled as plain tables and no longer given any metatable. - The test suite for marshaled objects and their constructors has been extended and improved. - A bug in Citation objects, where setting a citation's suffix modified it's prefix, has been fixed.
Diffstat (limited to 'src/Text/Pandoc/Lua/Marshaling/CommonState.hs')
-rw-r--r--src/Text/Pandoc/Lua/Marshaling/CommonState.hs70
1 files changed, 0 insertions, 70 deletions
diff --git a/src/Text/Pandoc/Lua/Marshaling/CommonState.hs b/src/Text/Pandoc/Lua/Marshaling/CommonState.hs
deleted file mode 100644
index 857551598..000000000
--- a/src/Text/Pandoc/Lua/Marshaling/CommonState.hs
+++ /dev/null
@@ -1,70 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-{- |
- Module : Text.Pandoc.Lua.Marshaling.CommonState
- Copyright : © 2012-2021 John MacFarlane
- © 2017-2021 Albert Krewinkel
- License : GNU GPL, version 2 or above
- Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
- Stability : alpha
-
-Instances to marshal (push) and unmarshal (peek) the common state.
--}
-module Text.Pandoc.Lua.Marshaling.CommonState
- ( typeCommonState
- , peekCommonState
- , pushCommonState
- ) where
-
-import HsLua.Core
-import HsLua.Marshalling
-import HsLua.Packaging
-import Text.Pandoc.Class (CommonState (..))
-import Text.Pandoc.Logging (LogMessage, showLogMessage)
-import Text.Pandoc.Lua.Marshaling.List (pushPandocList)
-
--- | Lua type used for the @CommonState@ object.
-typeCommonState :: LuaError e => DocumentedType e CommonState
-typeCommonState = deftype "pandoc 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 (pushUD typeLogMessage), 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)
- ]
-
-peekCommonState :: LuaError e => Peeker e CommonState
-peekCommonState = peekUD typeCommonState
-
-pushCommonState :: LuaError e => Pusher e CommonState
-pushCommonState = pushUD typeCommonState
-
-typeLogMessage :: LuaError e => DocumentedType e LogMessage
-typeLogMessage = deftype "pandoc LogMessage"
- [ operation Index $ defun "__tostring"
- ### liftPure showLogMessage
- <#> udparam typeLogMessage "msg" "object"
- =#> functionResult pushText "string" "stringified log message"
- ]
- mempty -- no members