<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.agency/index.php?action=history&amp;feed=atom&amp;title=Module%3AHistorical_populations</id>
		<title>Module:Historical populations - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.agency/index.php?action=history&amp;feed=atom&amp;title=Module%3AHistorical_populations"/>
		<link rel="alternate" type="text/html" href="https://wiki.agency/index.php?title=Module:Historical_populations&amp;action=history"/>
		<updated>2026-05-01T21:24:31Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.1</generator>

	<entry>
		<id>https://wiki.agency/index.php?title=Module:Historical_populations&amp;diff=7824&amp;oldid=prev</id>
		<title>Admin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.agency/index.php?title=Module:Historical_populations&amp;diff=7824&amp;oldid=prev"/>
				<updated>2018-11-04T20:08:41Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 20:08, 4 November 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.agency/index.php?title=Module:Historical_populations&amp;diff=7823&amp;oldid=prev</id>
		<title>Frietjes: add optional year_style, pop_style, pct_style and optional percentages=monthly for monthly growth rates</title>
		<link rel="alternate" type="text/html" href="https://wiki.agency/index.php?title=Module:Historical_populations&amp;diff=7823&amp;oldid=prev"/>
				<updated>2018-10-30T15:04:17Z</updated>
		
		<summary type="html">&lt;p&gt;add optional year_style, pop_style, pct_style and optional percentages=monthly for monthly growth rates&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--&lt;br /&gt;
