Module:Tabs: Difference between revisions

346 bytes added ,  Sunday at 20:50
no edit summary
m (Rman41 moved page Module:Sandbox to Module:Tabs without leaving a redirect)
No edit summary
Line 2: Line 2:


local p = {}
local p = {}
function trim(s) -- Allows removing of whitespace from inputs; adapted from (https://www.lua.org/manual/2.4/node32.html)
local l = 1
while string.sub(s,l,l) == ' ' do
l = l+1
end
while string.sub(s,l,l+1) == '\n' do
l = l+2
end
local r = string.len(s)
while string.sub(s,r,r) == ' ' do
r = r-1
end
return string.sub(s,l,r)
end


function p.Main(frame)
function p.Main(frame)
Line 14: Line 29:
local i = 0
local i = 0
if args['active'] ~= nil then
if args['active'] ~= nil then
active = tonumber(args['active'])
active = tonumber(trim(args['active']))
else
else
active = 1
active = 1