This table autonumbers hashtags in tables, as mediawiki does not do that automatically. This module takes in raw wikicode tables, autonumbers the hastags inside them and returns the result. This module only supports one html styling attribute, class for the whole table, other styling attributes are ignored.

{{#invoke:Autonumber|main}}



local p = {}

function p.main(frame)
	local args = frame.args
	
	local pos = {1}
	local count = 0
	local i = 1
	while args[i] ~= nil do
		pos[i] = string.find(args[i], "#", (pos[i] or 1)+1)
		if string.find(args[i], "#") then
			count = count + 1
		end
		args[i] = string.gsub(args[i], "#", count, 1)
		i = i + 1
	end
	table.insert(args, 2, "class=" .. args.class .. "\n")
	return table.concat(args, "|")
end

return p