Anda dapat membuat halaman dokumentasi untuk buat pada modul Scribunto ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
localp={} -- Transclude randomly selected "Did you know?" entries functionp.main(frame) -- args = { 1,2,... = page names, paragraphs = list e.g. "1,3-5", files = list, more = text} localargs={}-- args[k] = frame.args[k] or frame:getParent().args[k] for all k in either (numeric or not) fork,vinpairs(frame:getParent().args)doargs[k]=vend fork,vinpairs(frame.args)doargs[k]=vend-- args from a Lua call have priority over parent args from template -- Read the input page localpage=args[1]orerror("No page name given") localtitle=mw.title.new(page)orerror("Missing input page "..page) localtext=title:getContent()orerror("No content for page "..page) -- Limit to the DYK section if present localsectionstart=mw.ustring.find(text,"\n==''Tahukah Anda?'' articles==",1,true) ifsectionstartthen localsectionend=mw.ustring.find(text,"\n==",sectionstart+1,true)or-1 text=mw.ustring.sub(text,sectionstart,sectionend) end -- Parse the entries entries={} forentryinmw.ustring.gmatch(text,"\n%*[.…%s]*([^\n]+)")do ifnotmw.ustring.find(entry,"article's talk page missing blurb",1,true)then table.insert(entries,entry) end end -- Swap some random entries into the first n positions localn=math.min(#entries,args.countor10)-- the number of entries to produce math.randomseed(os.time()) fori=1,ndo j=math.random(i,#entries) entries[i],entries[j]="*... "..entries[j],entries[i] end -- Return the first n entries text=table.concat(entries,"\n",1,n) returnframe:preprocess(text) end returnp