aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-10-08 09:22:46 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-10-09 11:01:33 -0700
commitaceee9ca48484c300ac3519fb7991e3d22768312 (patch)
tree5beaccc4860fd5a9525514d2fe9e737e42703f73 /src/Text/Pandoc/Lua
parent1b10b5cea947cd6567c33466006c4216fde9f107 (diff)
downloadpandoc-aceee9ca48484c300ac3519fb7991e3d22768312.tar.gz
Options.WriterOptions: Change type of writerVariables to Context Text.
This will allow structured values. [API change]
Diffstat (limited to 'src/Text/Pandoc/Lua')
-rw-r--r--src/Text/Pandoc/Lua/Marshaling.hs1
-rw-r--r--src/Text/Pandoc/Lua/Marshaling/Context.hs31
2 files changed, 32 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Lua/Marshaling.hs b/src/Text/Pandoc/Lua/Marshaling.hs
index 8a1270ab7..c37f22b8d 100644
--- a/src/Text/Pandoc/Lua/Marshaling.hs
+++ b/src/Text/Pandoc/Lua/Marshaling.hs
@@ -14,4 +14,5 @@ module Text.Pandoc.Lua.Marshaling () where
import Text.Pandoc.Lua.Marshaling.AST ()
import Text.Pandoc.Lua.Marshaling.CommonState ()
import Text.Pandoc.Lua.Marshaling.ReaderOptions ()
+import Text.Pandoc.Lua.Marshaling.Context ()
import Text.Pandoc.Lua.Marshaling.Version ()
diff --git a/src/Text/Pandoc/Lua/Marshaling/Context.hs b/src/Text/Pandoc/Lua/Marshaling/Context.hs
new file mode 100644
index 000000000..a9cc7f38e
--- /dev/null
+++ b/src/Text/Pandoc/Lua/Marshaling/Context.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE LambdaCase #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+{- |
+ Module : Text.Pandoc.Lua.Marshaling.Context
+ Copyright : © 2012-2019 John MacFarlane
+ © 2017-2019 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+ Stability : alpha
+
+Marshaling instance for doctemplates Context and its components.
+-}
+module Text.Pandoc.Lua.Marshaling.Context () where
+
+import qualified Foreign.Lua as Lua
+import Foreign.Lua (Pushable)
+import Text.DocTemplates (Context(..), Val(..))
+
+instance Pushable a => Pushable (Context a) where
+ push (Context m) = Lua.push m
+
+instance Pushable a => Pushable (Val a) where
+ push NullVal = Lua.push ()
+ push (MapVal ctx) = Lua.push ctx
+ push (ListVal xs) = Lua.push xs
+ push (SimpleVal x) = Lua.push x
+