Module:Smyth: Difference between revisions

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
forif separator, number in string.gmatchfind(sectionParameter, "([^%d%s]*)(%d+)") dothen
for number, separator in gmatch(sectionParameter, "(%d* ?%a?)(%p?[^%d]*)") do
sections[n] = number
if separatornumber == "" or separatornumber == nil then
separators sections[n] = ""
else
separators sections[n] = separatornumber
end
if sections[n]separator == nil"" or sections[n]separator == ""nil then
separators[n] = ""
breakelse
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 #sections[2] == 1"" then
sign = "§"
else
Line 52 ⟶ 62:
end
for i = 1, #sections do
if sections[ni] == "" numberthen
output = output .. separators[i] .. "[" .. Smyth(sections[i])
break
if i == 1 then
else
output = output .. " " .. sign
output = output .. separators[i] .. "[" .. Smyth(sections[i])
if i == 1 then
output = output .. " " .. sign
end
output = output .. " " .. sections[i] .. "]" .. separators[i]
end
output = output .. " " .. sections[i] .. "]"
end
return output