Module:TOC: Difference between revisions

From ProleWiki, the proletarian encyclopedia
m (Added return function)
m (Replaced uncalled "title" for "args.title" to parse directly from input)
Line 9: Line 9:
:addClass('toctitle')
:addClass('toctitle')
:tag('big')
:tag('big')
:wikitext(title)
:wikitext(args.title)
end
end
local rowNums = {}
local rowNums = {}

Revision as of 13:57, 22 June 2022

local p = {}
function p.toc( frame )
	local args = frame:getParent().args
	local root = mw.html.create()
	root = root:tag('div')
	root:addClass('template-toc')
	if args.title then
		root:tag('div')
		:addClass('toctitle')
		:tag('big')
		:wikitext(args.title)
	end
	local rowNums = {}
	for k,v in pairs(args) do
		local num = k:match('^heading(%d+)$') or k:match('^content(%d+)$')
		if num then table.insert(rowNums, tonumber(num))
		end
	end
	return tostring(root)
end
return p