Module:RoundN: Difference between revisions

Content deleted Content added
streamline matching
remove html comments from some args; no line if double skip
Line 69:
 
function p._main(args, frame)
function args:clean(key)--prevent html comments from breaking some args
p.cols = tonumber(args.columns)
args[key] = args[key] and string.gsub(string.gsub(mw.text.decode(args[key]), '<!.+>', ''), '%W', '') or nil
p.bold = ({low = 1, high = 2})[args.bold_winner]
return args[key]
end
p.cols = tonumber(args.:clean('columns'))
p.bold = ({low = 1, high = 2})[args.:clean('bold_winner')]
local skipMatch, unBold = {}, {}--(skip|manualbold)match# to boolean
for k, v_ in pairs(args) do
local mType, mNum = string.match(k, '^(%a+)match(%d+)$')
mType, mNum = ({skip = skipMatch, manualbold = unBold})[mType], tonumber(mNum)
if mType and mNum then
mType[mNum] = vargs:clean(k) == 'yes' or vargs[k] == 'true'
end
end
Line 88 ⟶ 92:
}) do
if args[v] ~= nil then
p[v] = args[:clean(v]) == 'yes' or args[v] == 'true'
end
end
Line 175 ⟶ 179:
:tag'td'
:attr{rowspan = bump + 4}
:css('border-bottom', not skipMatch[RD.top] and '1px solid' or nil)
RD.n = 0
for r = bumps + 1, rows, p.unit * 2 do
Line 200 ⟶ 204:
:attr{rowspan = maxSpan(p.unit * 4, r + p.unit, rows)}
:css{
['border-width'] = (RD.t % 2 < 1 and 2 or 0) .. '2pxpx 0 ' .. (not skipMatch[RD.top + RD.n + 2] and rowNum[r + p.unit * 5] and '1px' or 0),
['border-style'] = 'solid'
}