Content deleted Content added
I think I finally made it work |
Misc code cleanup, remove functions and variables used only once |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1:
local export = {}
local function Smyth(section, part)▼
code = mw.uri.encode(code, "PATH")▼
return "http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:" .. path .. ":" .. part .. "=" .. code▼
▲function Smyth(section, part)
if not part then
part = "smythp"
end
local Part, url
if section == "" or section == nil then
Line 40 ⟶ 25:
end
end
▲
end
return { url = url, Part = Part }
Line 52 ⟶ 38:
if sectionParameter then
n = 1
if mw.ustring.find(sectionParameter, "[^%d%s]") then
for number, postscript, separator in mw.ustring.gmatch(sectionParameter, "(%d+ ?%u?)(%.?[%l%d]?)(%p?[^%d]*)") do
sections[n], postscripts[n], separators[n] = number, postscript, separator
if sections[n] == "" or sections[n] == nil then
Line 61 ⟶ 47:
end
else
sections[1], separators[1] = mw.ustring.match(sectionParameter, "(%d+)"), ""
end
else
Line 79 ⟶ 65:
if not postscripts[i] then postscripts[i] = "" end
if not separators[i] then separators[i] = "" end
output = output .. "[" .. Smyth(sections[i]).url .. " "
if i == 1 then
output = output ..
end
output = output
end
end
Line 91 ⟶ 77:
function export.SmythPart(frame)
local sectionParameter = frame.args[1]
local section = mw.ustring.match(sectionParameter, "(%d+)")
return Smyth(section).Part
end
|