Module:Cite Q: Difference between revisions

Content deleted Content added
cleanup
update from sandbox; changes by RexxS
Line 58:
-- So now we have something to return:
-- table 'out' is going to to store the returnauthor valuenames(s):
-- and table 'link' will store any links to the author's article
local out = {}
local link = {}
if props[1].mainsnak.datavalue.type == "wikibase-entityid" then
-- it's wiki-linked value, so output as link if possible
Line 72 ⟶ 74:
end
if sitelink then
-- just the plain author name,
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"
-- but keep a record of the links, using the same index
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"
link[#out] = sitelink
else
-- no sitelink, so check first for a redirect with that label
Line 78 ⟶ 83:
if artitle.id > 0 then
if artitle.isRedirect then
-- no sitelink,
-- but there's a redirect with the same title as the label;
-- let'sso store the link to that
out[#out + 1] = "[[" .. label .. "]]"
link[#out] = label
else
-- no sitelink and not a redirect but an article exists with the same title as the label
Line 107 ⟶ 115:
-- construct the list in the format we want
for k,v in ipairs(out) do
local parameter_name = 'author' .. k;
args[parameter_name] = v;
end
for k,v in pairs(link) do
local parameter_name = 'authorlink' .. k
args[parameter_name] = v
end
end