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 toc = mw.html.create("div") :addClass("zw-toc") :wikitext("") if args.horizontal then toc:addClass("zw-toc--horizontal-"..args.horizontal) end if args.limit then toc:addClass("zw-toc--limit-"..args.limit) end if args.columns then toc:addClass("zw-toc--columns-"..args.columns) end return toc end

p.Templates = { ["TOC"] = { 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"}, },				{					label = "Columns", params = {"columns"}, },			},		},		paramOrder = {"limit", "horizontal", "columns"}, params = { columns = { type = "number", desc = "Sets a number of columns to use for the list of headings.", enum = {1, 2, 3, 4, 5}, trim = true, nilIfEmpty = true, },			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