aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-12-19 23:04:31 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2021-12-19 23:17:27 +0100
commit993222d2c9c94cbf51f06528b79ffddd56b9da46 (patch)
tree4025a5a8840fe706da3fa7e5b8eab8d8c7eb0cc0 /src
parent0610f16f7f684b320325b6c0b501725138d10a52 (diff)
downloadpandoc-993222d2c9c94cbf51f06528b79ffddd56b9da46.tar.gz
Custom writer: assign default Pandoc object to global PANDOC_DOCUMENT
The default Pandoc object is now non-strict, i.e., only the parts of the document that are accessed will be marshaled to Lua. A special type is no longer necessary. This change also makes it possible to use the global variable with library functions such as `pandoc.utils.references`, or to inspect the document contents with `walk()`.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Lua/Global.hs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Lua/Global.hs b/src/Text/Pandoc/Lua/Global.hs
index c7b50a25f..cf82890c6 100644
--- a/src/Text/Pandoc/Lua/Global.hs
+++ b/src/Text/Pandoc/Lua/Global.hs
@@ -18,9 +18,10 @@ import HsLua as Lua
import HsLua.Module.Version (pushVersion)
import Paths_pandoc (version)
import Text.Pandoc.Class.CommonState (CommonState)
-import Text.Pandoc.Definition (Pandoc (Pandoc), pandocTypesVersion)
+import Text.Pandoc.Definition (Pandoc, pandocTypesVersion)
import Text.Pandoc.Error (PandocError)
import Text.Pandoc.Lua.Marshal.CommonState (pushCommonState)
+import Text.Pandoc.Lua.Marshal.Pandoc (pushPandoc)
import Text.Pandoc.Lua.Marshal.ReaderOptions (pushReaderOptionsReadonly)
import Text.Pandoc.Lua.Orphans ()
import Text.Pandoc.Options (ReaderOptions)
@@ -52,7 +53,7 @@ setGlobal global = case global of
pushVersion pandocTypesVersion
Lua.setglobal "PANDOC_API_VERSION"
PANDOC_DOCUMENT doc -> do
- pushUD typePandocLazy doc
+ pushPandoc doc
Lua.setglobal "PANDOC_DOCUMENT"
PANDOC_READER_OPTIONS ropts -> do
pushReaderOptionsReadonly ropts
@@ -66,10 +67,3 @@ setGlobal global = case global of
PANDOC_VERSION -> do
pushVersion version
Lua.setglobal "PANDOC_VERSION"
-
--- | Readonly and lazy pandoc objects.
-typePandocLazy :: LuaError e => DocumentedType e Pandoc
-typePandocLazy = deftype "Pandoc (lazy)" []
- [ readonly "meta" "document metadata" (push, \(Pandoc meta _) -> meta)
- , readonly "blocks" "content blocks" (push, \(Pandoc _ blocks) -> blocks)
- ]