-- This module implements {{cat main}}.localmHatnote=require('Module:Hatnote')localyesno=require('Module:Yesno')localmTableTools-- lazily initialiselocalmArguments-- lazily initialiselocalp={}functionp.catMain(frame)mTableTools=require('Module:TableTools')mArguments=require('Module:Arguments')localargs=mArguments.getArgs(frame,{wrappers='الگو:اصلی رده'})localpages=mTableTools.compressSparseArray(args)localoptions={article=args.article,selfref=args.selfref}returnp._catMain(options,unpack(pages))endfunctionp._catMain(options,...)options=optionsor{}-- Get the links table.locallinks=mHatnote.formatPages(...)ifnotlinks[1]thenlocalpage=mw.title.getCurrentTitle().textlinks[1]=mHatnote._formatLink{link=page}endfori,linkinipairs(links)dolinks[i]=string.format("'''%s'''",link)end-- Get the pagetype.localpagetypeifyesno(options.article)~=falsethenpagetype='مقاله'elsepagetype='صفحه'end-- Work out whether we need to be singular or plural.localstringToFormatif#links>1thenstringToFormat='%sهای اصلی این [[راهنما:رده|رده]] %s هستند.'elsestringToFormat='%sٔ اصلی این [[راهنما:رده|رده]] %s است.'end-- Get the text.localtext=string.format(stringToFormat,pagetype,mw.text.listToText(links))-- Pass it through to Module:Hatnote.localhnOptions={}hnOptions.selfref=options.selfrefhnOptions.extraclasses='relarticle mainarticle'returnmHatnote._hatnote(text,hnOptions)endreturnp