Module:Headless TOC

From Constructed Worlds Wiki
Jump to navigation Jump to search
Wikipedia logo This page uses material from the Wikipedia page Module:Headless TOC, which is released under the Creative Commons Attribution-ShareAlike 3.0 Unported License (view authors).

local p = {}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {trim = false})
	if args[1] or args[2] then
		local toc = args[2] or args[1]
		for k = 1, (tonumber(args.depth) or 1) do
			toc = '=' .. toc .. '='
		end
		return '<div style="overflow:hidden;width:2px;height:2px;margin:-1px;display:inline-block;vertical-align:text-top;position:relative;top:-1em;">\n==' .. toc .. '==\n</div><div style="display:inline-block;margin:0;margin-left:-.625ex;">' .. (args[1] or '') .. '</div>'
	end
	return 'Missing arguments {{{1}}} and {{{2}}}'
end

return p