“模块:Radio-list”的版本间差异

添加900字节 、​ 2020年10月10日 (六) 07:26
无编辑摘要
local getArgs = require('Module:Arguments').getArgs
local p = {}
 
--[[
function date(stringstr)
local skip = 1
if stringstr:sub(1, 1) == 's' then
skip = 0
stringstr = mw.ustring.gsub(stringstr, "^%D+", "")
end
return {skip, mw.ustring.gsub(stringstr, "([年月])0?(%d+)", "%1<span class=\"countdown-num\">%2</span>")}
end
 
function cell(stringstr)
local property, value = mw.ustring.match(str, "([^|]*)|(.*)")
return {property, value or str}
end
 
function rowspanspan(stringstr)
return mw.ustring.match("rowspan= style=\"a:b\"{{!}}c"str, "rowspan%s*=%s*[\"\']?(%d+)") or 1
end
 
]]--
function p.main(frame)
local args = getArgs(frame, {removeBlanks = false})
--local result = "{|class=\"wikitable radio-list"..(args.comment and " radio-with-comment" or "").."\"\n!#!!配信日期"
--local ncols = 2 + (args.comment and 1 or 0)
--local ncvcols = 2
returnlocal cvcols = args.cvcols and mw.text.split(args.cvcols, "、") or {}
--[[iffor args.cvcolsk,v andin args.ipairs(cvcols) ~= "" thendo
ncvcolsncols = ncvcolsncols + 1
local cvcols = mw.text.split(args.cvcols, "、")
ncvcols = ncvcols + 1
for k,v in ipairs(cvcols) do
ncolsresult = ncols + 1result.."!!"..v
ncvcols = ncvcols + 1
result = result.."!!"..v
end
end
result = result.."!!视频资料"..(args.comment and "!!備註" or "")
local id = args.start or 1
local rowspan = {}
for k,v in ipairs(args) do
local i = k % ncols
if i == 1 then
local date = date(v)
result = result.."\n|-\n|"..(date[1] == 1 and id or "<div style=\"text-align:center\">–</div>").."||"..date[2]
id = id + date[1]
elseif (i > 1 and i < ncvcols) then
rowspan[i] = rowspan[i] or 0
result = result.."||"..(v == "" and "class=\"table-none\"| " or frame:expandTemplate{title = "memberlink/cv", args = mw.text.split(v, "、")})
if rowspan[i] > 0 then
rowspan[i] = rowspan[i] - 1
else
local td = cell(v)
if td[1] then
rowspan[i] = span(td[1]) - 1
end
if td[1] or td[2] == "" then
result = result.."!!||"..(td[1] or "")..v
(td[2] == "" and "class=\"table-none\"| " or ("|"..
frame:expandTemplate{title = "memberlink/cv", args = mw.text.split(v, "、")}))
else
result = result.."||"..(v == "" and "class=\"table-none\"| " or frame:expandTemplate{title = "memberlink/cv", args = mw.text.split(v, "、")})
end
end
elseif i == ncvcols then
local video = string.match(v, "[%l%u%d]+")
result = result.."||"..(video and "[https://www.bilibili.com/video/"..video.." "..v.."]" or "–")
elseif i == 0 then
resultrowspan[i] = result.."||"..vrowspan[i] or 0
if rowspan[i] > 0 then
rowspan[i] = rowspan[i] - 1
else
local td = cell(v)
if td[1] then
rowspan[i] = span(td[1]) - 1
end
result = result.."||"..(td[1] and td[1].."|" or "")..td[2]
end
end
end
return result.."\n|}"]]--
end
 
16,874

个编辑