module Text.Pandoc.Lua.Marshaling.SimpleTable
( SimpleTable (..)
, peekSimpleTable
, pushSimpleTable
)
where
import Foreign.Lua (Lua, Peekable, Pushable, StackIndex)
import Text.Pandoc.Definition
import Text.Pandoc.Lua.Util (defineHowTo, pushViaConstructor, rawField)
import Text.Pandoc.Lua.Marshaling.AST ()
import qualified Foreign.Lua as Lua
data SimpleTable = SimpleTable
{ SimpleTable -> [Inline]
simpleTableCaption :: [Inline]
, SimpleTable -> [Alignment]
simpleTableAlignments :: [Alignment]
, SimpleTable -> [Double]
simpleTableColumnWidths :: [Double]
, :: [[Block]]
, SimpleTable -> [[[Block]]]
simpleTableBody :: [[[Block]]]
}
instance Pushable SimpleTable where
push :: SimpleTable -> Lua ()
push = SimpleTable -> Lua ()
pushSimpleTable
instance Peekable SimpleTable where
peek :: StackIndex -> Lua SimpleTable
peek = StackIndex -> Lua SimpleTable
peekSimpleTable
pushSimpleTable :: SimpleTable -> Lua ()
pushSimpleTable :: SimpleTable -> Lua ()
pushSimpleTable SimpleTable
tbl = String
-> [Inline]
-> [Alignment]
-> [Double]
-> [[Block]]
-> [[[Block]]]
-> Lua ()
forall a. PushViaCall a => String -> a
pushViaConstructor String
"SimpleTable"
(SimpleTable -> [Inline]
simpleTableCaption SimpleTable
tbl)
(SimpleTable -> [Alignment]
simpleTableAlignments SimpleTable
tbl)
(SimpleTable -> [Double]
simpleTableColumnWidths SimpleTable
tbl)
(SimpleTable -> [[Block]]
simpleTableHeader SimpleTable
tbl)
(SimpleTable -> [[[Block]]]
simpleTableBody SimpleTable
tbl)
peekSimpleTable :: StackIndex -> Lua SimpleTable
peekSimpleTable :: StackIndex -> Lua SimpleTable
peekSimpleTable StackIndex
idx = String -> Lua SimpleTable -> Lua SimpleTable
forall a. String -> Lua a -> Lua a
defineHowTo String
"get SimpleTable" (Lua SimpleTable -> Lua SimpleTable)
-> Lua SimpleTable -> Lua SimpleTable
forall a b. (a -> b) -> a -> b
$
[Inline]
-> [Alignment]
-> [Double]
-> [[Block]]
-> [[[Block]]]
-> SimpleTable
SimpleTable
([Inline]
-> [Alignment]
-> [Double]
-> [[Block]]
-> [[[Block]]]
-> SimpleTable)
-> Lua [Inline]
-> Lua
([Alignment]
-> [Double] -> [[Block]] -> [[[Block]]] -> SimpleTable)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StackIndex -> String -> Lua [Inline]
forall a. Peekable a => StackIndex -> String -> Lua a
rawField StackIndex
idx String
"caption"
Lua
([Alignment]
-> [Double] -> [[Block]] -> [[[Block]]] -> SimpleTable)
-> Lua [Alignment]
-> Lua ([Double] -> [[Block]] -> [[[Block]]] -> SimpleTable)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StackIndex -> String -> Lua [Alignment]
forall a. Peekable a => StackIndex -> String -> Lua a
rawField StackIndex
idx String
"aligns"
Lua ([Double] -> [[Block]] -> [[[Block]]] -> SimpleTable)
-> Lua [Double] -> Lua ([[Block]] -> [[[Block]]] -> SimpleTable)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StackIndex -> String -> Lua [Double]
forall a. Peekable a => StackIndex -> String -> Lua a
rawField StackIndex
idx String
"widths"
Lua ([[Block]] -> [[[Block]]] -> SimpleTable)
-> Lua [[Block]] -> Lua ([[[Block]]] -> SimpleTable)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StackIndex -> String -> Lua [[Block]]
forall a. Peekable a => StackIndex -> String -> Lua a
rawField StackIndex
idx String
"headers"
Lua ([[[Block]]] -> SimpleTable)
-> Lua [[[Block]]] -> Lua SimpleTable
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> StackIndex -> String -> Lua [[[Block]]]
forall a. Peekable a => StackIndex -> String -> Lua a
rawField StackIndex
idx String
"rows"