![]() |
VOOZH | about |
Implements {{Command}}.
localp={} functionp.cmd(f) localargs=f iff==mw.getCurrentFrame()then args=f:getParent().args end localcommandName=args[1]:match('^%s*/?([^%s]+)'):lower() localparams={} localcommand={} --getparams fori,vinipairs(args)do ifi>1orv:match('^%s*/?(.+)'):lower()~=commandNamethen table.insert(params,mw.text.trim(v)) end end --escape space and split args if#params==1and(notargs[2]orargs[2]=='...')andparams[1]:find('%s')then params[1]=params[1]:match('^[^%s]+%s(.+)') end command=params ifargs.linkthen ifargs.link:lower()~='none'then commandName='[['..args.link..'|'..commandName..']]' end else commandName='[[Commands/'..commandName..'|'..commandName..']]' end table.insert(command,1,commandName) localslash='/' ifargs['/']=='0'orargs.slash=='0'then slash='' end localattr='' ifargs.longthen attr='style="display: flex; padding: 0.8em 1em; margin-bottom: 0.4em; word-warp: break-word;"' end localresult=table.concat(command,' '):gsub('〈space〉',' '):gsub('〈lsqb〉','%['):gsub('〈rsqb〉','%]'):gsub('〈apos〉',"'"):gsub('〈quot〉','"') -- Don't encode if told not to or if there is a sub-command ifargs.escape~='0'then result=result:gsub('<','<'):gsub('<(!%-%- Command %-%->)<','<%1<'):gsub('</code><(!%-%- /Command %-%->)','</code><%1') end result='<!-- Command --><code '..attr..'><span>'..slash..result..'</span></code><!-- /Command -->' returnresult end returnp