localp={}
localseparators={
dot=true,
pipe=true,
comma=true,
['tpt-languages']=true
}
localfunctiongetSeparator(sep)
iftype(sep)~='string'then
returnnil
end
ifseparators[sep]then
returnmw.message.new(sep..'-separator'):plain()
else
returnsep
end
end
localfunctiongenerateLink(page,nspace,delim,endDelim)
ifnotpagethen
returnnil
end
localpagename=mw.title.new(page)
ifnotpagenamethen
-- Default to the args we were passed if our page
-- object was nil.
pagename=page
else
pagename=pagename.text
end
delim=delimor''
endDelim=endDelimordelim
nspace=nspaceor''
ifnspace=='all'then
nspace=''
pagename=page
end
localoutStr=mw.ustring.gsub(
string.format(
'%s[[:%s:%s|%s]]%s',
delim,nspace,pagename,page,endDelim
),
':+',
':'
)
returnoutStr
end
functionp._main(args)
localt={}
localseparator=getSeparator(args.separator)
localconjunction=getSeparator(args.conjunction)
fori,vinipairs(args)do
table.insert(t,generateLink(
v,args.nspace,args.delim,args.edelim
))
end
returnmw.text.listToText(t,separator,conjunction)
end
functionp.main(frame)
localorigArgs=require('Module:Arguments').getArgs(frame,{
trim=false,
removeBlanks=false,
wrappers='Template:Pagelist'
})
-- Process integer args. Allow for explicit positional arguments that are
-- specified out of order, e.g. {{br separated entries|3=entry3}}.
-- After processing, the args can be accessed accurately from ipairs.
localargs={}
fork,vinpairs(origArgs)do
iftype(k)=='number'and
k>=1and
math.floor(k)==kand
string.match(v,'%S')then-- Remove blank or whitespace values.
table.insert(args,k)
end
end
table.sort(args)
fori,vinipairs(args)do
args[i]=origArgs[v]
-- Trim whitespace.
iftype(args[i])=='string'then
args[i]=mw.text.trim(args[i])
end
end
-- Get old named args. We don't need to remove blank values
-- as for the nspace and edelim parameters the behaviour is different
-- depending on whether the parameters are blank or absent, and for
-- the delim parameter the default should be the blank string anyway.
args.delim=origArgs.delim
args.edelim=origArgs.edelim
args.nspace=origArgs.nspace
-- Get new named args, "separator" and "conjunction", and strip blank values.
iforigArgs.separatorandorigArgs.separator~=''then
args.separator=origArgs.separator
end
iforigArgs.conjunctionandorigArgs.conjunction~=''then
args.conjunction=origArgs.conjunction
end
returnp._main(args)
end
returnp