Jump to content

Module:Smyth

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Erutuon (talk | contribs) at 03:40, 4 October 2016 (a module to generate Perseus links for refs, starting with Smyth's Greek Grammar). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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 sections = frame.args[1]
	local section = {}
	local part = frame.args[2]
	if sections then
		n = 1
		while n do
			section[n] = string.gmatch(sections, "%s*(%d+)")
			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 .. "[" .. Smyth(section[i]) .. section[i] .. "]"
	end
	return output
end