Module:Smyth
Appearance
export = {}
data = {
["Smyth"] = {
["path"] = "1999.04.0007",
["parts"] = { "part", "chapter", "section", "smythp" }
}
}
local function url(resourceCode, part, code)
code = mw.uri.encode(code, PATH)
return "http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:" .. path .. ":" .. part .. "=" .. code
end
function Smyth(section, part)
if not part then
part = "smythp"
end
SmythData = data.Smyth
path = SmythData.path
return url(path, part, section)
end
function export.SmythSection(frame)
local output, sign = "", ""
local sectionParameter = frame.args[1]
local sections, separators = {}, {}
local part = frame.args[2]
if sectionParameter then
n = 1
for separator, number in string.gmatch(sectionParameter, "([^%d]*)(%d+)") do
sections[n] = number
if separator == "" or separator == nil then
separators[n] = ""
else
separators[n] = separator
end
if sections[n] == nil or sections[n] == "" then
break
end
n = n + 1
end
else
error("SmythSection wants input in the first parameter")
end
if #sections == nil or #sections == "" then
error("No numbers in the text provided to SmythSection")
elseif #sections == 1 then
sign = "§"
else
sign = "§§"
end
for i = 1, #sections do
output = output .. separators[i] .. "[" .. Smyth(sections[i])
if i == 1 then
output = output .. " " .. sign
end
output = output .. " " .. sections[i] .. "]"
end
return output
end
return export