Module:Aligned table
- Аԥсшәа
- العربية
- Asturianu
- Azərbaycanca
- تۆرکجه
- Basa Bali
- বাংলা
- 閩南語 / Bân-lâm-gí
- Башҡортса
- Беларуская (тарашкевіца)
- भोजपुरी
- Bikol Central
- Български
- Bosanski
- Català
- Čeština
- Chamoru
- Corsu
- Dansk
- الدارجة
- Español
- فارسی
- Fiji Hindi
- Føroyskt
- Français
- Galego
- ГӀалгӀай
- ગુજરાતી
- गोंयची कोंकणी / Gõychi Konknni
- 客家語 / Hak-kâ-ngî
- 한국어
- Hausa
- Հայերեն
- हिन्दी
- Hrvatski
- Ilokano
- Bahasa Indonesia
- Ирон
- Íslenska
- ಕನ್ನಡ
- ქართული
- Kernowek
- Kurdî
- Ladin
- Latviešu
- Lëtzebuergesch
- Lietuvių
- Madhurâ
- मैथिली
- Македонски
- മലയാളം
- Māori
- मराठी
- مصرى
- Bahasa Melayu
- 閩東語 / Mìng-dĕ̤ng-ngṳ̄
- Мокшень
- Монгол
- မြန်မာဘာသာ
- नेपाली
- 日本語
- Нохчийн
- Norsk nynorsk
- ଓଡ଼ିଆ
- Oʻzbekcha / ўзбекча
- ਪੰਜਾਬੀ
- ပအိုဝ်ႏဘာႏသာႏ
- Português
- Qaraqalpaqsha
- Română
- Русский
- संस्कृतम्
- ᱥᱟᱱᱛᱟᱲᱤ
- Scots
- Shqip
- සිංහල
- Simple English
- Slovenščina
- کوردی
- Српски / srpski
- Srpskohrvatski / српскохрватски
- Suomi
- Tagalog
- தமிழ்
- ไทย
- ತುಳು
- Türkçe
- Türkmençe
- Українська
- اردو
- Vèneto
- Tiếng Việt
- Winaray
- 吴语
- 粵語
- 中文
- Betawi
- Kadazandusun
- Jaku Iban
- Kumoring
Appearance
From Wikipedia, the free encyclopedia
Warning This Lua module is used on 14,000+ pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
Implements {{Aligned table }}
The above documentation is transcluded from Module:Aligned table/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
-- This module implements {{aligned table}} localp={} localfunctionisnotempty(s) returnsands:match('^%s*(.-)%s*$')~='' end functionp.table(frame) localargs=(frame.args[3]~=nil)andframe.argsorframe:getParent().args localentries={} localcolclass={} localcolstyle={} localcols=tonumber(args['cols'])or2 -- create the root table localroot=mw.html.create('table') -- add table style for fullwidth ifisnotempty(args['fullwidth'])then root :css('width','100%') :css('border-collapse','collapse') :css('border-spacing','0px 0px') :css('border','none') end -- add table classes ifisnotempty(args['class'])then root:addClass(args['class']) end -- add table style ifisnotempty(args['style'])then root:cssText(args['style']) end -- build arrays with the column styles and classes ifisnotempty(args['leftright'])then colstyle[1]='text-align:left;' colstyle[2]='text-align:right;' end ifisnotempty(args['rightleft'])then colstyle[1]='text-align:right;' colstyle[2]='text-align:left;' end fori=1,colsdo colclass[i]=colclass[i]or'' colstyle[i]=colstyle[i]or'' ifisnotempty(args['colstyle'])then colstyle[i]=args['colstyle']..';'..colstyle[i] end ifisnotempty(args['colalign'..tostring(i)])then colstyle[i]='text-align:'..args['colalign'..tostring(i)]..';'..colstyle[i] elseifisnotempty(args['col'..tostring(i)..'align'])then colstyle[i]='text-align:'..args['col'..tostring(i)..'align']..';'..colstyle[i] elseifisnotempty(args['align'..tostring(i)])then colstyle[i]='text-align:'..args['align'..tostring(i)]..';'..colstyle[i] end ifisnotempty(args['colnowrap'..tostring(i)])then colstyle[i]='white-space:nowrap;'..colstyle[i] elseifisnotempty(args['col'..tostring(i)..'nowrap'])then colstyle[i]='white-space:nowrap;'..colstyle[i] elseifisnotempty(args['nowrap'..tostring(i)])then colstyle[i]='white-space:nowrap;'..colstyle[i] end ifisnotempty(args['colwidth'..tostring(i)])then colstyle[i]='width:'..args['colwidth'..tostring(i)]..';'..colstyle[i] elseifisnotempty(args['col'..tostring(i)..'width'])then colstyle[i]='width:'..args['col'..tostring(i)..'width']..';'..colstyle[i] elseifisnotempty(args['colwidth'])then colstyle[i]='width:'..args['colwidth']..';'..colstyle[i] end ifisnotempty(args['colstyle'..tostring(i)])then colstyle[i]=colstyle[i]..args['colstyle'..tostring(i)] elseifisnotempty(args['col'..tostring(i)..'style'])then colstyle[i]=colstyle[i]..args['col'..tostring(i)..'style'] elseifisnotempty(args['style'..tostring(i)])then colstyle[i]=colstyle[i]..args['style'..tostring(i)] end ifisnotempty(args['colclass'..tostring(i)])then colclass[i]=args['colclass'..tostring(i)] elseifisnotempty(args['col'..tostring(i)..'class'])then colclass[i]=args['col'..tostring(i)..'class'] elseifisnotempty(args['class'..tostring(i)])then colclass[i]=args['class'..tostring(i)] end end -- compute the maximum cell index localcellcount=0 fork,vinpairs(args)do iftype(k)=='number'then cellcount=math.max(cellcount,k) end end -- compute the number of rows localrows=math.ceil(cellcount/cols) -- build the table content ifisnotempty(args['title'])then localcaption=root:tag('caption') caption:cssText(args['titlestyle']) caption:wikitext(args['title']) end ifisnotempty(args['above'])then localrow=root:tag('tr') localcell=row:tag('th') cell:attr('colspan',cols) cell:cssText(args['abovestyle']) cell:wikitext(args['above']) end forj=1,rowsdo -- start a new row localrow=root:tag('tr') ifisnotempty(args['rowstyle'])then row:cssText(args['rowstyle']) else row:css('vertical-align','top') end ifisnotempty(args['rowclass'])then row:addClass(args['rowclass']) end -- loop over the cells in the row fori=1,colsdo localcell ifisnotempty(args['row'..tostring(j)..'header'])then cell=row:tag('th'):attr('scope','col') elseifisnotempty(args['col'..tostring(i)..'header'])then cell=row:tag('th'):attr('scope','row') else cell=row:tag('td') end ifargs['class'..tostring(j)..'.'..tostring(i)]then cell:addClass(args['class'..tostring(j)..'.'..tostring(i)]) else ifargs['rowclass'..tostring(j)]then cell:addClass(args['rowclass'..tostring(j)]) elseifargs['row'..tostring(j)..'class']then cell:addClass(args['row'..tostring(j)..'class']) elseifargs['rowevenclass']andmath.fmod(j,2)==0then cell:addClass(args['rowevenclass']) elseifargs['rowoddclass']andmath.fmod(j,2)==1then cell:addClass(args['rowoddclass']) end ifcolclass[i]~=''then cell:addClass(colclass[i]) end end ifargs['style'..tostring(j)..'.'..tostring(i)]then cell:cssText(args['style'..tostring(j)..'.'..tostring(i)]) else ifargs['rowstyle'..tostring(j)]then cell:cssText(args['rowstyle'..tostring(j)]) elseifargs['rowevenstyle']andmath.fmod(j,2)==0then cell:cssText(args['rowevenstyle']) elseifargs['rowoddstyle']andmath.fmod(j,2)==1then cell:cssText(args['rowoddstyle']) elseifargs['row'..tostring(j)..'style']then cell:cssText(args['row'..tostring(j)..'style']) end ifisnotempty(colstyle[i])then cell:cssText(colstyle[i]) end end cell:wikitext(mw.ustring.gsub(args[cols*(j-1)+i]or'','^(.-)%s*$','%1')or'') end end -- return the root table returntostring(root) end returnp