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

添加1,272字节 、​ 2024年1月10日 (星期三)
解决colspan和rowspan撞到一起的时候缩进错误的bug:What a Wonderful Radio!!#节目表第92行
Zth讨论 | 贡献
(解决colspan和rowspan撞到一起的时候缩进错误的bug:What a Wonderful Radio!!#节目表第92行)
 
(未显示2个用户的16个中间版本)
end
 
function spanrspan(str)
return mw.ustring.match(str, "rowspan%s*=%s*[\"\']?(%d+)") or 1
end
 
function cspan(str)
return mw.ustring.match(str, "colspan%s*=%s*[\"\']?(%d+)") or 1
end
 
function ktype(str)
local key = str:sub(1, 2)
if key == "cv" or key == "CV" then
return "read"
elseif key == "BV" or key == "bv" or key == "AV" or key == "av" then
return "video"
end
end
 
local id = args.start or 1
local rowspan = {}
local colspan = 0
local urlcol = tonumber(args.urlcol)
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>").."|\n|"..date[2]
id = id + date[1]
elseif i == (ncvcols %colspan ncols)= then0
local video = string.match(v, "^[%l%u%d]+")
local link = string.match(v, "^[%l%u%d%p]+")
local label = mw.ustring.match(v, "【(.+)】")
result = result.."||"..
(video and "<div class=\"video-link\">[https://www.bilibili.com/video/"..link.." "..video.."]"..(label or "").."</div>" or
"<div style=\"text-align:center\">–</div>")
else
rowspan[i] = rowspan[i] or 0
if rowspan[i] > 0 then
rowspan[i] = rowspan[i] - 1
if colspan > 0 then
colspan = colspan - 1
end
elseif colspan > 0 then
colspan = colspan - 1
else
local td = cell(v)
if td[1] then
rowspan[i] = spanrspan(td[1]) - 1
colspan = cspan(td[1]) - 1
end
if i == 0(ncvcols % ncols) then
result = result.."|\n|"..(td[1] and td[1].."|" or "")..td[2]
if td[2] then
result = result.."| |"..
for index,value in ipairs(mw.text.split(td[2], ";")) do
local video = string.match(vvalue, "^[%l%u%d]+")
local link = string.match(vvalue, "^[%l%u%d%p]+")
local label = mw.ustring.match(vvalue, "【(.+)】")
result = result..(video and
(video and "<div class=\"video-link\">[https://www.bilibili.com/video/"..link.." "..video.."]"..(label or "").."</div>" or
or "")
end
else
result = result.."<div style=\"text-align:center\">|</div>")
end
elseif i == 0 then
result = result.."\n|"..(td[1] and td[1].."|" or "")..td[2]
elseif i == urlcol then
result = result.."\n|"..(td[1] or "")..
(td[2] == "" and " |" or " |<div class=\"video-link\">[https://www.bilibili.com/"..ktype(td[2]).."/"..td[2].." "..td[2].."]</div>")
else
result = result.."|\n|"..(td[1] or "")..
(td[2] == "" and " class=\"table-none\"| " or
(" |"..frame:expandTemplate{title = "memberlink/cv", args = mw.text.split(td[2], "、")}))
end
14,865

个编辑