Jump to content

Module:BSto

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sameboat (talk | contribs) at 13:02, 8 September 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

local function base(t1,t2,link,italic,bold,align,style,line,bg1,bg2,fs1,fs2,lh1,lh2)
	if not align then align = 'inherit' end
	if not style then style = '' end
	local result = '{|cellspacing="0" cellpadding="0" style="font-size:80%; font-weight:inherit; color:inherit; background-color:transparent; margin-top:-1px; margin-bottom:-1px; display:inline-table; vertical-align:bottom; text-align:'..align
	if italic then result = result..';font-style:italic' end
	if bold then result = result..';font-weight:bold' end
	local row = '\n|-\n|style="line-height:'
	result = result..';'..style..'"'..row..lh1
	if line then result = result..';border-bottom:1px solid gray' end
	if bg1 then result = result..';padding-left:0.5em;padding-right:0.5em;background-color:'..bg1 end
	if fs1 then result = result..';font-size:'..fs1 end
	result = result..'"|'
	if link then
		result = result..'[['..link..'|'..t1..']]'
	else
		result = result..t1
	end
	result = result..row..lh2
	if bg2 then result = result..';padding-left:0.5em;padding-right:0.5em;background-color:'..bg2 end
	if fs2 then result = result..';font-size:'..fs2 end
	if not italic and lh2 == '0.95em' then -- Check if this is BSto instead of BSsplit
		result = result..';font-style:italic'
	elseif italic == 'off' then
		result = result..';font-style:normal'
	end
	result = result..'"|'
	if link then
		result = result..'[['..link..'|'..t2..']]'
	else
		result = result..t2
	end
	return result..'\n|}'
end

local getArgs = require('Module:Arguments').getArgs

local function makeInvokeFunction(funcName)
	-- makes a function that can be returned from #invoke, using
	-- [[Module:Arguments]].
	return function (frame)
		local args = getArgs(frame, {parentOnly = true})
		return p[funcName](args)
	end
end

p.BSto = makeInvokeFunction('_BSto')
 
function p._BSto(args)
	args[3] = args[3] or args.L
	args[4] = args[4] or args.it
	return base(args[1],args[2],args[3],args[4],args[5],args.align,args.style,args.bg1,args.bg2,args.line,'110%','92%','0.95em','0.95em')
end

p.BSsplit = makeInvokeFunction('_BSsplit')
 
function p._BSsplit(args)
	args[3] = args[3] or args.L
	args[4] = args[4] or args.it
	return base(args[1],args[2],args[3],args[4],args[5],args.align,args.style,args.bg1,args.bg2,args.line,'inherit','inherit','0.92em','0.92em')
end

return p