<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://the-democratika.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AAligned_table</id>
	<title>Module:Aligned table - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://the-democratika.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AAligned_table"/>
	<link rel="alternate" type="text/html" href="https://the-democratika.com/wiki/index.php?title=Module:Aligned_table&amp;action=history"/>
	<updated>2026-04-04T17:49:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://the-democratika.com/wiki/index.php?title=Module:Aligned_table&amp;diff=5869&amp;oldid=prev</id>
		<title>&gt;Plastikspork: Optional rowclass</title>
		<link rel="alternate" type="text/html" href="https://the-democratika.com/wiki/index.php?title=Module:Aligned_table&amp;diff=5869&amp;oldid=prev"/>
		<updated>2021-01-13T21:53:43Z</updated>

		<summary type="html">&lt;p&gt;Optional rowclass&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{aligned table}}&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function isnotempty(s)&lt;br /&gt;
	return s and s:match( &amp;#039;^%s*(.-)%s*$&amp;#039; ) ~= &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.table(frame)&lt;br /&gt;
	local args = (frame.args[3] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	local entries = {}&lt;br /&gt;
	local colclass = {}&lt;br /&gt;
	local colstyle = {}&lt;br /&gt;
	local cols = tonumber(args[&amp;#039;cols&amp;#039;]) or 2&lt;br /&gt;
&lt;br /&gt;
	-- create the root table&lt;br /&gt;
	local root = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	-- add table style for fullwidth&lt;br /&gt;
	if isnotempty(args[&amp;#039;fullwidth&amp;#039;]) then&lt;br /&gt;
		root&lt;br /&gt;
			:css(&amp;#039;width&amp;#039;, &amp;#039;100%&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-collapse&amp;#039;, &amp;#039;collapse&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-spacing&amp;#039;, &amp;#039;0px 0px&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- add table classes&lt;br /&gt;
	if isnotempty(args[&amp;#039;class&amp;#039;]) then&lt;br /&gt;
		root:addClass(args[&amp;#039;class&amp;#039;])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- add table style&lt;br /&gt;
	if isnotempty(args[&amp;#039;style&amp;#039;]) then&lt;br /&gt;
		root:cssText(args[&amp;#039;style&amp;#039;])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- build arrays with the column styles and classes&lt;br /&gt;
	if isnotempty(args[&amp;#039;leftright&amp;#039;]) then&lt;br /&gt;
		colstyle[1] = &amp;#039;text-align:left;&amp;#039;&lt;br /&gt;
		colstyle[2] = &amp;#039;text-align:right;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if isnotempty(args[&amp;#039;rightleft&amp;#039;]) then&lt;br /&gt;
		colstyle[1] = &amp;#039;text-align:right;&amp;#039;&lt;br /&gt;
		colstyle[2] = &amp;#039;text-align:left;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	for i = 1,cols do&lt;br /&gt;
		colclass[ i ] = colclass[ i ] or &amp;#039;&amp;#039;&lt;br /&gt;
		colstyle[ i ] = colstyle[ i ] or &amp;#039;&amp;#039;&lt;br /&gt;
		if isnotempty(args[&amp;#039;colstyle&amp;#039;]) then&lt;br /&gt;
			colstyle[ i ] = args[&amp;#039;colstyle&amp;#039;] .. &amp;#039;;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		end&lt;br /&gt;
		if isnotempty(args[&amp;#039;colalign&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;text-align:&amp;#039; .. args[&amp;#039;colalign&amp;#039; .. tostring(i)] .. &amp;#039;;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;align&amp;#039;]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;text-align:&amp;#039; .. args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;align&amp;#039;] .. &amp;#039;;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;align&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;text-align:&amp;#039; .. args[&amp;#039;align&amp;#039; .. tostring(i)] .. &amp;#039;;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		end&lt;br /&gt;
		if isnotempty(args[&amp;#039;colnowrap&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;white-space:nowrap;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;nowrap&amp;#039;]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;white-space:nowrap;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;nowrap&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;white-space:nowrap;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		end&lt;br /&gt;
		if isnotempty(args[&amp;#039;colwidth&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;width:&amp;#039; .. args[&amp;#039;colwidth&amp;#039; .. tostring(i)] .. &amp;#039;;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;width&amp;#039;]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;width:&amp;#039; .. args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;width&amp;#039;] .. &amp;#039;;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;colwidth&amp;#039;]) then&lt;br /&gt;
			colstyle[ i ] = &amp;#039;width:&amp;#039; .. args[&amp;#039;colwidth&amp;#039;] .. &amp;#039;;&amp;#039; .. colstyle[ i ]&lt;br /&gt;
		end&lt;br /&gt;
		if isnotempty(args[&amp;#039;colstyle&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colstyle[ i ] = colstyle[ i ] .. args[&amp;#039;colstyle&amp;#039; .. tostring(i)]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;style&amp;#039;]) then&lt;br /&gt;
			colstyle[ i ] = colstyle[ i ] .. args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;style&amp;#039;]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;style&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colstyle[ i ] = colstyle[ i ] .. args[&amp;#039;style&amp;#039; .. tostring(i)]&lt;br /&gt;
		end&lt;br /&gt;
		if isnotempty(args[&amp;#039;colclass&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colclass[ i ] =  args[&amp;#039;colclass&amp;#039; .. tostring(i)]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;class&amp;#039;]) then&lt;br /&gt;
			colclass[ i ] =  args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;class&amp;#039;]&lt;br /&gt;
		elseif isnotempty(args[&amp;#039;class&amp;#039; .. tostring(i)]) then&lt;br /&gt;
			colclass[ i ] =  args[&amp;#039;class&amp;#039; .. tostring(i)]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- compute the maximum cell index&lt;br /&gt;
	local cellcount = 0&lt;br /&gt;
	for k, v in pairs( args ) do&lt;br /&gt;
		if type( k ) == &amp;#039;number&amp;#039; then&lt;br /&gt;
			cellcount = math.max(cellcount, k)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- compute the number of rows&lt;br /&gt;
	local rows = math.ceil(cellcount / cols)&lt;br /&gt;
&lt;br /&gt;
	-- build the table content&lt;br /&gt;
	if isnotempty(args[&amp;#039;title&amp;#039;]) then&lt;br /&gt;
		local caption = root:tag(&amp;#039;caption&amp;#039;)&lt;br /&gt;
		caption:cssText(args[&amp;#039;titlestyle&amp;#039;])&lt;br /&gt;
		caption:wikitext(args[&amp;#039;title&amp;#039;])&lt;br /&gt;
	end&lt;br /&gt;
	if isnotempty(args[&amp;#039;above&amp;#039;]) then&lt;br /&gt;
		local row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		local cell = row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		cell:attr(&amp;#039;colspan&amp;#039;, cols)&lt;br /&gt;
		cell:cssText(args[&amp;#039;abovestyle&amp;#039;])&lt;br /&gt;
		cell:wikitext(args[&amp;#039;above&amp;#039;])&lt;br /&gt;
	end&lt;br /&gt;
	for j=1,rows do&lt;br /&gt;
		-- start a new row&lt;br /&gt;
		local row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		if isnotempty(args[&amp;#039;rowstyle&amp;#039;]) then&lt;br /&gt;
			row:cssText(args[&amp;#039;rowstyle&amp;#039;])&lt;br /&gt;
		else&lt;br /&gt;
			row:css(&amp;#039;vertical-align&amp;#039;, &amp;#039;top&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		if isnotempty(args[&amp;#039;rowclass&amp;#039;]) then&lt;br /&gt;
			row:addClass(args[&amp;#039;rowclass&amp;#039;])&lt;br /&gt;
		end&lt;br /&gt;
		-- loop over the cells in the row&lt;br /&gt;
		for i=1,cols do&lt;br /&gt;
			local cell&lt;br /&gt;
			if isnotempty(args[&amp;#039;row&amp;#039; .. tostring(j) .. &amp;#039;header&amp;#039;]) then&lt;br /&gt;
				cell = row:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;scope&amp;#039;,&amp;#039;col&amp;#039;)&lt;br /&gt;
			elseif isnotempty(args[&amp;#039;col&amp;#039; .. tostring(i) .. &amp;#039;header&amp;#039;]) then&lt;br /&gt;
				cell = row:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;scope&amp;#039;,&amp;#039;row&amp;#039;)&lt;br /&gt;
			else&lt;br /&gt;
				cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			end&lt;br /&gt;
			if args[&amp;#039;class&amp;#039; .. tostring(j) .. &amp;#039;.&amp;#039; .. tostring(i)] then&lt;br /&gt;
				cell:addClass(args[&amp;#039;class&amp;#039; .. tostring(j) .. &amp;#039;.&amp;#039; .. tostring(i)])&lt;br /&gt;
			else&lt;br /&gt;
				if args[&amp;#039;rowclass&amp;#039; .. tostring(j)] then&lt;br /&gt;
					cell:addClass(args[&amp;#039;rowclass&amp;#039; .. tostring(j)])&lt;br /&gt;
				elseif args[&amp;#039;row&amp;#039; .. tostring(j) .. &amp;#039;class&amp;#039;] then&lt;br /&gt;
					cell:addClass(args[&amp;#039;row&amp;#039; .. tostring(j) .. &amp;#039;class&amp;#039;])&lt;br /&gt;
				elseif args[&amp;#039;rowevenclass&amp;#039;] and math.fmod(j,2) == 0 then&lt;br /&gt;
					cell:addClass(args[&amp;#039;rowevenclass&amp;#039;])&lt;br /&gt;
				elseif args[&amp;#039;rowoddclass&amp;#039;] and math.fmod(j,2) == 1 then	&lt;br /&gt;
					cell:addClass(args[&amp;#039;rowoddclass&amp;#039;])&lt;br /&gt;
				end&lt;br /&gt;
				if colclass[i] ~= &amp;#039;&amp;#039; then&lt;br /&gt;
					cell:addClass(colclass[i])&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if args[&amp;#039;style&amp;#039; .. tostring(j) .. &amp;#039;.&amp;#039; .. tostring(i)] then&lt;br /&gt;
				cell:cssText(args[&amp;#039;style&amp;#039; .. tostring(j) .. &amp;#039;.&amp;#039; .. tostring(i)])&lt;br /&gt;
			else&lt;br /&gt;
				if args[&amp;#039;rowstyle&amp;#039; .. tostring(j)] then&lt;br /&gt;
					cell:cssText(args[&amp;#039;rowstyle&amp;#039; .. tostring(j)])&lt;br /&gt;
				elseif args[&amp;#039;rowevenstyle&amp;#039;] and math.fmod(j,2) == 0 then&lt;br /&gt;
					cell:cssText(args[&amp;#039;rowevenstyle&amp;#039;])&lt;br /&gt;
				elseif args[&amp;#039;rowoddstyle&amp;#039;] and math.fmod(j,2) == 1 then	&lt;br /&gt;
					cell:cssText(args[&amp;#039;rowoddstyle&amp;#039;])&lt;br /&gt;
				elseif args[&amp;#039;row&amp;#039; .. tostring(j) .. &amp;#039;style&amp;#039;] then&lt;br /&gt;
					cell:cssText(args[&amp;#039;row&amp;#039; .. tostring(j) .. &amp;#039;style&amp;#039;])&lt;br /&gt;
				end&lt;br /&gt;
				if isnotempty(colstyle[i]) then&lt;br /&gt;
					cell:cssText(colstyle[i])&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			cell:wikitext(mw.ustring.gsub(args[cols*(j - 1) + i] or &amp;#039;&amp;#039;, &amp;#039;^(.-)%s*$&amp;#039;, &amp;#039;%1&amp;#039;) or &amp;#039;&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- return the root table&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>&gt;Plastikspork</name></author>
	</entry>
</feed>