diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2017-12-01 17:58:12 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2017-12-01 17:58:12 +0100 |
commit | 6640506ddc0ab848824d818a363c2e685b8b31a5 (patch) | |
tree | 75c7cc09e5f2d7a835dcdb10c0f48e1ae66b8fee /src/Text/Pandoc/Lua | |
parent | 5026dfaedf4a8043fd1d76c1b7da8880770f9255 (diff) | |
download | pandoc-6640506ddc0ab848824d818a363c2e685b8b31a5.tar.gz |
Lua/StackInstances: push Pandoc and Meta via constructor
Pandoc and Meta elements are now pushed by calling the respective
constructor functions of the pandoc Lua module. This makes serialization
consistent with the way blocks and inlines are pushed to lua and allows
to use List methods with the `blocks` value.
Diffstat (limited to 'src/Text/Pandoc/Lua')
-rw-r--r-- | src/Text/Pandoc/Lua/StackInstances.hs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Lua/StackInstances.hs b/src/Text/Pandoc/Lua/StackInstances.hs index 3eb14eba3..ce6dbdb98 100644 --- a/src/Text/Pandoc/Lua/StackInstances.hs +++ b/src/Text/Pandoc/Lua/StackInstances.hs @@ -36,17 +36,14 @@ import Control.Applicative ((<|>)) import Foreign.Lua (FromLuaStack (peek), Lua, LuaInteger, LuaNumber, StackIndex, ToLuaStack (push), Type (..), throwLuaError, tryLua) import Text.Pandoc.Definition -import Text.Pandoc.Lua.Util (addValue, adjustIndexBy, getTable, - pushViaConstructor) +import Text.Pandoc.Lua.Util (adjustIndexBy, getTable, pushViaConstructor) import Text.Pandoc.Shared (safeRead) import qualified Foreign.Lua as Lua instance ToLuaStack Pandoc where - push (Pandoc meta blocks) = do - Lua.newtable - addValue "blocks" blocks - addValue "meta" meta + push (Pandoc meta blocks) = + pushViaConstructor "Pandoc" blocks meta instance FromLuaStack Pandoc where peek idx = do @@ -55,7 +52,8 @@ instance FromLuaStack Pandoc where return $ Pandoc meta blocks instance ToLuaStack Meta where - push (Meta mmap) = push mmap + push (Meta mmap) = + pushViaConstructor "Meta" mmap instance FromLuaStack Meta where peek idx = Meta <$> peek idx |