본문으로 이동

모듈:Main

위키백과, 우리 모두의 백과사전.

--[[
-- This module produces a link to a main article or articles. It implements the
-- template {{main}}.
--
-- If the module is used in category or category talk space, it produces "The
-- main article for this category is xxx ". Otherwise, it produces
-- "Main article: xxx".
--]]

localmHatnote=require('Module:Hatnote')
localmHatlist=require('Module:Hatnote list')
localmArguments-- lazily initialise
localp={}

functionp.main(frame)
mArguments=require('Module:Arguments')
localargs=mArguments.getArgs(frame,{parentOnly=true})
localpages={}
fork,vinpairs(args)do
iftype(k)=='number'then
localdisplay=args['label '..k]orargs['l'..k]
localpage=displayand
string.format('%s|%s',string.gsub(v,'|.*$',''),display)orv
pages[#pages+1]=page
end
end
if#pages==0andmw.title.getCurrentTitle().namespace==0then
returnmHatnote.makeWikitextError(
'문서 이름이 지정되지 않았음',
'틀:본문#오류',
args.category
)
end
localoptions={
selfref=args.selfref
}
returnp._main(pages,options)
end

functionp._main(args,options)
-- Get the list of pages. If no first page was specified we use the current
-- page name.
localcurrentTitle=mw.title.getCurrentTitle()
if#args==0thenargs={currentTitle.text}end
localfirstPage=string.gsub(args[1],'|.*$','')
-- Make the formatted link text
list=mHatlist.andList(args,true)
-- Build the text.
localmainForm
localcurNs=currentTitle.namespace
if(curNs==14)or(curNs==15)then--category/talk namespaces
mainForm='이 [[위키백과:분류|분류]]의 본문은 %s입니다.'
else
mainForm='이 부분의 본문은 %s입니다.'
end
mainForm="[[파일:Icons8 flat search.svg|18px|링크=|alt=]]"..mainForm
localtext=string.format(mainForm,list)
-- Process the options and pass the text to the _rellink function in
-- [[Module:Hatnote]].
options=optionsor{}
localhnOptions={
selfref=options.selfref
}
returnmHatnote._hatnote(text,hnOptions)
end

returnp