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
{ simpleTableCaption :: [Inline]
, simpleTableAlignments :: [Alignment]
, simpleTableColumnWidths :: [Double]
, simpleTableHeader :: [[Block]]
, simpleTableBody :: [[[Block]]]
}
instance Pushable SimpleTable where
push = pushSimpleTable
instance Peekable SimpleTable where
peek = peekSimpleTable
pushSimpleTable :: SimpleTable -> Lua ()
pushSimpleTable tbl = pushViaConstructor "SimpleTable"
(simpleTableCaption tbl)
(simpleTableAlignments tbl)
(simpleTableColumnWidths tbl)
(simpleTableHeader tbl)
(simpleTableBody tbl)
peekSimpleTable :: StackIndex -> Lua SimpleTable
peekSimpleTable idx = defineHowTo "get SimpleTable" $
SimpleTable
<$> rawField idx "caption"
<*> rawField idx "aligns"
<*> rawField idx "widths"
<*> rawField idx "headers"
<*> rawField idx "rows"