Module:Sandbox/Frietjes: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 8:
end
 
function p.cleanbox(frame)
slocal image = frame.args[1]
local caption = frame.args[2]
s = mw.ustring.gsub(s, '[Mm]etre', 'm')
local isleft = frame.args['isleft']
s = mw.ustring.gsub(s, '([^a])meter', '%1m') -- prevents "parameter" from being changed to "param"
local iscenter = frame.args['iscenter']
s = mw.ustring.gsub(s, '[Cc]enti', 'c') -- changes "centim" to "cm"
local upright = frame.args['upright'] or '1'
s = mw.ustring.gsub(s, 'ms', 'm')
if (caption or '') ~= '' then
s = mw.ustring.gsub(s, 'm[%.,]', 'm')
local targs = {}
 
if isleft then
s = mw.ustring.gsub(s, '[Ff]eet', 'ft')
targs['bodystyle'] = 'float:left;clear:left;margin:0.5em 1em 0.5em 0em'
s = mw.ustring.gsub(s, 'foot', 'ft')
elseif iscenter then
s = mw.ustring.gsub(s, 'ft[%.,]', 'ft')
targs['bodystyle'] = 'float:none;clear:both;margin:0.5em auto'
 
end
s = mw.ustring.gsub(s, '[Ii]nches', 'in')
targs['image'] = '[[File:' .. image .. '|upright=' .. upright .. '|frameless]]'
s = mw.ustring.gsub(s, '[Ii]nch', 'in')
targs['caption'] = caption
s = mw.ustring.gsub(s, 'ins', 'in')
return require('Module:Infobox').infobox(targs)
s = mw.ustring.gsub(s, 'in[%.,]', 'in')
end
 
return '[[File:' .. image .. '|thumb]]'
s = mw.ustring.gsub(s, '%[%[[Mm]%]%]s', '[[Metre|m]]')
s = mw.ustring.gsub(s, '%[%[[Cc]m%]%]s', '[[Centimetre|cm]]')
s = mw.ustring.gsub(s, '%[%[[Cc]entim|cm%]%]', '[[Centimetre|cm]]')
s = mw.ustring.gsub(s, '%[%[[Ii]n|in%]%]', '[[inch|in]]')
s = mw.ustring.gsub(s, '(%d)%s+(c?m)', '%1 %2')
s = mw.ustring.gsub(s, '(%d)%s+(ft)', '%1 %2')
s = mw.ustring.gsub(s, '(%d)%s+(in)', '%1 %2')
return s
end