require('strict')local p = local horizontal = require('Module:List').horizontallocal start =
local close =
local function make_TOC_item(anchor, link_text) link_text = link_text or anchor return ("%s"):format(anchor, link_text)end
local Array_mt = local function Array return setmetatable(Array_mt)end
function p.make_TOC(frame) local content = mw.title.getCurrentTitle:getContent if not content then error "The current page has no content" end local letters = Array -- Find uppermost headers containing a single ASCII letter. for letter in content:gmatch "%f[^\n]
%f[^=]" do letter = letter:upper letters:insert(make_TOC_item(letter)) end local yesno = require('Module:Yesno') local rest = Array local other_headers = require('Module:TableTools').listToSet for header in content:gmatch "%f[^\n]
%f[^=]" do if other_headers[header] then rest:insert(make_TOC_item(header)) end end return start .. horizontal(letters) .. horizontal(rest) .. closeend
return p