Esta plantía úsase'n unes Plantía:Sigfig páxines, de mou que los cambios que se faigan equí notaránse abondo. Por favor, prueba cualquier cambiu nes subpáxines /sandbox o /testcases de la plantía, o na to propia subpáxina d'usuariu. Por favor, comenta los cambios na páxina d'alderique antes de publicalos.
Esti módulu ta suxetu a proteición de páxina. Ye un módulu visible enforma qu'usa un númberu de páxines bien grande, o se sustituye frecuentemente. Como'l vandalismu o les enquivocaciones afeutaríen a munches páxines, y mesmo una edición mínima podría causar una carga sustancial nos sirvidores, ta protexíu escontra ediciones.
-- This module implements {{aligned table}}localp={}localfunctionisnotempty(s)returnsands:match('^%s*(.-)%s*$')~=''endfunctionp.table(frame)localargs=(frame.args[3]~=nil)andframe.argsorframe:getParent().argslocalentries={}localcolclass={}localcolstyle={}localcols=tonumber(args['cols'])or2-- create the root tablelocalroot=mw.html.create('table')-- add table style for fullwidthifisnotempty(args['fullwidth'])thenroot:css('width','100%'):css('border-collapse','collapse'):css('border-spacing','0px 0px'):css('border','none')end-- add table classesifisnotempty(args['class'])thenroot:addClass(args['class'])end-- add table styleifisnotempty(args['style'])thenroot:cssText(args['style'])end-- build arrays with the column styles and classesifisnotempty(args['leftright'])thencolstyle[1]='text-align:left;'colstyle[2]='text-align:right;'endfori=1,colsdocolclass[i]=colclass[i]or''colstyle[i]=colstyle[i]or''ifisnotempty(args['colstyle'])thencolstyle[i]=args['colstyle']..';'..colstyle[i]endifisnotempty(args['colalign'..tostring(i)])thencolstyle[i]='text-align:'..args['colalign'..tostring(i)]..';'..colstyle[i]elseifisnotempty(args['col'..tostring(i)..'align'])thencolstyle[i]='text-align:'..args['col'..tostring(i)..'align']..';'..colstyle[i]elseifisnotempty(args['align'..tostring(i)])thencolstyle[i]='text-align:'..args['align'..tostring(i)]..';'..colstyle[i]endifisnotempty(args['colnowrap'..tostring(i)])thencolstyle[i]='white-space:nowrap;'..colstyle[i]elseifisnotempty(args['col'..tostring(i)..'nowrap'])thencolstyle[i]='white-space:nowrap;'..colstyle[i]elseifisnotempty(args['nowrap'..tostring(i)])thencolstyle[i]='white-space:nowrap;'..colstyle[i]endifisnotempty(args['colwidth'..tostring(i)])thencolstyle[i]='width:'..args['colwidth'..tostring(i)]..';'..colstyle[i]elseifisnotempty(args['col'..tostring(i)..'width'])thencolstyle[i]='width:'..args['col'..tostring(i)..'width']..';'..colstyle[i]elseifisnotempty(args['colwidth'])thencolstyle[i]='width:'..args['colwidth']..';'..colstyle[i]endifisnotempty(args['colstyle'..tostring(i)])thencolstyle[i]=colstyle[i]..args['colstyle'..tostring(i)]elseifisnotempty(args['col'..tostring(i)..'style'])thencolstyle[i]=colstyle[i]..args['col'..tostring(i)..'style']elseifisnotempty(args['style'..tostring(i)])thencolstyle[i]=colstyle[i]..args['style'..tostring(i)]endifisnotempty(args['colclass'..tostring(i)])thencolclass[i]=args['colclass'..tostring(i)]elseifisnotempty(args['col'..tostring(i)..'class'])thencolclass[i]=args['col'..tostring(i)..'class']elseifisnotempty(args['class'..tostring(i)])thencolclass[i]=args['class'..tostring(i)]endend-- compute the maximum cell indexlocalcellcount=0fork,vinpairs(args)doiftype(k)=='number'thencellcount=math.max(cellcount,k)endend-- compute the number of rowslocalrows=math.ceil(cellcount/cols)-- build the table contentifisnotempty(args['title'])thenlocalcaption=root:tag('caption')caption:cssText(args['titlestyle'])caption:wikitext(args['title'])endifisnotempty(args['above'])thenlocalrow=root:tag('tr')localcell=row:tag('th')cell:attr('colspan',cols)cell:cssText(args['abovestyle'])cell:wikitext(args['above'])endforj=1,rowsdo-- start a new rowlocalrow=root:tag('tr')ifisnotempty(args['rowstyle'])thenrow:cssText(args['rowstyle'])elserow:css('vertical-align','top')end-- loop over the cells in the rowfori=1,colsdolocalcellifisnotempty(args['row'..tostring(j)..'header'])thencell=row:tag('th'):attr('scope','col')elseifisnotempty(args['col'..tostring(i)..'header'])thencell=row:tag('th'):attr('scope','row')elsecell=row:tag('td')endifargs['class'..tostring(j)..'.'..tostring(i)]thencell:addClass(args['class'..tostring(j)..'.'..tostring(i)])elseifargs['rowclass'..tostring(j)]thencell:addClass(args['rowclass'..tostring(j)])elseifargs['row'..tostring(j)..'class']thencell:addClass(args['row'..tostring(j)..'class'])elseifargs['rowevenclass']andmath.fmod(j,2)==0thencell:addClass(args['rowevenclass'])elseifargs['rowoddclass']andmath.fmod(j,2)==1thencell:addClass(args['rowoddclass'])endifcolclass[i]~=''thencell:addClass(colclass[i])endendifargs['style'..tostring(j)..'.'..tostring(i)]thencell:cssText(args['style'..tostring(j)..'.'..tostring(i)])elseifargs['rowstyle'..tostring(j)]thencell:cssText(args['rowstyle'..tostring(j)])elseifargs['rowevenstyle']andmath.fmod(j,2)==0thencell:cssText(args['rowevenstyle'])elseifargs['rowoddstyle']andmath.fmod(j,2)==1thencell:cssText(args['rowoddstyle'])elseifargs['row'..tostring(j)..'style']thencell:cssText(args['row'..tostring(j)..'style'])endifisnotempty(colstyle[i])thencell:cssText(colstyle[i])endendcell:wikitext(mw.ustring.gsub(args[cols*(j-1)+i]or'','^(.-)%s*$','%1')or'')endend-- return the root tablereturntostring(root)endreturnp