Module:Smyth/sandbox: Difference between revisions

Content deleted Content added
will never be an empty string
Theoretically, this can't happen either - gmatch will give an empty string for postscripts and separators if the first capture group matches but the second/third ones match empty strings. postscripts[1] would be nil if the line 46 else branch was reached, but we can just set postscripts[1] = "" there. Also, making `n` a local variable, and moving it a bit further up
Line 37:
local part = frame.args[2]
if sectionParameter then
n = 1
if mw.ustring.find(sectionParameter, "[^%d%s]") then
local n = 1
for number, postscript, separator in mw.ustring.gmatch(sectionParameter, "(%d+ ?%u?)(%.?[%l%d]?)(%p?[^%d]*)") do
sections[n], postscripts[n], separators[n] = number, postscript, separator
Line 44:
end
else
sections[1], postscripts[1], separators[1] = mw.ustring.match(sectionParameter, "(%d+)"), "", ""
end
else
Line 58:
for i = 1, #sections do
if not postscripts[i] then postscripts[i] = "" end
if not separators[i] then separators[i] = "" end
output = output .. "[" .. Smyth(sections[i]).url .. " "
if i == 1 then