Module:TOC

local p = {}

local utilsArg = require("Module:UtilsArg")

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates.TOC) if err then return ""..err.categoryText end local modifier = "" if args.horizontal then modifier = "horizontal-"..args.horizontal elseif args.limit then modifier = "limit-"..args.limit else return "" end local html = mw.html.create("div") :addClass("zw-toc zw-toc--"..modifier) :wikitext("") return html end

p.Templates = { ["TOC"] = { wip = true, purpose = "Customizes the ", categories = {"Formatting Templates"}, usage = "Place the following where you wish the table of contents to be generated:", boilerplate = { tabs = { {					label = "No Parameters", desc = "This template can be used without parameters simply to change the location of the table of contents.", params = {}, },				{					label = "Limit", params = {"limit"}, },				{					label = "Horizontal", params = {"horizontal"}, },			}		},		params = { limit = { type = "number", desc = "Sets a maximum heading level. Any subheadings beyond this level are hidden.", enum = {2, 3, 4, 5}, trim = true, nilIfEmpty = true, },			horizontal = { type = "number", desc = "Headings at the specified level are laid out horizontally in the table of contents. Any headings beyond that level are hidden regardless of the  setting.", enum = {2, 3, 4, 5, 6}, trim = true, nilIfEmpty = true, },		}	} }

return p