본문으로 이동

모듈:글머리 3열

위키백과, 우리 모두의 백과사전.

local p = {}

function p.main( frame )
	local args = require('Module:Arguments').getArgs(frame, {wrappers = '틀:글머리 3열', removeBlanks = false})

	local t1 = '';
	local t2 = '';
	local t3 = '';

	local number = args.number or '';

	local line = '';
	local temp = '';

	local j = args.start or '';
	if j == '' or nil then
		j = 1;
	end;
	for i = 1, 150, 3 do

		t1 = args[i] or '';
		t2 = args[i + 1] or '';
		t3 = args[i + 2] or '';

		temp = t1 ..t2 ..t3;
		if temp == '' or nil then
			break
		end

		temp = '<tr>';
		if number ~= '' or nil then
			temp = temp ..'<td style="text-align: right;"><span style="margin-left: 10px;">' .. j ..'.</span></td>';
		else
			temp = temp ..'<td><span style="margin-left: 15px; color: #00528c; font-weight: bold;">・</span></td>';
		end

		if t2 ~= '' or nil then
			temp = temp ..'<td style="white-space: nowrap; padding-left: 2px; border-bottom: 1px solid #aaa;">' ..t1 ..'<td>&nbsp;-&nbsp;</td><td style=" border-bottom: 1px solid #aaa;">' ..t2 ..'</td>';
		else
			temp = temp ..'<td style="white-space: nowrap; padding-left: 2px; border-bottom: 1px solid #aaa;">' ..t1 ..'<td></td><td></td>';
		end

		if t3 ~= '' or nil then
			temp = temp ..'<td>&nbsp;-&nbsp;</td><td style=" border-bottom: 1px solid #aaa;">' ..t3 ..'</td>';
		else
			temp = temp ..'<td></td><td></td>';
		end

		line = line ..temp ..'</tr>';
		temp = '';

		j = j + 1;
	end

	return '<table>' ..line ..'</table>';
end

return p