Content deleted Content added
add section signs |
Misc code cleanup, remove functions and variables used only once |
||
(16 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▼
end▼
▲function Smyth(section, part)
if not part then
part = "smythp"
end
local Part, url
url, Part = "No number provided", "No number provided"
return url(path, part, section)▼
else
sectionNumber = tonumber(section)
Part = ""
else
if sectionNumber < 189 then
Part = "Part I: Letters, Sounds, Syllables, Accent"
elseif sectionNumber < 822 then
Part = "Part II: Inflection"
elseif sectionNumber < 900 then
Part = "Part III: Formation of Words"
elseif sectionNumber < 3049 then
Part = "Part IV: Syntax"
error("The largest valid section number is 3048")
end
end
▲
end
return { url = url, Part = Part }
end
function export.SmythSection(frame)
local sectionParameter = frame.args[1]
local
local sections, postscripts, separators = {}, {}, {}
local part = frame.args[2]
if sectionParameter then
n = 1
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 separator == "" or separator == nil then
n = n + 1▼
end
else
sections[1], separators[1] = mw.ustring.match(sectionParameter, "(%d+)"), ""
▲ break
▲ end
▲ n = n + 1
end
else
error("SmythSection wants input in the first parameter")
end
if #sections == nil
error("No numbers in the text provided to SmythSection")
elseif
sign = "§"
else
Line 52 ⟶ 60:
end
for i = 1, #sections do
if sections[i] == "" or sections[i] == nil then -- Does gmatch return nil or an empty string when it finds no match?
output = output .. separators[i] .. "[" .. Smyth(sections[i])▼
break
▲ if i == 1 then
else
output = output .. " " .. sign▼
if not postscripts[i] then postscripts[i] = "" end
if not separators[i] then separators[i] = "" end
if i == 1 then
end
end
▲ output = output .. " " .. sections[i] .. "]"
end
return output
▲end
function export.SmythPart(frame)
local sectionParameter = frame.args[1]
local section = mw.ustring.match(sectionParameter, "(%d+)")
end
|