モジュール:Infobox/former

local p = {}
function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {parentOnly = true})	--引数取得
	local child = (args.child == 'yes')
	local subbox = (args.subbox == 'yes')
	local h = {subheader = {}, image = }	--ヘッダー部（subheader, image）テーブル
	local body, sbody = {}, {}	--本体部テーブル, ソート済み本体部テーブル
	local link = args.tnavbar or args.name	--（フッター部）テンプレート名
	local result = 	--結果格納用
	
	--
	subheader, image用引数振り分け
	
	local function args2tbl(str, k, v)
		local num = string.match(k, '%d*$')
		num = (num == ) and 1 or tonumber(num)
		hstrnum = hstrnum or {}
		if k == str then
			hstr11 = v
		elseif string.match(k, str .. '%d+') then
			hstrnum1 = v
		elseif string.find(k, 'style') then
			if string.match(k, 'style$') then
				hstr'style' = v
			else
				hstrnum'style' = v
			end
		elseif string.find(k, 'rowclass') then
			if string.match(k, 'rowclass$') then
				hstr'rowclass' = v
			else
				hstrnum'rowclass' = v
			end
		elseif string.match(k, 'class$') then
			hstr'class' = v
		end
	end
	
	--
	引数振り分け
	
	for k, v in pairs(args) do
		--subheader
		if string.find(k, 'subheader') then
			args2tbl('subheader', k, v)
		--image
		elseif string.find(k, 'image') then
			args2tbl('image', k, v)
		elseif string.find(k, 'caption') then
			if string.match(k, 'caption$') then
				h'image'1'caption' =  .. v .. 
			elseif string.match(k, 'caption%d+') then
				local num = tonumber(string.match(k, '%d*$'))
				h'image'num = h'image'num or {}
				h'image'num'caption' =  .. v .. 
			end
		--その他（本体部）
		elseif string.match(k, '^%D+%d+$') then
			local str, num = string.match(k, '^(%D+)(%d+)$')
			num = tonumber(num)
			if not bodynum then
				local OddOrEven = (num % 2 ~= 0) and 'odd' or 'even'
				bodynum = {
					num,
					headerstyle = (args.headerstyle or ) .. (argsOddOrEven .. 'headerstyle' or ),
					labelstyle = (args.labelstyle or ) .. (argsOddOrEven .. 'labelstyle' or ),
					datastyle = (args.datastyle or ) .. (argsOddOrEven .. 'datastyle' or )
				}
			end
			bodynumstr = (bodynumstr or ) .. v
		end
	end
	
	--
	Template:Infobox/row
	
	local function row(header, headerstyle, label, labelstyle, data, datastyle, rowstyle, class, rowclass, id, itemprop, rowitemprop, itemtype, rowitemtype, itemref, rowitemref)
		local result =
		if header then
			result =  .. header .. 
		elseif data then
			result = 
			if label then
				result = result ..  .. label .. 
			else
					result = result .. 
			end
			result = result .. '\n' .. data .. 
		end
		return result
	end
	
	--
	Template:Infobox
	
	--ヘッダー部
	if not child then
		--tableタグ
		result = 
		if args.title then
			--captionタグ
			result = result ..  .. args.title .. 
		end
		if args.above then
			result = result ..  .. args.above ..
		end
	else
		if args.title then
			result =  .. args.title .. 
		end
	end
	for k, v in pairs(h.subheader) do
		result = result .. row(nil, nil, nil, nil, v1, v.style or h.subheader.style, v.rowstyle, h.subheader.class, v.rowclass, nil, nil, nil, nil, nil, nil, nil)
	end
	for k, v in pairs(h.image) do
		result = result .. row(nil, nil, nil, nil, v1 and (v1 .. (v.caption or )), v.style or h.image.style, v.rowstyle, h.image.class, v.rowclass, nil, nil, nil, nil, nil, nil, nil)
	end
	
	--本体部ソート
	for k, v in pairs(body) do
		sbody#sbody + 1 = v
	end
	table.sort(sbody,
		function (a, b) return a1 ' .. args.below .. 
	end
	
	if link then
		--Template:Transclude
		link = string.gsub(link, ':?Ttemplate:', )
		if not string.find(link, ':') then
			link = 'Template:' .. link
		end
		result = result .. 'テンプレートを表示'
	end
	
	--tableタグ閉じ
	if not child then
		result = result .. 
	end
	
	--出力
	return result
end
return p