You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.3 KiB
78 lines
1.3 KiB
DECK = Deck.new();
|
|
|
|
function config(x)
|
|
for k,v in pairs(x) do
|
|
DECK:addConfig(k, v);
|
|
end
|
|
end
|
|
|
|
function slide(x)
|
|
local s = Slide.new()
|
|
|
|
for k, v in pairs(x) do
|
|
if type(k) == "string" then
|
|
s:addConfig(k, v)
|
|
else
|
|
s:addNode(v)
|
|
end
|
|
end
|
|
|
|
DECK:addSlide(s)
|
|
end
|
|
|
|
function makeNode(ntype, ncontent)
|
|
local n = Node.new(ntype)
|
|
|
|
-- handle plain strings
|
|
if type(ncontent) == "string" then
|
|
n:addText(ncontent)
|
|
return n
|
|
end
|
|
|
|
-- handle more advanced config ones
|
|
for k,v in pairs(ncontent) do
|
|
if type(k) == "string" then
|
|
n:addConfig(k, v)
|
|
else
|
|
n:addText(v)
|
|
end
|
|
end
|
|
|
|
return n
|
|
end
|
|
|
|
function t(content)
|
|
return makeNode(NodeType.TEXT, content)
|
|
end
|
|
|
|
function h1(text)
|
|
return makeNode(NodeType.H1, content)
|
|
end
|
|
|
|
function image(settings)
|
|
return makeNode(NodeType.IMAGE, content)
|
|
end
|
|
|
|
function ul(text)
|
|
return makeNode(NodeType.UL, content)
|
|
end
|
|
|
|
function pprint(o)
|
|
if type(o) == 'table' then
|
|
local s = '{'
|
|
for k,v in pairs(o) do
|
|
if type(k) == 'number' then
|
|
s = s .. pprint(v) .. ','
|
|
elseif type(k) == 'string' then
|
|
s = s .. '"' .. k .. '"=' .. pprint(v) .. ','
|
|
else
|
|
s = s .. '[' .. k .. ']=' .. pprint(v) .. ','
|
|
end
|
|
end
|
|
return s .. '}\n'
|
|
elseif type(o) == 'string' then
|
|
return '"' .. o .. '"'
|
|
else
|
|
return tostring(o)
|
|
end
|
|
end
|
|
|