Module:Elements

-- local p = {} local base = "Module:Elements/" local suffix local source local data

function rsort(a) local d = {} for _, n in ipairs(a) do table.insert(d, n) end table.sort(d) return d end

function getElementsFromList(name, frame) source = base .. name data = mw.loadData(source) local d = rsort(data) local l = #d local n = 9 local i = 1 local h = {} local r = {} local e = "" for i, v in ipairs(d) do       local idx = tonumber(i) if (i % n == 1) and (idx ~= 1) then table.insert(h, r)           r = {} i = 1 end table.insert(r, v)       if (idx == l) then table.insert(h, r) end i = i + 1 end for index, value in ipairs(h) do       local ul = mw.html.create("ul"):addClass("element-list") for j, val in ipairs(value) do           local li = mw.html.create("li"):addClass("element-item") local a = {} table.insert(a, mw.ustring.lower(val)) if (name == "void") then table.insert(a, "1") end li:wikitext( .. frame:expandTemplate{                title = "HTML tag",                args = a            } .. ) ul:node(li) end e = e..tostring(ul) end return e end

function p.void(frame) suffix = "void" return getElementsFromList(suffix, frame) end

function p.sectioning(frame) suffix = "sectioning" return getElementsFromList(suffix, frame) end

function p.grouping(frame) suffix = "grouping" return getElementsFromList(suffix, frame) end

function p.textLevel(frame) suffix = "textLevel" return getElementsFromList(suffix, frame) end

function p.interactive(frame) suffix = "interactive" return getElementsFromList(suffix, frame) end

function p.tables(frame) suffix = "table" return getElementsFromList(suffix, frame) end

function p.forms(frame) suffix = "form" return getElementsFromList(suffix, frame) end

function p.scripting(frame) suffix = "scripting" return getElementsFromList(suffix, frame) end

function p.deprecated(frame) suffix = "deprecated" return getElementsFromList(suffix, frame) end

function p.obsolete(frame) suffix = "obsolete" return getElementsFromList(suffix, frame) end

return p