Rabu, 30 September 2026
06:37 WIB
TERKINI
Nasional Saksi Ungkap Penolakan Uang 1 Juta Dolar AS untuk Pansus Haji oleh Dua Tokoh Megapolitan Demo Buruh di DPR Lumpuhkan Gatot Subroto: Simak Jalur Alternatifnya Megapolitan Komunikasi Terputus Jadi Akar Tabrakan KA Argo Bromo Anggrek di Bekasi Regional KPU Batam Musnahkan Ribuan Surat Suara Rusak, Jaga Integritas Pemilu Regional Gagal Menulis Ulang: Konten Berita Tidak Memadai Way Kanan Kepala Toko Alfamart Way Kanan Diduga Gelapkan Rp141 Juta, Dua Pelaku Ditangkap Hiburan Lisa BLACKPINK Ukir Sejarah: Solois Asia Pertama Sabet Best Pop MTV VMAs 2026 Ekonomi Dan Bisnis Harga Emas Antam Turun Drastis Rp17 Ribu, Cek Daftar Lengkap 29 September 2026 Hiburan TXT Gegerkan Penggemar dengan Mini Album 'PERFECT STORM' dan Tur Dunia Termasuk Jakarta Berita Fenomena Unik 'Hujan Salju' di Lapangan Sempur Bogor, Warga Sambut Riang Nasional Saksi Ungkap Penolakan Uang 1 Juta Dolar AS untuk Pansus Haji oleh Dua Tokoh Megapolitan Demo Buruh di DPR Lumpuhkan Gatot Subroto: Simak Jalur Alternatifnya Megapolitan Komunikasi Terputus Jadi Akar Tabrakan KA Argo Bromo Anggrek di Bekasi Regional KPU Batam Musnahkan Ribuan Surat Suara Rusak, Jaga Integritas Pemilu Regional Gagal Menulis Ulang: Konten Berita Tidak Memadai Way Kanan Kepala Toko Alfamart Way Kanan Diduga Gelapkan Rp141 Juta, Dua Pelaku Ditangkap Hiburan Lisa BLACKPINK Ukir Sejarah: Solois Asia Pertama Sabet Best Pop MTV VMAs 2026 Ekonomi Dan Bisnis Harga Emas Antam Turun Drastis Rp17 Ribu, Cek Daftar Lengkap 29 September 2026 Hiburan TXT Gegerkan Penggemar dengan Mini Album 'PERFECT STORM' dan Tur Dunia Termasuk Jakarta Berita Fenomena Unik 'Hujan Salju' di Lapangan Sempur Bogor, Warga Sambut Riang

Modul:Hatnote list

Wikimedia module

