Module:Citation
From Warwick Wiki
Powers {{citation}}.
local p = {}
local h = {}
function p.citation(frame)
local args = frame:getParent().args
local data = {}
data["authors"] = args["authors"] or ""
if data["authors"] == "" then
if args["author"] or args["author1"] then
data["authors"] = args["author"] or args["author1"]
elseif args["last"] or args["last1"] then
data["authors"] = args["last"] or args["last1"]
if args["first"] or args["first1"] then
data["authors"] = data["authors"] .. ", " .. (args["first"] or args["first1"])
end
end
if args["author-link"] or args["author-link1"] then
data["authors"] = "[[" .. (args["author-link"] or args["author-link1"]) .. "|" .. data["authors"] .. "]]"
end
local finished = false
local i = 2
if not (args["author" .. toString(i)] or args["last" .. toString(i)]) then
finished = true
end
while not finished do
local displayText = ""
if args["author" .. toString(i)] then
displayText = displayText .. args["author" .. toString(i)]
elseif args["last" .. toString(i)] then
displayText = displayText .. args["last" .. toString(i)]
if args["first" .. toString(i)] then
displayText = displayText .. ", " .. args["first" .. toString(i)]
end
end
if args["author-link" .. toString(i)] then
data["authors"] = data["authors"] .. "; [[" .. args["first" .. toString(i)] .. "|" .. displayText .. "]]"
else
data["authors"] = data["authors"] .. "; " .. displayText
end
i = i + 1
if not (args["author" .. toString(i)] or args["last" .. toString(i)]) then
finished = true
end
end
end
end