Module:Sandbox
Appearance
local p={}
function p.test(f) local a,c=f.args[1],function(t) return '<code style=color:red;font-weight:bold;background:lime;border-color:blue;border-radius:.4em>the '..t..'</code>' end
if not a then return c'parameter is unspecified' elseif a=='' then return c'parameter is empty' else return c('specified parameter is “'..a..'”') end
end
function p.tl(f)
local a,nw,b,bb,color,u,eb,tag,tn,l=f.args,function(t) return f:extensionTag('nowiki', t) end,'','','',function(t) return t end,function(t) return t end,'code'
if a.tag and a.tag~='' then tag=a.tag end
if a.template=='' or not a.template then tn=a[1] else tn=a.template end
if f:callParserFunction('ucfirst',tn:gsub('[_ ]+',' '))==mw.title.new(tn).text then l='Template:'..tn else l=tn end
if a.shl=='1' then color,b,bb,u,eb=' style=color:#80c','<b>','</b>',function(t) return '<u'..color..'>'..nw(t)..'</u>' end,
function(t) if t~='' then local m,s,gsub,sub='([^{}]-)','%1'
function gsub(t) return t:gsub(m..'(&#[Xx]3[Dd];).*',s):gsub(m..'(=).*',s):gsub(m..'(=).*',s):gsub(m..'({{=}}).*',s):gsub(m..'(=).*',s) end
if t==gsub(t) then t=bb..nw(t)..b else s='%1%2'
function sub(t) return mw.ustring.sub(t,1+mw.ustring.len(gsub(t))) end
if sub(t)=='' then t=nw(t) else t=nw(gsub(t))..bb..nw(sub(t))..b end
end
end return t end
end
local r='<'..tag..color..'>'..b..'{{[['..l..'|'..u(tn)..']]'
for nu,v in ipairs(a) do
if a.template or nu>1 then r=r..'|'..eb(v) end
end
r=r..'}}'..bb..'</'..tag..'>'
return r
end
p['']=function(f)
local tablef,fargs={},'{| class=wikitable\n!Name\n!Type/Value\n'
for na,v in pairs(f) do
table.insert(tablef,'\n|-\n|'..na..'\n|'..tostring(v))
end
for na,v in pairs(f.args) do
fargs=fargs..'|-\n|'..na..'\n|'..tostring(v)..'\n'
end
fargs=fargs..'|}'
return '{| class=wikitable\n!Name\n!Type/Value'..table.concat(tablef)..'\n|}\n'..fargs
end
return p