1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
{-# 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
|