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 = ""
local sections = frame.args[1]
local section, separators = {}, {}
local part = frame.args[2]
if sections then
n = 1
for separator, number in string.gmatch(sections, "([^%d]*)(%d+)") do
section[n] = number
if separator == "" or separator == nil then
separators[n] = ""
else
separators[n] = separator
end
if section[n] == nil or section[n] == "" then
n = false
end
n = n + 1
end
else
error("SmythSection wants input in the first parameter")
end
for i = 1, #section do
output = output .. separators[i] .. "[" .. Smyth(section[i]) .. " " .. section[i] .. "]"
end
return output
end
return export