localp={}localfunctionisnotempty(s)returnsands:match('^%s*(.-)%s*$')~=''endfunctionp.table(frame)localargs=(frame.args[1]~=nil)andframe.argsorframe:getParent().argslocalcols=isnotempty(args['3rdcoltitle'])and3or2-- compute the maximum cell indexlocalcellcount=0fork,vinpairs(args)doiftype(k)=='number'andisnotempty(v)thencellcount=math.max(cellcount,k)endend-- compute the number of rowslocalrows=math.ceil(cellcount/cols)-- create the root tablelocalroot=mw.html.create('table')root:addClass('wikitable'):addClass('sortable'):css('font-size','95%')-- add the header rowlocalrow=root:tag('tr')localcell=row:tag('th')cell:wikitext('شرکتهای هواپیمایی')cell=row:tag('th')cell:addClass('unsortable')cell:wikitext('مقصدهای پروازی')if(isnotempty(args['3rdcoltitle']))thencell=row:tag('th')cell:css('width','10%')cell:wikitext(args['3rdcoltitle'])end-- loop over rowsforj=1,rowsdorow=root:tag('tr')fori=1,colsdocell=row:tag('td')if(i>2)thencell:css('text-align','center')endcell:wikitext(args[cols*(j-1)+i]or'')endend-- return the root tablereturntostring(root)endreturnp