Content deleted Content added
will never be an empty string |
sync with live module |
||
(One intermediate revision by one other user not shown) | |||
Line 41:
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
if sections[n] == "" or sections[n] == nil then
break
end
n = n + 1
end
Line 49 ⟶ 52:
error("SmythSection wants input in the first parameter")
end
if #sections ==
error("No numbers in the text provided to SmythSection")
elseif sections[2] == "" or sections[2] == nil then
sign = "§"
else
sign = "§§"
end
for i = 1, #sections do
if sections[i] == "" or sections[i] == nil then -- Does gmatch return nil or an empty string when it finds no match?
if not postscripts[i] then postscripts[i] = "" end▼
break
if not separators[i] then separators[i] = "" end▼
else
output = output .. "[" .. Smyth(sections[i]).url .. " "▼
▲ if not postscripts[i] then postscripts[i] = "" end
if i == 1 then▼
▲ if not separators[i] then separators[i] = "" end
output = output .. sign .. " "▼
▲ output = output .. "[" .. Smyth(sections[i]).url .. " "
▲ if i == 1 then
▲ output = output .. sign .. " "
end
output = output .. sections[i] .. postscripts[i] .. "]" .. separators[i]▼
end
▲ output = output .. sections[i] .. postscripts[i] .. "]" .. separators[i]
end
return output
|