Bagikan:
Dokumentasi modullihatsuntingriwayatsegarkan
WarningModul Lua ini digunakan pada sekitar 84.000 halaman dan perubahannya kemungkinan memicu perubahan massal pada semua halaman yang menggunakannya. Uji cobalah di subhalaman /bak pasir atau /kasus uji Modul:Hatnote list, atau bak pasir modul Anda. Pertimbangkan untuk mendiskusikan perubahan di halaman pembicaraan sebelum mengimplementasikannya.
Dokumentasi di atas ditransklusikan dari Modul:Hatnote list/doc. (sunting | riwayat)
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
--                           Module:Hatnote list                              --
--                                                                            --
-- This module produces and formats lists for use in hatnotes. In particular, --
-- it implements the for-see list, i.e. lists of "For X, see Y" statements,   --
-- as used in {{about}}, {{redirect}}, and their variants. Also introduced    --
-- are andList & orList helpers for formatting lists with those conjunctions. --
--------------------------------------------------------------------------------
localmArguments--initialize lazily
localmFormatLink=require('Module:Format link')
localmHatnote=require('Module:Hatnote')
locallibraryUtil=require('libraryUtil')
localcheckType=libraryUtil.checkType
localp={}
--------------------------------------------------------------------------------
-- List stringification helper functions
--
-- These functions are used for stringifying lists, usually page lists inside
-- the "Y" portion of "For X, see Y" for-see items.
--------------------------------------------------------------------------------
--default options table used across the list stringification functions
localstringifyListDefaultOptions={
conjunction="dan",
separator=",",
altSeparator=";",
space=" ",
formatted=false
}
--Searches display text only
localfunctionsearchDisp(haystack,needle)
returnstring.find(
string.sub(haystack,(string.find(haystack,'|')or0)+1),needle
)
end
-- Stringifies a list generically; probably shouldn't be used directly
localfunctionstringifyList(list,options)
-- Type-checks, defaults, and a shortcut
checkType("stringifyList",1,list,"table")
if#list==0thenreturnnilend
checkType("stringifyList",2,options,"table",true)
options=optionsor{}
fork,vinpairs(stringifyListDefaultOptions)do
ifoptions[k]==nilthenoptions[k]=vend
end
locals=options.space
-- Format the list if requested
ifoptions.formattedthen
list=mFormatLink.formatPages(
{categorizeMissing=mHatnote.missingTargetCat},list
)
end
-- Set the separator; if any item contains it, use the alternate separator
localseparator=options.separator
fork,vinpairs(list)do
ifsearchDisp(v,separator)then
separator=options.altSeparator
break
end
end
-- Set the conjunction, apply Oxford comma, and force a comma if #1 has "§"
localconjunction=s..options.conjunction..s
if#list==2andsearchDisp(list[1],"§")or#list>2then
conjunction=separator..conjunction
end
-- Return the formatted string
returnmw.text.listToText(list,separator..s,conjunction)
end
--DRY function
functionp.conjList(conj,list,fmt)
returnstringifyList(list,{conjunction=conj,formatted=fmt})
end
-- Stringifies lists with "and" or "or"
functionp.andList(...)returnp.conjList("dan",...)end
functionp.orList(...)returnp.conjList("atau",...)end
--------------------------------------------------------------------------------
-- For see
--
-- Makes a "For X, see [[Y]]." list from raw parameters. Intended for the
-- {{about}} and {{redirect}} templates and their variants.
--------------------------------------------------------------------------------
--default options table used across the forSee family of functions
localforSeeDefaultOptions={
andKeyword='dan',
title=mw.title.getCurrentTitle().text,
otherText='kegunaan lain',
forSeeForm='Untuk %s, lihat %s.',
}
--Collapses duplicate punctuation at end of string, ignoring italics and links
localfunctionpunctuationCollapse(text)
returntext:match("[.?!]('?)%1(%]?)%2%.$")andtext:sub(1,-2)ortext
end
-- Structures arguments into a table for stringification, & options
functionp.forSeeArgsToTable(args,from,options)
-- Type-checks and defaults
checkType("forSeeArgsToTable",1,args,'table')
checkType("forSeeArgsToTable",2,from,'number',true)
from=fromor1
checkType("forSeeArgsToTable",3,options,'table',true)
options=optionsor{}
fork,vinpairs(forSeeDefaultOptions)do
ifoptions[k]==nilthenoptions[k]=vend
end
-- maxArg's gotten manually because getArgs() and table.maxn aren't friends
localmaxArg=0
fork,vinpairs(args)do
iftype(k)=='number'andk>maxArgthenmaxArg=kend
end
-- Structure the data out from the parameter list:
-- * forTable is the wrapper table, with forRow rows
-- * Rows are tables of a "use" string & a "pages" table of pagename strings
-- * Blanks are left empty for defaulting elsewhere, but can terminate list
localforTable={}
locali=from
localterminated=false
-- If there is extra text, and no arguments are given, give nil value
-- to not produce default of "For kegunaan lain, see foo (disambiguation)"
ifoptions.extratextandi>maxArgthenreturnnilend
-- Loop to generate rows
repeat
-- New empty row
localforRow={}
-- On blank use, assume list's ended & break at end of this loop
forRow.use=args[i]
ifnotargs[i]thenterminated=trueend
-- New empty list of pages
forRow.pages={}
-- Insert first pages item if present
table.insert(forRow.pages,args[i+1])
-- If the param after next is "and", do inner loop to collect params
-- until the "and"'s stop. Blanks are ignored: "1|and||and|3" → {1, 3}
whileargs[i+2]==options.andKeyworddo
ifargs[i+3]then
table.insert(forRow.pages,args[i+3])
end
-- Increment to next "and"
i=i+2
end
-- Increment to next use
i=i+2
-- Append the row
table.insert(forTable,forRow)
untilterminatedori>maxArg
returnforTable
end
-- Stringifies a table as formatted by forSeeArgsToTable
functionp.forSeeTableToString(forSeeTable,options)
-- Type-checks and defaults
checkType("forSeeTableToString",1,forSeeTable,"table",true)
checkType("forSeeTableToString",2,options,"table",true)
options=optionsor{}
fork,vinpairs(forSeeDefaultOptions)do
ifoptions[k]==nilthenoptions[k]=vend
end
-- Stringify each for-see item into a list
localstrList={}
ifforSeeTablethen
fork,vinpairs(forSeeTable)do
localuseStr=v.useoroptions.otherText
localpagesStr=
p.andList(v.pages,true)or
mFormatLink._formatLink{
categorizeMissing=mHatnote.missingTargetCat,
link=mHatnote.disambiguate(options.title)
}
localforSeeStr=string.format(options.forSeeForm,useStr,pagesStr)
forSeeStr=punctuationCollapse(forSeeStr)
table.insert(strList,forSeeStr)
end
end
ifoptions.extratextthentable.insert(strList,punctuationCollapse(options.extratext..'.'))end
-- Return the concatenated list
returntable.concat(strList,' ')
end
-- Produces a "For X, see [[Y]]" string from arguments. Expects index gaps
-- but not blank/whitespace values. Ignores named args and args < "from".
functionp._forSee(args,from,options)
localforSeeTable=p.forSeeArgsToTable(args,from,options)
returnp.forSeeTableToString(forSeeTable,options)
end
-- As _forSee, but uses the frame.
functionp.forSee(frame,from,options)
mArguments=require('Module:Arguments')
returnp._forSee(mArguments.getArgs(frame),from,options)
end
returnp
Konten disalin dari Wikipedia Bahasa Indonesia (lisensi CC BY-SA) Lihat versi asli di Wikipedia

Rekomendasi Pilihan