localgetArgs=require('Module:Arguments').getArgslocalyesno=require('Module:Yesno')localcompressSparseArray=require('Module:TableTools').compressSparseArraylocalp={}localfunctionadd_anchor(anchor,text,visible)localresult=mw.html.create('span'):attr('id',anchor):wikitext(text)ifvisiblethenresult:addClass('highlight-target')endreturntostring(result)endlocalfunctionunpack(...)localframe=...localargsiftype(frame.args)=='table'thenargs=getArgs(frame)elseiftype(frame)=='table'thenargs=frameelseargs={...}endreturnargsendfunctionp.main(...)localargs=unpack(...)localanchors=compressSparseArray(args)localtextlocalvisible=yesno(args.visibleorargs.v)ifvisiblethentext=args.textorargs['текст']orargs[1]endlocalresult=textfori,vinipairs(anchors)doresult=add_anchor(anchors[i],result,visible)--[[ создание старого вида якорей для совместимости, см. Обсуждение шаблона:Якорь#Новые html5 ссылки и старые ]]localencoded_anchor=mw.uri.encode(anchors[i],'WIKI'):gsub('%%','.')ifanchors[i]~=encoded_anchorthenresult=add_anchor(encoded_anchor,result,visible)endendreturnresultendreturnp