Module:Smyth: Difference between revisions

Content deleted Content added
debug, allow multiple separators
add section signs
Line 23:
 
function export.SmythSection(frame)
local output, sign = "", ""
local sectionssectionParameter = frame.args[1]
local sectionsections, separators = {}, {}
local part = frame.args[2]
if sectionssectionParameter then
n = 1
for separator, number in string.gmatch(sectionssectionParameter, "([^%d]*)(%d+)") do
sectionsections[n] = number
if separator == "" or separator == nil then
separators[n] = ""
Line 36:
separators[n] = separator
end
if sectionsections[n] == nil or sectionsections[n] == "" then
n = falsebreak
end
n = n + 1
Line 44:
error("SmythSection wants input in the first parameter")
end
if #sections == nil or #sections == "" then
for i = 1, #section do
error("No numbers in the text provided to SmythSection")
output = output .. separators[i] .. "[" .. Smyth(section[i]) .. " " .. section[i] .. "]"
elseif #sections == 1 then
sign = "§"
else
sign = "§§"
end
for i = 1, #sectionsections do
output = output .. separators[i] .. "[" .. Smyth(sectionsections[i]) .. " " .. section[i] .. "]"
if i == 1 then
output = output .. " " .. sign
end
output = output .. " " .. sections[i] .. "]"
end
return output