localp={}localhorizontal=require('Module:List').horizontallocalfunctionmake_TOC_item_linked(anchor,text)text=textoranchor-- if (frame.args.auto == "")return("[[#%s|%s]]"):format(anchor,text)endlocalfunctionmake_TOC_item_unlinked(anchor,text)text=textoranchorreturn("%s"):format(anchor,text)endlocalArray_mt={__index=table}localfunctionArray()returnsetmetatable({},Array_mt)endfunctionp.make_TOC(frame)localcontent=mw.title.getCurrentTitle():getContent()ifnotcontentthenerror"The current page has no content"endlocalletters=Array()-- Find uppermost headers containing a single ASCII letter.ifframe.args.auto:upper()=="LINK"then-- If we wanted them linked, do thatforletterincontent:gmatch"%f[^\n]==%s*(%a)%s*==%f[^=]"doletter=letter:upper()letters:insert(make_TOC_item_linked(letter))endelse-- f we do not want them linked, don'tforletterincontent:gmatch"%f[^\n]==%s*(%a)%s*==%f[^=]"doletter=letter:upper()letters:insert(make_TOC_item_unlinked(letter))endendreturnhorizontal(letters)..horizontal(rest)endreturnp