-- This template implements {{Historical populations}}&lt;br /&gt;
--&lt;br /&gt;
local p = {}&lt;br /&gt;
local lang = mw.getContentLanguage()&lt;br /&gt;
local Date -- lazy initialization&lt;br /&gt;
&lt;br /&gt;
local function ifexist(page)&lt;br /&gt;
    if not page then return false end&lt;br /&gt;
    if mw.title.new(page).exists then return true end&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function isempty( s )&lt;br /&gt;
	return not s or s:match( &amp;#039;^%s*(.-)%s*$&amp;#039; ) == &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function splitnumandref( s )&lt;br /&gt;
	s = s:match( &amp;#039;^%s*(.-)%s*$&amp;#039; )&lt;br /&gt;
	local t1 = mw.text.unstrip(s)&lt;br /&gt;
        local t2 = s:match( &amp;#039;^([%d][%d,]*)&amp;#039; )&lt;br /&gt;
	if( t1 == t2 ) then&lt;br /&gt;
		local t3 = s:match( &amp;#039;^[%d][%d,]*(.-)$&amp;#039; )&lt;br /&gt;
		return t1, t3&lt;br /&gt;
	else&lt;br /&gt;
		return s, &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatnumR(num)&lt;br /&gt;
	return tonumber(lang:parseFormattedNumber(num))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatnum(num)&lt;br /&gt;
	return lang:parseFormattedNumber(num) and lang:formatNum(lang:parseFormattedNumber(num)) or num&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- this function creates an array with the {year, population, percent change}&lt;br /&gt;
local function getpoprow(year, popstr, pyear, ppopstr, linktype, percentages, current_year)&lt;br /&gt;
	local pop, popref = splitnumandref( popstr or &amp;#039;&amp;#039;)&lt;br /&gt;
	local ppop, ppopref = splitnumandref( ppopstr or &amp;#039;&amp;#039;)&lt;br /&gt;
	local percent = &amp;#039;&amp;#039;&lt;br /&gt;
	local yearnum = formatnumR(mw.ustring.gsub(year or &amp;#039;&amp;#039;, &amp;#039;^%s*([%d][%d][%.%d]+).*$&amp;#039;, &amp;#039;%1&amp;#039;) or &amp;#039;&amp;#039;)&lt;br /&gt;
	local pyearnum = formatnumR(mw.ustring.gsub(pyear or &amp;#039;&amp;#039;, &amp;#039;^%s*([%d][%d][%.%d]+).*$&amp;#039;, &amp;#039;%1&amp;#039;) or &amp;#039;&amp;#039;)&lt;br /&gt;
	local popnum = formatnumR(pop)&lt;br /&gt;
	local ppopnum = formatnumR(ppop)&lt;br /&gt;
	if( linktype == &amp;#039;US&amp;#039; or linktype == &amp;#039;USA&amp;#039; ) then&lt;br /&gt;
		if( (yearnum or 0) &amp;gt;= 1790 and yearnum &amp;lt;= current_year and math.fmod(math.floor(yearnum), 10) == 0) then&lt;br /&gt;
			if( yearnum &amp;lt; current_year ) then&lt;br /&gt;
				year = &amp;#039;[[&amp;#039; .. tostring(yearnum) .. &amp;#039; United States Census|&amp;#039; .. year .. &amp;#039;]]&amp;#039;&lt;br /&gt;
  			elseif( ifexist(tostring(yearnum) .. &amp;#039; United States Census&amp;#039;) ) then&lt;br /&gt;
				year = &amp;#039;[[&amp;#039; .. tostring(yearnum) .. &amp;#039; United States Census|&amp;#039; .. year .. &amp;#039;]]&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if(percentages ~= &amp;#039;off&amp;#039;) then&lt;br /&gt;
		local pstr = &amp;#039;—&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;#039;&lt;br /&gt;
		if(popnum ~= nil and ppopnum ~= nil and (ppopnum &amp;gt; 0)) then&lt;br /&gt;
			if(percentages == &amp;#039;pagr&amp;#039;) then&lt;br /&gt;
				pstr = mw.ustring.format(&amp;#039;%.2f&amp;#039;, 100*math.abs(math.pow(popnum/ppopnum,1/(yearnum-pyearnum)) - 1))&lt;br /&gt;
			elseif(percentages == &amp;#039;monthly&amp;#039;) then&lt;br /&gt;
				if Date == nil then Date = require(&amp;#039;Module:Date&amp;#039;)._Date end&lt;br /&gt;
				local date1 = Date(year)&lt;br /&gt;
				local date2 = Date(pyear)&lt;br /&gt;
				local diff = date1 - date2&lt;br /&gt;
				local months = (diff.age_days/(365.25/12))&lt;br /&gt;
				pstr = mw.ustring.format(&amp;#039;%.2f&amp;#039;, 100*math.abs(math.pow(popnum/ppopnum,1/months) - 1))&lt;br /&gt;
			else&lt;br /&gt;
				pstr = mw.ustring.format(&amp;#039;%.1f&amp;#039;, 100*math.abs(popnum/ppopnum - 1))&lt;br /&gt;
			end&lt;br /&gt;
			if( popnum &amp;lt; ppopnum ) then&lt;br /&gt;
				pstr = &amp;#039;−&amp;#039; .. pstr .. &amp;#039;%&amp;#039;&lt;br /&gt;
			else&lt;br /&gt;
				pstr = &amp;#039;+&amp;#039; .. pstr .. &amp;#039;%&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		elseif(popnum ~= nil and ppopnum ~= nil and (ppopnum == popnum)) then&lt;br /&gt;
			pstr = mw.ustring.format(&amp;#039;%.2f&amp;#039;, 0) .. &amp;#039;%&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		percent = pstr&lt;br /&gt;
	end&lt;br /&gt;
	-- strip the fractional part of the year, if there is one&lt;br /&gt;
	year = mw.ustring.gsub(year or &amp;#039;&amp;#039;, &amp;#039;^%s*([%d][%d][%d]+)%.[%d]*&amp;#039;, &amp;#039;%1&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	return {year, formatnum(pop) .. popref, percent }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- this function creates an array with table header labels&lt;br /&gt;
local function getheadrow(percentages, popname, yearname, percentname)&lt;br /&gt;
	-- year cell	&lt;br /&gt;
	if(yearname == &amp;#039;&amp;#039;) then&lt;br /&gt;
		yearname = &amp;#039;Year&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	-- population cell&lt;br /&gt;
	if(popname == &amp;#039;&amp;#039;) then&lt;br /&gt;
		popname = &amp;#039;&amp;lt;abbr title=&amp;quot;Population&amp;quot;&amp;gt;Pop.&amp;lt;/abbr&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- percentages cell&lt;br /&gt;
	if( percentages ~= &amp;#039;off&amp;#039; and percentname == &amp;#039;&amp;#039;) then&lt;br /&gt;
		if( percentages == &amp;#039;pagr&amp;#039; ) then&lt;br /&gt;
			percentname = &amp;#039;&amp;lt;abbr title=&amp;quot;Per annum growth rate&amp;quot;&amp;gt;±% p.a.&amp;lt;/abbr&amp;gt;&amp;#039;&lt;br /&gt;
		elseif( percentages == &amp;#039;monthly&amp;#039; ) then&lt;br /&gt;
			percentname = &amp;#039;&amp;lt;abbr title=&amp;quot;Per month growth rate&amp;quot;&amp;gt;±% p.m.&amp;lt;/abbr&amp;gt;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			percentname = &amp;#039;&amp;lt;abbr title=&amp;quot;Percent change&amp;quot;&amp;gt;±%&amp;lt;/abbr&amp;gt;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return {yearname, popname, percentname}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- this function renders the population table in a vertical format&lt;br /&gt;
local function rendervertical(data, head, title, footnote, alignfn, class, style, width, shading, percol, cols)&lt;br /&gt;
	-- define a couple helper functions&lt;br /&gt;
	local function addrowcell(trow, tag, text, align, shading, style)&lt;br /&gt;
		cell = trow:tag(tag)&lt;br /&gt;
		cell&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, align)&lt;br /&gt;
			:css(&amp;#039;padding&amp;#039;, &amp;#039;1px&amp;#039;)&lt;br /&gt;
			:wikitext(text)&lt;br /&gt;
			:css(&amp;#039;border-bottom&amp;#039;, shading ~= &amp;#039;off&amp;#039; and &amp;#039;1px solid #bbbbbb&amp;#039; or nil)&lt;br /&gt;
			:cssText(style)&lt;br /&gt;
	end&lt;br /&gt;
	local function addheadcell(trow, text, align, width, pad)&lt;br /&gt;
		cell = trow:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		cell&lt;br /&gt;
			:css(&amp;#039;border-bottom&amp;#039;, &amp;#039;1px solid black&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;padding&amp;#039;, pad and (&amp;#039;1px &amp;#039; .. pad) or &amp;#039;1px&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, align)&lt;br /&gt;
			:css(&amp;#039;width&amp;#039;, width)&lt;br /&gt;
			:wikitext(text)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local colspan = 3&lt;br /&gt;
	local yearcount = #data&lt;br /&gt;
	local argcount = 2*yearcount&lt;br /&gt;
	&lt;br /&gt;
	if( isempty(width) ) then&lt;br /&gt;
		width = &amp;#039;15em&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- override the value of cols if percol has been specified&lt;br /&gt;
	if( percol &amp;gt; 0 ) then&lt;br /&gt;
		cols = math.floor( (yearcount - 1) / percol ) + 1&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- compute the number of rows per col&lt;br /&gt;
	local rowspercol = math.floor( (yearcount - 1) / cols ) + 1&lt;br /&gt;
&lt;br /&gt;
	-- specify the colspan for the title and footer lines&lt;br /&gt;
	if( cols &amp;gt; 1 ) then&lt;br /&gt;
		colspan = cols&lt;br /&gt;
	else&lt;br /&gt;
		if (head[3] == &amp;#039;&amp;#039;) then &lt;br /&gt;
			colspan = 2&lt;br /&gt;
		else&lt;br /&gt;
			colspan = 3&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- compute outer table width&lt;br /&gt;
	local twidth = width&lt;br /&gt;
	if( (cols &amp;gt; 1) and width:match(&amp;#039;^%s*[%d]+[%w]+%s*$&amp;#039;) ) then&lt;br /&gt;
		local widthnum = mw.ustring.gsub( width, &amp;#039;^%s*([%d]+)([%w]+)%s*$&amp;#039;, &amp;#039;%1&amp;#039; )&lt;br /&gt;
		local widthunit = mw.ustring.gsub( width, &amp;#039;^%s*([%d]+)([%w]+)%s*$&amp;#039;, &amp;#039;%2&amp;#039; )&lt;br /&gt;
		twidth = tostring(widthnum*cols) .. widthunit&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- create the outer table&lt;br /&gt;
	local root = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
	root&lt;br /&gt;
		:addClass(class)&lt;br /&gt;
		:css(&amp;#039;width&amp;#039;, twidth)&lt;br /&gt;
		:cssText(style[&amp;#039;table&amp;#039;])&lt;br /&gt;
	-- add title&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&lt;br /&gt;
		:addClass(&amp;#039;navbox-title&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;colspan&amp;#039;, colspan)&lt;br /&gt;
		:css(&amp;#039;padding&amp;#039;, &amp;#039;0.25em&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;font-size&amp;#039;, &amp;#039;110%&amp;#039;)&lt;br /&gt;
		:wikitext(title)&lt;br /&gt;
	&lt;br /&gt;
	-- loop over columns and rows within columns&lt;br /&gt;
	local offset = 1&lt;br /&gt;
	local t = root&lt;br /&gt;
	for c = 1,cols do&lt;br /&gt;
		-- add inner tables if we are rendering more than one column&lt;br /&gt;
		if( cols &amp;gt; 1) then&lt;br /&gt;
			if (c == 1) then&lt;br /&gt;
				row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
				row:attr(&amp;#039;valign&amp;#039;, &amp;#039;top&amp;#039;)&lt;br /&gt;
				cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				cell:css(&amp;#039;padding&amp;#039;, &amp;#039;0 0.5em&amp;#039;)&lt;br /&gt;
			else&lt;br /&gt;
				cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				cell&lt;br /&gt;
					:css(&amp;#039;padding&amp;#039;, &amp;#039;0 0.5em&amp;#039;)&lt;br /&gt;
					:css(&amp;#039;border-left&amp;#039;, &amp;#039;solid 1px #aaa&amp;#039;)&lt;br /&gt;
			end&lt;br /&gt;
			t = cell:tag(&amp;#039;table&amp;#039;)&lt;br /&gt;
			t&lt;br /&gt;
				:css(&amp;#039;border-spacing&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;width&amp;#039;, width)&lt;br /&gt;
		end&lt;br /&gt;
		-- start column headers&lt;br /&gt;
		local hrow = t:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		hrow:css(&amp;#039;font-size&amp;#039;, &amp;#039;95%&amp;#039;)&lt;br /&gt;
		-- year header&lt;br /&gt;
		addheadcell(hrow, head[1], nil, head[3] ~= &amp;#039;&amp;#039; and &amp;#039;3em&amp;#039; or &amp;#039;auto&amp;#039;, nil, nil)&lt;br /&gt;
		-- population header&lt;br /&gt;
		addheadcell(hrow, head[2], &amp;#039;right&amp;#039;, nil, &amp;#039;2px&amp;#039;)&lt;br /&gt;
		-- percentages header&lt;br /&gt;
		if( head[3] ~= &amp;#039;&amp;#039; ) then&lt;br /&gt;
			addheadcell(hrow, head[3], &amp;#039;right&amp;#039;, nil, nil)&lt;br /&gt;
		end&lt;br /&gt;
		-- end column headers&lt;br /&gt;
		-- start population rows&lt;br /&gt;
		for r = 1,rowspercol do&lt;br /&gt;
			-- generate the row if we have not exceeded the rowcount&lt;br /&gt;
			-- shade every fifth row, unless shading = off&lt;br /&gt;
			local s = &amp;#039;off&amp;#039;&lt;br /&gt;
			if( math.fmod((c - 1)*rowspercol + r, 5) == 0 and r ~= rowspercol) then&lt;br /&gt;
				s = shading&lt;br /&gt;
			end&lt;br /&gt;
			if(offset &amp;lt;= yearcount) then&lt;br /&gt;
				-- start population row&lt;br /&gt;
				local prow = t:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
				-- year cell&lt;br /&gt;
				addrowcell(prow, &amp;#039;th&amp;#039;, data[offset][1], &amp;#039;center&amp;#039;, s, style[&amp;#039;year&amp;#039;])&lt;br /&gt;
				-- population cell&lt;br /&gt;
				addrowcell(prow, &amp;#039;td&amp;#039;, data[offset][2], &amp;#039;right&amp;#039;, s, style[&amp;#039;pop&amp;#039;])&lt;br /&gt;
				-- percentage cell&lt;br /&gt;
				if( not isempty(head[3]) ) then&lt;br /&gt;
					addrowcell(prow, &amp;#039;td&amp;#039;, data[offset][3], &amp;#039;right&amp;#039;, s, style[&amp;#039;pct&amp;#039;])&lt;br /&gt;
				end&lt;br /&gt;
				-- end population row&lt;br /&gt;
				offset = offset + 1&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- add the footnote line 	&lt;br /&gt;
	if( footnote ~= &amp;#039;&amp;#039;) then&lt;br /&gt;
		row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
		cell&lt;br /&gt;
			:attr(&amp;#039;colspan&amp;#039;, colspan)&lt;br /&gt;
			:css(&amp;#039;border-top&amp;#039;, &amp;#039;1px solid black&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;font-size&amp;#039;, &amp;#039;85%&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, alignfn)&lt;br /&gt;
			:wikitext(footnote)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- this function renders the population table in a horizontal format&lt;br /&gt;
local function renderhorizontal(data, head, title, footnote, alignfn, class, style, width, shading, perrow, rows)&lt;br /&gt;
	local row&lt;br /&gt;
	local cell&lt;br /&gt;
	local yearcount = #data&lt;br /&gt;
	local argcount = 2*yearcount&lt;br /&gt;
	&lt;br /&gt;
	-- override the value of rows if perrow has been specified&lt;br /&gt;
	if( perrow &amp;gt; 0 ) then&lt;br /&gt;
		rows = math.floor( (yearcount - 1) / perrow ) + 1&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- compute the number of cols per row&lt;br /&gt;
	local colsperrow = math.floor( (yearcount - 1) / rows ) + 1&lt;br /&gt;
&lt;br /&gt;
	-- create the outer table&lt;br /&gt;
	local root = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
	root&lt;br /&gt;
		:addClass(class)&lt;br /&gt;
		:css(&amp;#039;font-size&amp;#039;, &amp;#039;90%&amp;#039;)&lt;br /&gt;
		:cssText(style[&amp;#039;table&amp;#039;])&lt;br /&gt;
	-- create title row&lt;br /&gt;
	row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
	cell = row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
	cell&lt;br /&gt;
		:css(&amp;#039;padding&amp;#039;, &amp;#039;0.25em&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;font-size&amp;#039;, &amp;#039;110%&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;colspan&amp;#039;, colsperrow + 1)&lt;br /&gt;
		:wikitext(title)&lt;br /&gt;
&lt;br /&gt;
	-- loop over rows and columns within rows&lt;br /&gt;
	local offset = 1&lt;br /&gt;
	for r = 1,rows do&lt;br /&gt;
		local rowoffset = offset&lt;br /&gt;
		-- render the years&lt;br /&gt;
		row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		cell = row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		cell:wikitext(head[1])&lt;br /&gt;
			:css(&amp;#039;border-top&amp;#039;, r &amp;gt; 1 and &amp;#039;2px solid #000&amp;#039; or nil)&lt;br /&gt;
		for c = 1,colsperrow do&lt;br /&gt;
			cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			if(offset &amp;lt;= yearcount) then&lt;br /&gt;
				cell:wikitext(data[offset][1])&lt;br /&gt;
					:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
					:css(&amp;#039;border-top&amp;#039;, r &amp;gt; 1 and &amp;#039;2px solid #000&amp;#039; or nil)&lt;br /&gt;
					:cssText(style[&amp;#039;year&amp;#039;])&lt;br /&gt;
			else&lt;br /&gt;
				cell:css(&amp;#039;border-width&amp;#039;, r &amp;gt; 1 and &amp;#039;2px 0 0 0&amp;#039; or 0)&lt;br /&gt;
					:css(&amp;#039;border-top&amp;#039;, r &amp;gt; 1 and &amp;#039;2px solid #000&amp;#039; or nil)&lt;br /&gt;
			end&lt;br /&gt;
			offset = offset + 1&lt;br /&gt;
		end&lt;br /&gt;
		-- render the pop&lt;br /&gt;
		offset = rowoffset&lt;br /&gt;
		row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		cell = row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		cell:wikitext(head[2])&lt;br /&gt;
		for c = 1,colsperrow do&lt;br /&gt;
			cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			if(offset &amp;lt;= yearcount) then&lt;br /&gt;
				cell:wikitext(data[offset][2])&lt;br /&gt;
					:css(&amp;#039;text-align&amp;#039;, &amp;#039;right&amp;#039;)&lt;br /&gt;
					:css(&amp;#039;padding-right&amp;#039;, &amp;#039;2px&amp;#039;)&lt;br /&gt;
					:cssText(style[&amp;#039;pop&amp;#039;])&lt;br /&gt;
			else&lt;br /&gt;
				cell:css(&amp;#039;border-width&amp;#039;, 0)&lt;br /&gt;
			end&lt;br /&gt;
			offset = offset + 1&lt;br /&gt;
		end&lt;br /&gt;
		-- render the percentages&lt;br /&gt;
		if(head[3] ~= &amp;#039;&amp;#039;) then&lt;br /&gt;
			offset = rowoffset&lt;br /&gt;
			row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			cell = row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
			cell:wikitext(head[3])&lt;br /&gt;
			for c = 1,colsperrow do&lt;br /&gt;
				cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				if(offset &amp;lt;= yearcount) then&lt;br /&gt;
					cell:wikitext(data[offset][3])&lt;br /&gt;
						:css(&amp;#039;text-align&amp;#039;, &amp;#039;right&amp;#039;)&lt;br /&gt;
						:css(&amp;#039;padding-right&amp;#039;, &amp;#039;2px&amp;#039;)&lt;br /&gt;
						:cssText(style[&amp;#039;pct&amp;#039;])&lt;br /&gt;
				else&lt;br /&gt;
					cell:css(&amp;#039;border-width&amp;#039;, 0)&lt;br /&gt;
				end&lt;br /&gt;
				offset = offset + 1&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- add the footnote line 	&lt;br /&gt;
	if( footnote ~= &amp;#039;&amp;#039;) then&lt;br /&gt;
		row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
		cell&lt;br /&gt;
			:css(&amp;#039;border-top&amp;#039;, &amp;#039;2px solid black&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;font-size&amp;#039;, &amp;#039;85%&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, alignfn)&lt;br /&gt;
			:attr(&amp;#039;colspan&amp;#039;, colsperrow + 1)&lt;br /&gt;
			:wikitext(footnote)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- this is the main function&lt;br /&gt;
function p.poptable(frame)&lt;br /&gt;
	local data = {}&lt;br /&gt;
	local style = {}&lt;br /&gt;
	local args = frame.args[1] and frame.args or frame:getParent().args&lt;br /&gt;
&lt;br /&gt;
	local title			= args[&amp;#039;title&amp;#039;]			or &amp;#039;&amp;#039;&lt;br /&gt;
	local align			= args[&amp;#039;align&amp;#039;]			or &amp;#039;&amp;#039;&lt;br /&gt;
	local clear			= args[&amp;#039;clear&amp;#039;]			or &amp;#039;&amp;#039;&lt;br /&gt;
	local direction		= args[&amp;#039;direction&amp;#039;]		or &amp;#039;&amp;#039;&lt;br /&gt;
	local percentages	= args[&amp;#039;percentages&amp;#039;]	or &amp;#039;&amp;#039;&lt;br /&gt;
	local state			= args[&amp;#039;state&amp;#039;]			or &amp;#039;&amp;#039;&lt;br /&gt;
	local linktype		= args[&amp;#039;type&amp;#039;]			or &amp;#039;&amp;#039;&lt;br /&gt;
	local shading		= args[&amp;#039;shading&amp;#039;]		or &amp;#039;on&amp;#039;&lt;br /&gt;
	local width			= args[&amp;#039;width&amp;#039;]			or &amp;#039;&amp;#039;&lt;br /&gt;
	local subbox		= args[&amp;#039;subbox&amp;#039;]		or &amp;#039;&amp;#039;&lt;br /&gt;
	local popname		= args[&amp;#039;pop_name&amp;#039;]		or &amp;#039;&amp;#039;&lt;br /&gt;
	local yearname		= args[&amp;#039;year_name&amp;#039;]		or &amp;#039;&amp;#039;&lt;br /&gt;
	local percentname   = args[&amp;#039;percent_name&amp;#039;]  or &amp;#039;&amp;#039;&lt;br /&gt;
	local footnote		= args[&amp;#039;footnote&amp;#039;]		or &amp;#039;&amp;#039;&lt;br /&gt;
	local alignfn		= args[&amp;#039;align-fn&amp;#039;]		or &amp;#039;&amp;#039;&lt;br /&gt;
	local source		= args[&amp;#039;source&amp;#039;]		or &amp;#039;&amp;#039;&lt;br /&gt;
	local percol = tonumber(args[&amp;#039;percol&amp;#039;])	or 0&lt;br /&gt;
	local cols	 = tonumber(args[&amp;#039;cols&amp;#039;])	or 1&lt;br /&gt;
	local perrow = tonumber(args[&amp;#039;perrow&amp;#039;])	or 0&lt;br /&gt;
	local rows	 = tonumber(args[&amp;#039;rows&amp;#039;])	or 1&lt;br /&gt;
	style[&amp;#039;year&amp;#039;] = args[&amp;#039;year_style&amp;#039;]&lt;br /&gt;
	style[&amp;#039;pop&amp;#039;]  = args[&amp;#039;pop_style&amp;#039;]&lt;br /&gt;
	style[&amp;#039;pct&amp;#039;]  = args[&amp;#039;pct_style&amp;#039;]&lt;br /&gt;
&lt;br /&gt;
	-- setup classes and styling for outer table&lt;br /&gt;
	local class = direction == &amp;#039;horizontal&amp;#039; and &amp;#039;wikitable&amp;#039; or &amp;#039;toccolours&amp;#039;&lt;br /&gt;
	if( state == &amp;#039;collapsed&amp;#039; ) then&lt;br /&gt;
		class = class .. &amp;#039; collapsible collapsed&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if( isempty(title) ) then&lt;br /&gt;
		title = &amp;#039;Historical population&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if( isempty(align) ) then&lt;br /&gt;
		align = direction ~= &amp;#039;horizontal&amp;#039; and &amp;#039;right&amp;#039; or &amp;#039;center&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if( isempty(alignfn) ) then&lt;br /&gt;
		alignfn = &amp;#039;left&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if( isempty(clear) ) then&lt;br /&gt;
		clear = align == &amp;#039;center&amp;#039; and &amp;#039;&amp;#039; or align&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local margin = &amp;#039;0.5em 0 1em 0.5em&amp;#039;&lt;br /&gt;
	if( align == &amp;#039;left&amp;#039; ) then&lt;br /&gt;
		margin = &amp;#039;0.5em 1em 0.5em 0&amp;#039;&lt;br /&gt;
	elseif( align == &amp;#039;none&amp;#039; ) then&lt;br /&gt;
		margin = &amp;#039;0.5em 1em 0.5em 0&amp;#039;&lt;br /&gt;
	elseif( align == &amp;#039;center&amp;#039; ) then&lt;br /&gt;
		margin = &amp;#039;0.5em auto&amp;#039;&lt;br /&gt;
		align = &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if( isempty(subbox) ) then&lt;br /&gt;
		style[&amp;#039;table&amp;#039;] =&lt;br /&gt;
			&amp;#039;border-spacing: 0;&amp;#039; ..&lt;br /&gt;
			(align ~= &amp;#039;&amp;#039; and &amp;#039;float:&amp;#039; .. align .. &amp;#039;;&amp;#039; or &amp;#039;&amp;#039;) ..&lt;br /&gt;
			(clear ~= &amp;#039;&amp;#039; and &amp;#039;clear:&amp;#039; .. clear .. &amp;#039;;&amp;#039; or &amp;#039;&amp;#039;) ..&lt;br /&gt;
			&amp;#039;margin:&amp;#039; .. margin .. &amp;#039;;&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		style[&amp;#039;table&amp;#039;] =&lt;br /&gt;
			&amp;#039;margin:0;&amp;#039; ..&lt;br /&gt;
			&amp;#039;border-collapse:collapse;&amp;#039; ..&lt;br /&gt;
			&amp;#039;border:none;&amp;#039;&lt;br /&gt;
	end	&lt;br /&gt;
		&lt;br /&gt;
	-- setup the footer text&lt;br /&gt;
	if( source ~= &amp;#039;&amp;#039; ) then&lt;br /&gt;
		source = &amp;#039;Source: &amp;#039; .. source&lt;br /&gt;
		if( footnote ~= &amp;#039;&amp;#039; ) then&lt;br /&gt;
			footnote = footnote .. &amp;#039;&amp;lt;br/&amp;gt;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	footnote = footnote .. source&lt;br /&gt;
	&lt;br /&gt;
	-- setup the data header cols/rows&lt;br /&gt;
	local head = getheadrow(percentages, popname, yearname, percentname)&lt;br /&gt;
	&lt;br /&gt;
	-- count the total number of population rows&lt;br /&gt;
	local argcount = 0&lt;br /&gt;
	local rowcount = 0&lt;br /&gt;
	for k, v in pairs( args ) do&lt;br /&gt;
		if ( (type( k ) == &amp;#039;number&amp;#039;) and (not isempty(args[k])) ) then&lt;br /&gt;
			if( k &amp;gt;= 1 and math.floor(k) == k and k &amp;gt; argcount) then&lt;br /&gt;
				argcount = k&lt;br /&gt;
			end&lt;br /&gt;
			if( math.fmod(k - 1, 2) == 0 ) then&lt;br /&gt;
				rowcount = rowcount + 1&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- here is where we build all the data for the table&lt;br /&gt;
	-- loop over columns and rows within columns&lt;br /&gt;
	local pyear = &amp;#039;&amp;#039;&lt;br /&gt;
	local ppop = &amp;#039;&amp;#039;&lt;br /&gt;
	local offset = 1&lt;br /&gt;
	local current_year = tonumber(os.date(&amp;quot;%Y&amp;quot;, os.time()))&lt;br /&gt;
	for r = 1,rowcount do&lt;br /&gt;
		-- skip blank rows&lt;br /&gt;
		while(isempty(args[offset]) and offset &amp;lt;= argcount) do&lt;br /&gt;
			offset = offset + 2&lt;br /&gt;
		end&lt;br /&gt;
		-- generate the row if we have not exceeded the rowcount&lt;br /&gt;
		if(offset &amp;lt;= argcount) then&lt;br /&gt;
			table.insert(data, getpoprow(args[offset], args[offset + 1] or &amp;#039;&amp;#039;, pyear, ppop, &lt;br /&gt;
				linktype, percentages, current_year) )&lt;br /&gt;
			pyear = args[offset]&lt;br /&gt;
			ppop = args[offset+1] or &amp;#039;&amp;#039;&lt;br /&gt;
			offset = offset + 2&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- now that we have the data for the table, render it in the requested format&lt;br /&gt;
    if (direction == &amp;#039;horizontal&amp;#039;) then&lt;br /&gt;
		return renderhorizontal(data, head, title, footnote, alignfn, class, style, width, shading, perrow, rows)&lt;br /&gt;
	else&lt;br /&gt;
		return rendervertical(data, head, title, footnote, alignfn, class, style, width, shading, percol, cols)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Frietjes</name></author>	</entry>

	</feed>