Module:Article list
Appearance
Please see Template:Article list.
local p = {};
function p.getlinks(frame)
local qids = frame.args[1]
local removes = frame.args.remove or ""
removelist = mw.text.split(removes,"%s*,%s*")
local links = {}
if qids then
for qid in qids:gmatch("Q%d+") do
links[#links+1] = "* ".. p.getlink(qid)
end
return table.concat(links,"\n")
else
return "Error: no parameter"
end
end
function p.getlink(qid)
local slink = mw.wikibase.sitelink(qid)
local label = mw.wikibase.getLabel(qid)
local pipe = ""
if slink then
if label then
pipe = p.removeword(label)
else
pipe = p.removeword(slink)
end
slink = "[[" .. slink .. "|" .. pipe .. "]]"
return slink
else
return ""
end
end
function p.removeword(link)
for i,remove in ipairs(removelist) do
local char1=string.sub(remove,1,1)
local regex="%f[%w][" .. string.upper(char1) .. string.lower(char1) .. "]" .. string.sub(remove,2) .. "*%f[%W]"
link=link:gsub(regex,"")
end
link = link:gsub("^(%l)", mw.ustring.upper)
return link
end
return p