Module:Headless TOC

From Nordic Larp Wiki
Revision as of 15:02, 29 December 2018 by Johannes Axner (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Headless TOC/doc

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