Content deleted Content added
add section signs |
revamp, to allow for sections like "50 D" |
||
Line 7:
}
}
local find, match, gmatch = mw.ustring.find, mw.ustring.match, mw.ustring.gmatch
local function url(resourceCode, part, code)
Line 29 ⟶ 31:
if sectionParameter then
n = 1
for number, separator in gmatch(sectionParameter, "(%d* ?%a?)(%p?[^%d]*)") do
sections[n] = number▼
if
else
end▼
separators[n] = ""
separators[n] = separator
end
if sections[n] == "" and separators[n] == "" then
break
end
n = n + 1▼
end
else
▲ if sections[n] == nil or sections[n] == "" then
sections[1], separators[1] = match(sectionParameter, "(%d*)"), ""
▲ break
▲ end
▲ n = n + 1
end
else
Line 46 ⟶ 56:
if #sections == nil or #sections == "" then
error("No numbers in the text provided to SmythSection")
elseif
sign = "§"
else
Line 52 ⟶ 62:
end
for i = 1, #sections do
output = output .. separators[i] .. "[" .. Smyth(sections[i])▼
break
if i == 1 then▼
else
output = output .. " " .. sign▼
▲ if i == 1 then
▲ output = output .. " " .. sign
end
output = output .. " " .. sections[i] .. "]" .. separators[i]▼
end
▲ output = output .. " " .. sections[i] .. "]"
end
return output
|