aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2019-06-12 18:58:38 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2019-06-12 09:58:38 -0700
commit11bb8627677fb8b49af92d7c55aec07c69f95843 (patch)
tree3bd8a3ea839a94747b2cc41e78ef7f062c7489f9 /src/Text
parentd81b9f55c142f89db38edd44db999ef2de162a8d (diff)
downloadpandoc-11bb8627677fb8b49af92d7c55aec07c69f95843.tar.gz
Lua: add a `clone()` method to all AST elements (#5572)
Closes: #5568
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Lua/Marshaling/AST.hs5
-rw-r--r--src/Text/Pandoc/Lua/Module/Types.hs46
2 files changed, 50 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Lua/Marshaling/AST.hs b/src/Text/Pandoc/Lua/Marshaling/AST.hs
index f18754ac2..7b428b5f0 100644
--- a/src/Text/Pandoc/Lua/Marshaling/AST.hs
+++ b/src/Text/Pandoc/Lua/Marshaling/AST.hs
@@ -14,7 +14,10 @@
Marshaling/unmarshaling instances for document AST elements.
-}
-module Text.Pandoc.Lua.Marshaling.AST () where
+module Text.Pandoc.Lua.Marshaling.AST
+ ( LuaAttr (..)
+ , LuaListAttributes (..)
+ ) where
import Prelude
import Control.Applicative ((<|>))
diff --git a/src/Text/Pandoc/Lua/Module/Types.hs b/src/Text/Pandoc/Lua/Module/Types.hs
index 641bde7d6..fdc63cd99 100644
--- a/src/Text/Pandoc/Lua/Module/Types.hs
+++ b/src/Text/Pandoc/Lua/Module/Types.hs
@@ -15,8 +15,11 @@ module Text.Pandoc.Lua.Module.Types
import Prelude
import Data.Version (Version)
import Foreign.Lua (Lua, NumResults)
+import Text.Pandoc.Definition
+import Text.Pandoc.Lua.Marshaling.AST (LuaAttr, LuaListAttributes)
import Text.Pandoc.Lua.Marshaling.Version ()
import Text.Pandoc.Lua.Util (addFunction)
+import Text.Pandoc.Shared (Element (..))
import qualified Foreign.Lua as Lua
@@ -25,4 +28,47 @@ pushModule :: Lua NumResults
pushModule = do
Lua.newtable
addFunction "Version" (return :: Version -> Lua Version)
+ pushCloneTable
+ Lua.setfield (Lua.nthFromTop 2) "clone"
return 1
+
+pushCloneTable :: Lua NumResults
+pushCloneTable = do
+ Lua.newtable
+ addFunction "Attr" cloneAttr
+ addFunction "Block" cloneBlock
+ addFunction "Citation" cloneCitation
+ addFunction "Element" cloneElement
+ addFunction "Inline" cloneInline
+ addFunction "Meta" cloneMeta
+ addFunction "MetaValue" cloneMetaValue
+ addFunction "ListAttributes" cloneListAttributes
+ addFunction "Pandoc" clonePandoc
+ return 1
+
+cloneAttr :: LuaAttr -> Lua LuaAttr
+cloneAttr = return
+
+cloneBlock :: Block -> Lua Block
+cloneBlock = return
+
+cloneCitation :: Citation -> Lua Citation
+cloneCitation = return
+
+cloneElement :: Element -> Lua Element
+cloneElement = return
+
+cloneInline :: Inline -> Lua Inline
+cloneInline = return
+
+cloneListAttributes :: LuaListAttributes -> Lua LuaListAttributes
+cloneListAttributes = return
+
+cloneMeta :: Meta -> Lua Meta
+cloneMeta = return
+
+cloneMetaValue :: MetaValue -> Lua MetaValue
+cloneMetaValue = return
+
+clonePandoc :: Pandoc -> Lua Pandoc
+clonePandoc = return