localp={}localfunctionisnotempty(s)returnsands:match('^%s*(.-)%s*$')~=''endfunctionp.table(frame)localargs=(frame.args[1]~=nil)andframe.argsorframe:getParent().argslocalcolsifisnotempty(args['4thcoltitle'])andisnotempty(args['3rdcoltitle'])thencols=4elseifisnotempty(args['3rdcoltitle'])thencols=3elsecols=2end-- 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('Airlines')cell=row:tag('th')cell:addClass('unsortable')cell:wikitext('Destinations')if(isnotempty(args['3rdcoltitle']))thencell=row:tag('th')cell:css('width','10%')if(isnotempty(args['3rdcolunsortable']))thencell:addClass('unsortable')endcell:wikitext(args['3rdcoltitle'])endif(isnotempty(args['4thcoltitle']))thencell=row:tag('th')if(isnotempty(args['4thcolunsortable']))thencell:addClass('unsortable')endcell:wikitext(args['4thcoltitle'])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