localp={}localfunction_main(args)localsep=mw.message.new('comma-separator'):plain()returntable.concat(args,sep)endfunctionp.main(frame)localorigArgsifframe==mw.getCurrentFrame()then-- We're being called via #invoke. If the invoking template passed any arguments,-- use them. Otherwise, use the arguments that were passed into the template.origArgs=frame:getParent().argsfork,vinpairs(frame.args)doorigArgs=frame.argsbreakendelse-- We're being called from another module or from the debug console, so assume-- the arguments are passed in directly.origArgs=frameend-- Use integer args only, and 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)doiftype(k)=='number'andk>=1andmath.floor(k)==kandmw.ustring.match(v,'%S')-- Remove blank or whitespace values.thentable.insert(args,k)endendtable.sort(args)fori,vinipairs(args)doargs[i]=origArgs[v]-- Trim whitespace from all args.iftype(args[i])=='string'thenargs[i]=mw.text.trim(args[i])endendreturn_main(args)endreturnp