Jump to content

Module:BSto

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jc86035 (talk | contribs) at 12:46, 23 June 2016. 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,it,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 = ' \n{|cellspacing="0" cellpadding="0" style="font-size:80%; font-weight:inherit; color:inherit; background-color:transparent; margin-top:-2px; margin-bottom:-2px; display:inline-table; vertical-align:bottom; text-align:'..align
	if italic or it == 'all' then result = result..';font-style:italic' end
	if bold then result = result..';font-weight:bold' end
	local row = '\n|-\n|style="text-align:inherit;padding:0;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 it ~= 'off' and fs1 == 'inherit' then -- Check if this is BSto instead of BSsplit
		result = result..';font-style:italic'
	elseif it == '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],nil,args[4],args[5],args.align,args.style,args.bg1,args.bg2,args.line,'105%','92%','0.9em','0.9em')
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],nil,args[5],args.align,args.style,args.bg1,args.bg2,args.line,'inherit','inherit','0.9em','0.9em')
end

return p