「モジュール:Infobox/former」の版間の差分

削除された内容 追加された内容
Waiesu (会話 | 投稿記録)
4行目:
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 = {}, {} --本体部テーブル, ソート済み本体部テーブル
59 ⟶ 60行目:
local str, num = string.match(k, '^(%D+)(%d+)$')
num = tonumber(num)
body[num]if =not body[num] or {num}then
local OddOrEven = (num % 2 ~= 0) and 'odd' or 'even'
body[num][str] = v{
num,
headerstyle = (args.headerstyle or '') .. (args[OddOrEven .. 'headerstyle'] or ''),
labelstyle = (args.labelstyle or '') .. (args[OddOrEven .. 'labelstyle'] or ''),
datastyle = (args.datastyle or '') .. (args[OddOrEven .. 'datastyle'] or '')
}
end
body[num][str] = (body[num][str] or '') .. v
end
end
67 ⟶ 76行目:
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 = '<tr><th scope="col" colspan="2" classstyle="' .. (classrowstyle or '') .. '"' style.. (rowitemtype and (' itemscope itemtype="text-align:center; ' .. (headerstylerowitemtype .. '"') or '') .. ' itemref="' .. (rowitemtyperowitemref andor ('') itemscope.. itemtype'"><th scope="'col" ..colspan="2" rowitemtypeclass="' .. '"')(class or '') .. '" itemrefstyle="text-align:center; ' .. (rowitemrefheaderstyle or '') .. '">' .. header .. '</th></tr>'
elseif data then
result = '<tr class="' .. (rowclass or '') .. '" style="' .. (rowstyle or '') .. '" itemprop="' .. (rowitemprop or '') .. '"' .. (rowitemtype and (' itemscope itemtype="' .. rowitemtype .. '"') or '') .. ' itemref="' .. (rowitemref or '') .. '">'
if label then
result = result .. '<th scope="row" style="text-align:left; white-space:nowrap; ' .. (labelstyle or '') .. '">' .. label .. '</th><td class="' .. (class or '') .. '" style="' .. (datastyle or '') .. '" itemprop="' .. (itemprop or '') .. '"' .. (itemtype and (' itemscope itemtype="' .. itemtype .. '"') or '') .. ' itemref="' .. (itemref or '') .. '">'
89 ⟶ 98行目:
if not child then
--tableタグ
result = '<table class="' .. (subbox and '' or 'infobox ') .. (args.bodyclass or '') .. '" style="' .. (subbox and 'min-width:100%; width:calc(100% + 6px); margin:-3px; ' or 'width:22em; ') .. (args.bodystyle or '') .. '"' .. (args.bodyitemtype and (' itemscope itemtype="' .. args.bodyitemtype .. '"') or '') .. ' itemref="' .. (args.bodyitemref or '') .. '">'
if args.title then
--captionタグ
104 ⟶ 113行目:
 
for k, v in pairs(h.subheader) do
result = result .. row(nil, nil, nil, nil, v[1], 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, v[1] and (v[1] .. (v.caption or '')), v.style or h.image.style, v.rowstyle, h.image.class, v.rowclass, nil, nil, nil, nil, nil, nil, nil)
end
119 ⟶ 128行目:
--本体部
for k, v in ipairs(sbody) do
result = result .. row(v.header, argsv.headerstyle, v.label, v.labelstyle or args.labelstyle, v.data, v.datastyle, or argsv.datastylerowstyle, v.class, v.rowclass, v.id, v.itemprop, v.rowitemprop, v.itemtype, v.rowitemtype, v.itemref, v.rowitemref)
end