Wikipedii
olowiki
https://olo.wikipedia.org/wiki/Pi%C3%A4sivu
MediaWiki 1.47.0-wmf.6
first-letter
Medii
Erikoine
Pagin
Käyttäi
Käyttäi pagin
Wikipedii
Wikipedien paginat
Failu
Failu pagin
MediiWiki
MediiWiki pagin
Šablonu
Šablonu pagin
Abu
Abu pagin
Kategourii
Kategourii pagin
TimedText
TimedText talk
Moduuli
Keskustelu moduulista
Event
Event talk
Wikipedii:Portualu
4
16
50972
50421
2026-06-11T21:29:52Z
Olksolo
356
/* Tracking categories */ uusi ketju ([[mw:c:Special:MyLanguage/User:JWBTH/CD|CD]])
50972
wikitext
text/x-wiki
__NEWSECTIONLINK__ __FORCETOC__
<div style= "background-color:#ccffff; border-style:solid; border-width:2px; padding:2px;">
* '''olo:''' {{int:please-translate}}.
* '''en:''' Requests for the [[m:bot|bot]] flag should be made on this page. This wiki uses the [[m:bot policy|standard bot policy]], and allows [[m:bot policy#Global_bots|global bots]] and [[m:bot policy#Automatic_approval|automatic approval of certain types of bots]]. Other bots should apply below, and then [[m:Steward requests/Bot status|request access]] from a steward if there is no objection.
</div>
{{Käyttäi:MABot/config
|archive = Wikipedii:Portualu/Arkisto/%(year)d
|algo = old(30d)
|counter = 1
|archiveheader =
|minthreadstoarchive = 1
|minthreadsleft = 2
}}
'''Arhiivu:'''
{{Special:Prefixindex/Wikipedii:Portualu/Arkisto/|hideredirects=1|stripprefix=1}}
<hr>
== Feminism and Folklore 2026 starts soon ==
<div style="border:8px maroon ridge;padding:6px;">
[[File:Feminism and Folklore 2026 logo.svg|centre|550px|frameless]]
::<div lang="en" dir="ltr" class="mw-content-ltr">
<div style="text-align: center; width: 100%;">''{{int:please-translate}}''</div>
;Invitation to Organize Feminism and Folklore 2026
Dear Wiki Community,
We are pleased to invite Wikimedia communities, affiliates, and independent contributors to organize the '''[[:m:Feminism and Folklore 2026|Feminism and Folklore 2026]]''' writing competition on your local Wikipedia.
The international campaign will run from '''1 February to 31 March 2026''' and aims to improve coverage of feminism, women’s histories, gender-related topics, and folk culture across Wikipedia projects.
;About the Campaign
'''Feminism and Folklore''' is a global writing initiative that complements the '''[[:c:Commons:Wiki Loves Folklore 2026|Wiki Loves Folklore]]''' photography competition. While Wiki Loves Folklore focuses on visual documentation, this writing campaign addresses the '''gender gap on Wikipedia''' by improving encyclopedic content related to folk culture and marginalized voices.
;What Can Participants Write About?
Communities can contribute by creating, expanding, or translating articles related to:
* Folk festivals, rituals, and celebrations
* Folk dances, music, and traditional performances
* Women and queer figures in folklore
* Women in mythology and oral traditions
* Women warriors, witches, and witch-hunting narratives
* Fairy tales, folk stories, and legends
* Folk games, sports, and cultural practices
Participants may work from curated article lists or generate new article suggestions using campaign tools.
;How to Sign Up as an Organizer
Organizers are requested to complete the following steps to register their community:
# Create a local project page on your wiki [[:m:Feminism and Folklore/Sample|(see sample)]]
# Set up the campaign using the '''CampWiz''' tool
# Prepare a local article list and clearly mention:
#* Campaign timeline
#* Local and international prizes
# Request a site notice from local administrators [[:mr:Template:SN-FNF|(see sample)]]
# Add your local project page and CampWiz link to the '''[[:m:Feminism and Folklore 2026/Project Page|Meta project page]]'''
;Campaign Tools
The Wiki Loves Folklore Tech Team has introduced tools to support organizers and participants:
* '''Article List Generator by Topic''' – Helps identify articles available on English Wikipedia but missing in your local language Wikipedia. The tool allows customized filters and provides downloadable article lists in CSV and wikitable formats.
* '''CampWiz''' – Enables communities to manage writing campaigns effectively, including jury-based evaluation. This will be the third year CampWiz is officially used for Feminism and Folklore.
Both tools are now available for use in the campaign. '''[https://tools.wikilovesfolklore.org/ Click here to access the tools]'''
;Learn More & Get Support
For detailed information about rules, timelines, and prizes, please visit the
'''[[:m:Feminism and Folklore 2026|Feminism and Folklore 2026 project page]]'''.
If you have any questions or need assistance, feel free to reach out via:
* '''[[:m:Talk:Feminism and Folklore 2026/Project Page|Meta talk page]]'''
* Email us using details on the contact page.
;Join Us
We look forward to your collaboration and coordination in making Feminism and Folklore 2026 a meaningful and impactful campaign for closing gender gaps and enriching folk culture content on Wikipedia.
Thank you and best wishes,
'''[[:m:Feminism and Folklore 2026|Feminism and Folklore 2026 International Team]]'''
----
''Stay connected:''
[[File:B&W Facebook icon.png|link=https://www.facebook.com/feminismandfolklore/|30x30px]]
[[File:B&W Twitter icon.png|link=https://twitter.com/wikifolklore|30x30px]]
</div></div>
== Invitation to Host Wiki Loves Folklore 2026 in Your Country ==
<div lang="en" dir="ltr" class="mw-content-ltr">
<div style="text-align: center; width: 100%;">''{{int:please-translate}}''</div>
[[File:Wiki Loves Folklore Logo.svg|right|150px|frameless]]
Hello everyone,
We are delighted to invite Wikimedia affiliates, user groups, and community organizations worldwide to participate in '''Wiki Loves Folklore 2026''', an international initiative dedicated to documenting and celebrating folk culture across the globe.
;About Wiki Loves Folklore
'''Wiki Loves Folklore''' is an annual international photography competition hosted on Wikimedia Commons. The campaign runs from '''1 February to 31 March 2026''' and encourages photographers, cultural enthusiasts, and community members to contribute photographs that highlight:
* Folk traditions and rituals
* Cultural festivals and celebrations
* Traditional attire and crafts
* Performing arts, music, and dance
* Everyday practices rooted in folk heritage
Through this campaign, we aim to preserve and promote diverse folk cultures and make them freely accessible to the world.
[[:c:Commons:Wiki_Loves_Folklore_2026|Project page on Wikimedia Commons]]
; Host a Local Edition
As we celebrate the '''eight edition''' of Wiki Loves Folklore, we warmly invite communities to organize a local edition in their country or region. Hosting a local campaign is a great opportunity to:
* Increase visibility of your region’s folk culture
* Engage new contributors in your community
* Enrich Wikimedia Commons with high-quality cultural content
'''[[:c:Commons:Wiki_Loves_Folklore_2026/Organize|Sign up to organize]]:'''
If your team prefers to organize the competition in ''either February or March only'', please feel free to let us know.
If you are unable to organize, we encourage you to share this opportunity with other interested groups or organizations in your region.
;Get in Touch
If you have any questions, need support, or would like to explore collaboration opportunities, please feel free to contact us via:
* The project Talk pages
* Email: '''support@wikilovesfolklore.org'''
We are also happy to connect via an online meeting if your team would like to discuss planning or coordination in more detail.
Warm regards,
'''The Wiki Loves Folklore International Team'''
</div>
[[Käyttäi:MediaWiki message delivery|MediaWiki message delivery]] ([[Käyttäi pagin:MediaWiki message delivery|pagin]]) 18. Pakkaskuuta 2026 kello 16.21 (MSK)
<!-- Viestin on lähettänyt Käyttäjä:Tiven2240@metawiki käyttämällä luetteloa, joka on sijainnissa https://meta.wikimedia.org/w/index.php?title=Distribution_list/Global_message_delivery/Wikipedia&oldid=29228188 -->
== <span lang="en" dir="ltr">Annual review of the Universal Code of Conduct and Enforcement Guidelines</span> ==
<div lang="en" dir="ltr">
<section begin="announcement-content" />
I am writing to you to let you know the annual review period for the Universal Code of Conduct and Enforcement Guidelines is open now. You can make suggestions for changes through 9 February 2026. This is the first step of several to be taken for the annual review. [[m:Special:MyLanguage/Universal Code of Conduct/Annual review/2026|Read more information and find a conversation to join on the UCoC page on Meta]].
The [[m:Special:MyLanguage/Universal Code of Conduct/Coordinating Committee|Universal Code of Conduct Coordinating Committee]] (U4C) is a global group dedicated to providing an equitable and consistent implementation of the UCoC. This annual review was planned and implemented by the U4C. For more information and the responsibilities of the U4C, [[m:Special:MyLanguage/Universal Code of Conduct/Coordinating Committee/Charter|you may review the U4C Charter]].
Please share this information with other members in your community wherever else might be appropriate.
-- In cooperation with the U4C, [[m:User:Keegan (WMF)|Keegan (WMF)]] ([[m:User talk:Keegan (WMF)|talk]])<section end="announcement-content" />
</div>
20. Pakkaskuuta 2026 kello 00.01 (MSK)
<!-- Viestin on lähettänyt Käyttäjä:Keegan (WMF)@metawiki käyttämällä luetteloa, joka on sijainnissa https://meta.wikimedia.org/w/index.php?title=Distribution_list/Global_message_delivery&oldid=29905753 -->
== Join the sixth Ukraine’s Cultural Diplomacy Month on Wikipedia! ==
<div lang="en" dir="ltr">
[[File:Ukraine’s Cultural Diplomacy Month on Wikipedia 2026.png|right|250px|thumb|link=https://meta.wikimedia.org/wiki/Ukraine%27s_Cultural_Diplomacy_Month_2026|Join our campaign!]]
{{int:please-translate}}
Dear Wikipedians!
[[:m:Special:MyLanguage/Wikimedia Ukraine|Wikimedia Ukraine]], in cooperation with the [[:en:Ministry of Foreign Affairs of Ukraine|MFA of Ukraine]] and [[:en:Ukrainian Institute|Ukrainian Institute]], has launched the sixth edition of writing challenge "'''[[:m:Special:MyLanguage/Ukraine's Cultural Diplomacy Month 2026|Ukraine's Cultural Diplomacy Month]]'''", which lasts from '''1st April''' until '''30th April 2026'''.
The initiative aims to promote knowledge about Ukrainian culture abroad by creating and improving Wikipedia articles in multiple languages. This year marks the sixth edition of the campaign, which will focus on contemporary culture, making today’s artistic voices and practices more visible to international audiences.
🧩'''How to participate?'''
Choose an article from the suggested list → Write an article in your language, or improve an existing one according to the rules → Add your contribution to the contest page and calculate your points → Win prizes and receive a certificate of participation → Become a promoter of truthful knowledge about Ukraine.
🧩'''[[m:Special:MyLanguage/Ukraine's Cultural Diplomacy Month 2026|Check our main page for more information]]'''.
'''If you are interested in coordinating long-term community engagement for the campaign and becoming a local ambassador, we would love to hear from you! Please let us know your interest.'''
If not, then we encourage you to translate the [[m:Special:MyLanguage/Ukraine's Cultural Diplomacy Month 2026|landing page of the contest]] and [https://meta.wikimedia.org/wiki/Special:MessageGroupStats?group=Centralnotice-tgroup-UCDM2026banner&messages=&language=en&x=D banner] into your own language.
Also, we set up a [[:m:CentralNotice/Request/Ukraine's Cultural Diplomacy Month 2026|banner]] to notify users of the possibility to participate in this challenge!
[[:m:User:OlesiaLukaniuk (WMUA)|OlesiaLukaniuk (WMUA)]] ([[:m:User talk:OlesiaLukaniuk (WMUA)|talk]]) 04:35, 1 April 2026 (UTC)
</div>
<!-- Viestin on lähettänyt Käyttäjä:OlesiaLukaniuk (WMUA)@metawiki käyttämällä luetteloa, joka on sijainnissa https://meta.wikimedia.org/w/index.php?title=User:OlesiaLukaniuk_(WMUA)/list_of_wikis&oldid=28552112 -->
== Request for comment (global AI policy) ==
<bdi lang="en" dir="ltr" class="mw-content-ltr">
Apologies for writing in English. {{int:Please-translate}}
A [[:m:Requests for comment/Artificial intelligence policy|request for comment]] is currently being held to decide on a global AI policy. {{int:Feedback-thanks-title}}
[[Käyttäi:MediaWiki message delivery|MediaWiki message delivery]] ([[Käyttäi pagin:MediaWiki message delivery|pagin]]) 26. Sulakuuta 2026 kello 03.58 (MSK)
</bdi>
<!-- Viestin on lähettänyt Käyttäjä:Codename Noreste@metawiki käyttämällä luetteloa, joka on sijainnissa https://meta.wikimedia.org/w/index.php?title=Distribution_list/Global_message_delivery&oldid=30424282 -->
== Wikimedia Northern Europe Meeting 2026 ==
Я тут случайно наткнулся на такое событие — [[meta:Wikimedia Northern Europe Meeting 2026]]. Похоже, организаторы не сильно запариваются с рекламой и рассылкой приглашений, но тематика встречи пересекается с нашей деятельностью. Тем более что, там заявлен [[meta:Wikimedia Finno-Ugric Collaboration|Fenno-Ugric Wikiseminar]]. Понятно, что из России в Оулу сейчас попасть будет весьма проблематично, хотя вот Стася Львова из группы [[meta:North-West Russia Wiki-Historians User Group|Вики-краеведов Северо-Запада]] участвовать собирается. Собственно, это сообщение я разместил для того, вдруг, кто-то из наших активных редакторов имеет возможность и желание поучаствовать в этом митинге и рассказать о Ливвиковской Википедии.
I recently stumbled upon this event — [[meta:Wikimedia Northern Europe Meeting 2026]]. Apparently, the organizers aren't going out of their way with promotion or sending out invitations, but the meeting's theme overlaps with what we do. Especially since the [[meta:Wikimedia Finno-Ugric Collaboration|Fenno-Ugric Wikiseminar]] is listed on the agenda. Obviously, getting to Oulu from Russia right now would be quite challenging — though Stasya Lvova from [[meta:North-West Russia Wiki-Historians User Group|the North-West Wiki Local Historians group]] is planning to participate. Anyway, I'm posting this just in case any of our active editors has both the means and the desire to attend this gathering and talk about the Livvi-Karelian Wikipedia. [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 21. Oraskuuta 2026 kello 21.09 (MSK)
== <span lang="en" dir="ltr">Vote now in the 2026 U4C election</span> ==
<div lang="en" dir="ltr">
<section begin="announcement-content" />
Eligible voters are asked to participate in the 2026 [[m:Special:MyLanguage/Universal_Code_of_Conduct/Coordinating_Committee|Universal Code of Conduct Coordinating Committee]] election. More information–including an eligibility check, voting process information, candidate information, and a link to the vote–are available on Meta at the [[m:Special:MyLanguage/Universal_Code_of_Conduct/Coordinating_Committee/Election/2026|2026 Election information page]]. The vote closes on 2 June 2026 at [https://zonestamp.toolforge.org/1780358400 00:00 UTC].
Please vote if your account is eligible. Results will be available by 14 June 2026. -- In cooperation with the U4C,<section end="announcement-content" />
</div>
[[m:User:Keegan (WMF)|Keegan (WMF)]] ([[m:User talk:Keegan (WMF)|talk]]) 27. Oraskuuta 2026 kello 20.14 (MSK)
<!-- Viestin on lähettänyt Käyttäjä:Keegan (WMF)@metawiki käyttämällä luetteloa, joka on sijainnissa https://meta.wikimedia.org/w/index.php?title=Distribution_list/Global_message_delivery&oldid=30513860 -->
== Tracking categories ==
У меня руки чешутся навести порядок в отслеживающих категориях (tracking categories). Сейчас у нас там каша из ливвиковских, финских, русских и английских названий. Я даже как-то раз выцепил названия категорий на индонезийском: https://olo.wikipedia.org/w/index.php?title=Moduuli%3AInfobox&diff=50327&oldid=46839
В связи с этим у меня вопрос. Будем ли мы использовать для отслеживающих категорий какой-нибудь префикс, чтобы отличать их от обычных категорий? Например, в Русской Википедии для служебных категорий используется префикс "Википедия:" ("Википедия:Статьи со ссылками на элементы Викиданных без подписи", "Википедия:Биографии современников", ...). А вот в Английской Википедии никакой префикс обычно не используется ("Pages with disabled graphs", "Pages with disabled graphs", ...).
Для примера собрал несколько источников отслеживающих категорий:<br>
https://docs.google.com/spreadsheets/d/1AQTI3N1N_8wdyV0Sdc5CsGT7x-D4I_n4wf7hQNWtnuQ
Пингую активных редакторов для обсуждения: @[[Käyttäi:Onegaborg|Onegaborg]], @[[Käyttäi:Fembriha|Fembriha]], @[[Käyttäi:Miro Tuomi|Miro Tuomi]].
My hands are itching to clean up the tracking categories. Right now we have a mess of Livvi-Karelian, Finnish, Russian, and English names. I even once found category names in Indonesian: https://olo.wikipedia.org/w/index.php?title=Moduuli%3AInfobox&diff=50327&oldid=46839
This brings me to a question. Will we use some kind of prefix for tracking categories to distinguish them from regular categories? For example, the Russian Wikipedia uses the prefix "Википедия:" for maintenance categories ("Википедия:Статьи со ссылками на элементы Викиданных без подписи", "Википедия:Биографии современников", ...). The English Wikipedia, however, typically doesn't use any prefix ("Pages with disabled graphs", "Pages with disabled graphs", ...).
For reference, I've collected several sources of tracking categories:<br>
https://docs.google.com/spreadsheets/d/1AQTI3N1N_8wdyV0Sdc5CsGT7x-D4I_n4wf7hQNWtnuQ [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 12. Kezäkuuta 2026 kello 00.29 (MSK)
msperxt9e73d88t66jn8j3n4nhwja3x
Šablonu:Kartal sijaičendu+
10
87
50940
48274
2026-06-11T12:35:56Z
Olksolo
356
replace tleft/tright style classes with floatleft/floatright
50940
wikitext
text/x-wiki
<includeonly>{{#ifexist:template:Kartal sijaičendu {{{1}}}|{{#if:{{{alt|}}}|{{#ifexist:Media:{{{alt|}}}|[[Категория:Википедия:Изображения для переноса в ПозКарты]]}}}}<div class="location-map {{#switch:Q{{{caption|-}}}|Q|Q-=|thumb}} {{#switch:{{{float|right}}}|left|right=float{{{float|right}}}|none=floatright}}" style="width:{{#expr:{{{width|240}}}+{{#ifeq:{{{caption|}}}|{{{caption}}}|10|2}}}}px;{{#switch:{{{border|}}}Q|noneQ=border:none|Q=;|border:1px solid {{{border}}}}};{{#ifeq:{{{float|}}}|center|margin:0 auto}}"><div class="{{#switch:Q{{{caption|-}}}|Q|Q-=|thumbinner}}"><div class="thumbimage" style="overflow:hidden; width:{{{width|240}}}px;position:relative;{{#switch:{{{border|}}}Q|noneQ=border:none|Q=;|border:1px solid {{{border}}}}}">{{#if:{{Kartal sijaičendu {{{1|Мир}}}|areas|{{{areas|}}}}}|{{#tag:imagemap|File:{{#ifexist:Media:{{{alt|}}}|{{{alt}}}|{{Kartal sijaičendu {{{1|Мир}}}|image|{{{alt|}}}}}}}{{!}}{{{width|240}}}px{{!}}{{#if:{{{altname|}}}|{{{altname}}}|{{#if:{{{label|}}}|{{{label}}}|{{PAGENAME}}}} ({{Kartal sijaičendu {{{1|Мир}}}|name}})}}
{{#ifeq:{{{areas|}}}|{{{alt|}}}|{{Kartal sijaičendu {{{1|Мир}}}|areas|{{{areas|}}}}}|default [[:File:{{Kartal sijaičendu {{{1|Мир}}}|image|{{{alt|}}}}}]]
desc none}}}}|[[File:{{#ifexist:Media:{{{alt|}}}|{{{alt}}}|{{Kartal sijaičendu {{{1|Мир}}}|image|{{{alt|}}}}}}}{{!}}{{{width|240}}}px{{!}}{{#if:{{{altname|}}}|{{{altname}}}|{{#if:{{{label|}}}|{{{label}}}|{{PAGENAME}}}} ({{Kartal sijaičendu {{{1|Мир}}}|name}})}}]]}}{{{places|}}}</div>{{#if:{{{caption|-}}}|<div class="thumbcaption">{{#ifeq:{{{caption|-}}}|-|{{#if:{{{label|}}}|{{{label}}}, {{Kartal sijaičendu {{{1|Мир}}}|name}}|{{PAGENAME}}, {{Kartal sijaičendu {{{1|Мир}}}|name}}}}|{{{caption|}}}}}</div>}}</div></div>|<div class="error">''{{{1}}}'' ещё не имеет [[Template:Kartal sijaičendu {{{1}}}|позиционной карты]].</div>[[Категория:Википедия:Неверно указанные ПозКарты]]}}</includeonly><noinclude>
{{doc|Template:Kartal sijaičendu/doc}}
[[Kategourii:Šablonat:Kartal sijaičendat]]
[[Категория:Википедия:Исключения из печати]]
</noinclude>
qj0zzd3j3ug2mqv6je2rx2fhdq82vgo
Šablonu:Dokumentoija
10
153
50960
48946
2026-06-11T19:02:08Z
Olksolo
356
fix namespace
50960
wikitext
text/x-wiki
<noinclude>{{doc-inline}}</noinclude>{{ambox
|type=content
|text='''Этому шаблону не хватает [[Проект:Документирование шаблонов|документации]].'''
|text-small=Вы можете помочь проекту, сделав <span style="font-size:large;"><u><includeonly>[[{{SUBJECTSPACE}}:{{PAGENAME:{{{1|{{SUBJECTPAGENAME}}/doc}}}}}|описание шаблона]]</includeonly><noinclude>{{color|red|описание шаблона}}</noinclude></u></span>: что он делает, как его использовать, какие параметры он принимает. Это поможет другим использовать его.<br />Для оформления можете воспользоваться {{tl|doc}} или {{tl|doc-inline}}. Не забывайте помещать описание внутрь <nowiki><noinclude></noinclude></nowiki>.<br />P.S. Также не забываем про [[Проект:Шаблоны/Категоризация|категорию]] и [[ВП:Интервики|интервики]].
}}<includeonly>{{#if:{{{nocat|}}}||{{#ifeq:{{NAMESPACE}}|{{ns:10}}|[[Kategourii:Википедия:Недокументированные шаблоны|{{PAGENAME}}]]|}}}}</includeonly><noinclude>
Данное сообщение появляется при незаполненном шаблоне {{tl|doc}}.
{{doc/end}}
[[Kategourii:Шаблоны:Предупреждения|{{PAGENAME}}]]
[[Kategourii:Википедия:Недокументированные шаблоны| ]]
[[Kategourii:Шаблоны:Для документирования шаблонов|{{PAGENAME}}]]</noinclude>
3igeojefvav32ksfeufgy3ml5i6j0vz
Moduuli:Infobox
828
303
50970
50327
2026-06-11T21:09:39Z
Olksolo
356
fix namespace
50970
Scribunto
text/plain
local p = {}
local args = {}
local origArgs = {}
local root
local empty_row_categories = {}
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local has_rows = false
local function fixChildBoxes(sval, tt)
local function notempty( s ) return s and s:match( '%S' ) end
if notempty(sval) then
local marker = '<span class=special_infobox_marker>'
local s = sval
-- start moving templatestyles and categories inside of table rows
local slast = ''
while slast ~= s do
slast = s
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*%]%])', '%2%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)', '%2%1')
end
-- end moving templatestyles and categories inside of table rows
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
if s:match(marker) then
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1')
end
if s:match(marker) then
local subcells = mw.text.split(s, marker)
s = ''
for k = 1, #subcells do
if k == 1 then
s = s .. subcells[k] .. '</' .. tt .. '></tr>'
elseif k == #subcells then
local rowstyle = ' style="display:none"'
if notempty(subcells[k]) then rowstyle = '' end
s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' ..
subcells[k]
elseif notempty(subcells[k]) then
if (k % 2) == 0 then
s = s .. subcells[k]
else
s = s .. '<tr><' .. tt .. ' colspan=2>\n' ..
subcells[k] .. '</' .. tt .. '></tr>'
end
end
end
end
-- the next two lines add a newline at the end of lists for the PHP parser
-- [[Special:Diff/849054481]]
-- remove when [[:phab:T191516]] is fixed or OBE
s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')
s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')
return s
else
return sval
end
end
-- Cleans empty tables
local function cleanInfobox()
root = tostring(root)
if has_rows == false then
root = mw.ustring.gsub(root, '<table[^<>]*>%s*</table>', '')
end
end
-- Returns the union of the values of two tables, as a sequence.
local function union(t1, t2)
local vals = {}
for k, v in pairs(t1) do
vals[v] = true
end
for k, v in pairs(t2) do
vals[v] = true
end
local ret = {}
for k, v in pairs(vals) do
table.insert(ret, k)
end
return ret
end
-- Returns a table containing the numbers of the arguments that exist
-- for the specified prefix. For example, if the prefix was 'data', and
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
local function getArgNums(prefix)
local nums = {}
for k, v in pairs(args) do
local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
if num then table.insert(nums, tonumber(num)) end
end
table.sort(nums)
return nums
end
-- Adds a row to the infobox, with either a header cell
-- or a label/data cell combination.
local function addRow(rowArgs)
if rowArgs.header and rowArgs.header ~= '_BLANK_' then
has_rows = true
root
:tag('tr')
:addClass(rowArgs.rowclass)
:cssText(rowArgs.rowstyle)
:tag('th')
:attr('colspan', '2')
:addClass('infobox-header')
:addClass(rowArgs.class)
:addClass(args.headerclass)
-- @deprecated next; target .infobox-<name> .infobox-header
:cssText(args.headerstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.header, 'th'))
if rowArgs.data then
root:wikitext(
'[[Kategourii:Pages using infobox templates with ignored data cells]]'
)
end
elseif rowArgs.data and rowArgs.data:gsub(
category_in_empty_row_pattern, ''
):match('^%S') then
has_rows = true
local row = root:tag('tr')
row:addClass(rowArgs.rowclass)
row:cssText(rowArgs.rowstyle)
if rowArgs.label then
row
:tag('th')
:attr('scope', 'row')
:addClass('infobox-label')
-- @deprecated next; target .infobox-<name> .infobox-label
:cssText(args.labelstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(rowArgs.label)
:done()
end
local dataCell = row:tag('td')
dataCell
:attr('colspan', not rowArgs.label and '2' or nil)
:addClass(not rowArgs.label and 'infobox-full-data' or 'infobox-data')
:addClass(rowArgs.class)
-- @deprecated next; target .infobox-<name> .infobox(-full)-data
:cssText(rowArgs.datastyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.data, 'td'))
else
table.insert(empty_row_categories, rowArgs.data or '')
end
end
local function renderTitle()
if not args.title then return end
has_rows = true
root
:tag('caption')
:addClass('infobox-title')
:addClass(args.titleclass)
-- @deprecated next; target .infobox-<name> .infobox-title
:cssText(args.titlestyle)
:wikitext(args.title)
end
local function renderAboveRow()
if not args.above then return end
has_rows = true
root
:tag('tr')
:tag('th')
:attr('colspan', '2')
:addClass('infobox-above')
:addClass(args.aboveclass)
-- @deprecated next; target .infobox-<name> .infobox-above
:cssText(args.abovestyle)
:wikitext(fixChildBoxes(args.above,'th'))
end
local function renderBelowRow()
if not args.below then return end
has_rows = true
root
:tag('tr')
:tag('td')
:attr('colspan', '2')
:addClass('infobox-below')
:addClass(args.belowclass)
-- @deprecated next; target .infobox-<name> .infobox-below
:cssText(args.belowstyle)
:wikitext(fixChildBoxes(args.below,'td'))
end
local function addSubheaderRow(subheaderArgs)
if subheaderArgs.data and
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
local row = root:tag('tr')
row:addClass(subheaderArgs.rowclass)
local dataCell = row:tag('td')
dataCell
:attr('colspan', '2')
:addClass('infobox-subheader')
:addClass(subheaderArgs.class)
:cssText(subheaderArgs.datastyle)
:cssText(subheaderArgs.rowcellstyle)
:wikitext(fixChildBoxes(subheaderArgs.data, 'td'))
else
table.insert(empty_row_categories, subheaderArgs.data or '')
end
end
local function renderSubheaders()
if args.subheader then
args.subheader1 = args.subheader
end
if args.subheaderrowclass then
args.subheaderrowclass1 = args.subheaderrowclass
end
local subheadernums = getArgNums('subheader')
for k, num in ipairs(subheadernums) do
addSubheaderRow({
data = args['subheader' .. tostring(num)],
-- @deprecated next; target .infobox-<name> .infobox-subheader
datastyle = args.subheaderstyle,
rowcellstyle = args['subheaderstyle' .. tostring(num)],
class = args.subheaderclass,
rowclass = args['subheaderrowclass' .. tostring(num)]
})
end
end
local function addImageRow(imageArgs)
if imageArgs.data and
imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
local row = root:tag('tr')
row:addClass(imageArgs.rowclass)
local dataCell = row:tag('td')
dataCell
:attr('colspan', '2')
:addClass('infobox-image')
:addClass(imageArgs.class)
:cssText(imageArgs.datastyle)
:wikitext(fixChildBoxes(imageArgs.data, 'td'))
else
table.insert(empty_row_categories, imageArgs.data or '')
end
end
local function renderImages()
if args.image then
args.image1 = args.image
end
if args.caption then
args.caption1 = args.caption
end
local imagenums = getArgNums('image')
for k, num in ipairs(imagenums) do
local caption = args['caption' .. tostring(num)]
local data = mw.html.create():wikitext(args['image' .. tostring(num)])
if caption then
data
:tag('div')
:addClass('infobox-caption')
-- @deprecated next; target .infobox-<name> .infobox-caption
:cssText(args.captionstyle)
:wikitext(caption)
end
addImageRow({
data = tostring(data),
-- @deprecated next; target .infobox-<name> .infobox-image
datastyle = args.imagestyle,
class = args.imageclass,
rowclass = args['imagerowclass' .. tostring(num)]
})
end
end
-- When autoheaders are turned on, preprocesses the rows
local function preprocessRows()
if not args.autoheaders then return end
local rownums = union(getArgNums('header'), getArgNums('data'))
table.sort(rownums)
local lastheader
for k, num in ipairs(rownums) do
if args['header' .. tostring(num)] then
if lastheader then
args['header' .. tostring(lastheader)] = nil
end
lastheader = num
elseif args['data' .. tostring(num)] and
args['data' .. tostring(num)]:gsub(
category_in_empty_row_pattern, ''
):match('^%S') then
local data = args['data' .. tostring(num)]
if data:gsub(category_in_empty_row_pattern, ''):match('%S') then
lastheader = nil
end
end
end
if lastheader then
args['header' .. tostring(lastheader)] = nil
end
end
-- Gets the union of the header and data argument numbers,
-- and renders them all in order
local function renderRows()
local rownums = union(getArgNums('header'), getArgNums('data'))
table.sort(rownums)
for k, num in ipairs(rownums) do
addRow({
header = args['header' .. tostring(num)],
label = args['label' .. tostring(num)],
data = args['data' .. tostring(num)],
datastyle = args.datastyle,
class = args['class' .. tostring(num)],
rowclass = args['rowclass' .. tostring(num)],
-- @deprecated next; target .infobox-<name> rowclass
rowstyle = args['rowstyle' .. tostring(num)],
rowcellstyle = args['rowcellstyle' .. tostring(num)]
})
end
end
local function renderNavBar()
if not args.name then return end
has_rows = true
root
:tag('tr')
:tag('td')
:attr('colspan', '2')
:addClass('infobox-navbar')
:wikitext(require('Moduuli:Navbar')._navbar{
args.name,
mini = 1,
})
end
local function renderItalicTitle()
local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'}))
end
end
-- Categories in otherwise empty rows are collected in empty_row_categories.
-- This function adds them to the module output. It is not affected by
-- args.decat because this module should not prevent module-external categories
-- from rendering.
local function renderEmptyRowCategories()
for _, s in ipairs(empty_row_categories) do
root:wikitext(s)
end
end
-- Render tracking categories. args.decat == turns off tracking categories.
local function renderTrackingCategories()
if args.decat == 'yes' then return end
if args.child == 'yes' then
if args.title then
root:wikitext(
'[[Kategourii:Pages using embedded infobox templates with the title parameter]]'
)
end
elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
root:wikitext('[[Kategourii:Articles using infobox templates with no data rows]]')
end
end
--[=[
Loads the templatestyles for the infobox.
TODO: FINISH loading base templatestyles here rather than in
MediaWiki:Common.css. There are 4-5000 pages with 'raw' infobox tables.
See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :).
When we do this we should clean up the inline CSS below too.
Will have to do some bizarre conversion category like with sidebar.
]=]
local function loadTemplateStyles()
local frame = mw.getCurrentFrame()
-- See function description
local base_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = 'Moduuli:Infobox/styles.css' }
}
local templatestyles = ''
if args['templatestyles'] then templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['templatestyles'] }
}
end
local child_templatestyles = ''
if args['child templatestyles'] then child_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['child templatestyles'] }
}
end
local grandchild_templatestyles = ''
if args['grandchild templatestyles'] then grandchild_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
}
end
return table.concat({
base_templatestyles, -- see function description
templatestyles,
child_templatestyles,
grandchild_templatestyles
})
end
-- common functions between the child and non child cases
local function structure_infobox_common()
renderSubheaders()
renderImages()
preprocessRows()
renderRows()
renderBelowRow()
renderNavBar()
renderItalicTitle()
renderEmptyRowCategories()
renderTrackingCategories()
cleanInfobox()
end
-- Specify the overall layout of the infobox, with special settings if the
-- infobox is used as a 'child' inside another infobox.
local function _infobox()
if args.child ~= 'yes' then
root = mw.html.create('table')
root
:addClass(args.subbox == 'yes' and 'infobox-subbox' or 'infobox')
:addClass(args.bodyclass)
-- @deprecated next; target .infobox-<name>
:cssText(args.bodystyle)
renderTitle()
renderAboveRow()
else
root = mw.html.create()
root
:wikitext(args.title)
end
structure_infobox_common()
return loadTemplateStyles() .. root
end
-- If the argument exists and isn't blank, add it to the argument table.
-- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
local function preprocessSingleArg(argName)
if origArgs[argName] and origArgs[argName] ~= '' then
args[argName] = origArgs[argName]
end
end
-- Assign the parameters with the given prefixes to the args table, in order, in
-- batches of the step size specified. This is to prevent references etc. from
-- appearing in the wrong order. The prefixTable should be an array containing
-- tables, each of which has two possible fields, a "prefix" string and a
-- "depend" table. The function always parses parameters containing the "prefix"
-- string, but only parses parameters in the "depend" table if the prefix
-- parameter is present and non-blank.
local function preprocessArgs(prefixTable, step)
if type(prefixTable) ~= 'table' then
error("Non-table value detected for the prefix table", 2)
end
if type(step) ~= 'number' then
error("Invalid step value detected", 2)
end
-- Get arguments without a number suffix, and check for bad input.
for i,v in ipairs(prefixTable) do
if type(v) ~= 'table' or type(v.prefix) ~= "string" or
(v.depend and type(v.depend) ~= 'table') then
error('Invalid input detected to preprocessArgs prefix table', 2)
end
preprocessSingleArg(v.prefix)
-- Only parse the depend parameter if the prefix parameter is present
-- and not blank.
if args[v.prefix] and v.depend then
for j, dependValue in ipairs(v.depend) do
if type(dependValue) ~= 'string' then
error('Invalid "depend" parameter value detected in preprocessArgs')
end
preprocessSingleArg(dependValue)
end
end
end
-- Get arguments with number suffixes.
local a = 1 -- Counter variable.
local moreArgumentsExist = true
while moreArgumentsExist == true do
moreArgumentsExist = false
for i = a, a + step - 1 do
for j,v in ipairs(prefixTable) do
local prefixArgName = v.prefix .. tostring(i)
if origArgs[prefixArgName] then
-- Do another loop if any arguments are found, even blank ones.
moreArgumentsExist = true
preprocessSingleArg(prefixArgName)
end
-- Process the depend table if the prefix argument is present
-- and not blank, or we are processing "prefix1" and "prefix" is
-- present and not blank, and if the depend table is present.
if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then
for j,dependValue in ipairs(v.depend) do
local dependArgName = dependValue .. tostring(i)
preprocessSingleArg(dependArgName)
end
end
end
end
a = a + step
end
end
-- Parse the data parameters in the same order that the old {{infobox}} did, so
-- that references etc. will display in the expected places. Parameters that
-- depend on another parameter are only processed if that parameter is present,
-- to avoid phantom references appearing in article reference lists.
local function parseDataParameters()
preprocessSingleArg('autoheaders')
preprocessSingleArg('child')
preprocessSingleArg('bodyclass')
preprocessSingleArg('subbox')
preprocessSingleArg('bodystyle')
preprocessSingleArg('title')
preprocessSingleArg('titleclass')
preprocessSingleArg('titlestyle')
preprocessSingleArg('above')
preprocessSingleArg('aboveclass')
preprocessSingleArg('abovestyle')
preprocessArgs({
{prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}
}, 10)
preprocessSingleArg('subheaderstyle')
preprocessSingleArg('subheaderclass')
preprocessArgs({
{prefix = 'image', depend = {'caption', 'imagerowclass'}}
}, 10)
preprocessSingleArg('captionstyle')
preprocessSingleArg('imagestyle')
preprocessSingleArg('imageclass')
preprocessArgs({
{prefix = 'header'},
{prefix = 'data', depend = {'label'}},
{prefix = 'rowclass'},
{prefix = 'rowstyle'},
{prefix = 'rowcellstyle'},
{prefix = 'class'}
}, 50)
preprocessSingleArg('headerclass')
preprocessSingleArg('headerstyle')
preprocessSingleArg('labelstyle')
preprocessSingleArg('datastyle')
preprocessSingleArg('below')
preprocessSingleArg('belowclass')
preprocessSingleArg('belowstyle')
preprocessSingleArg('name')
-- different behaviour for italics if blank or absent
args['italic title'] = origArgs['italic title']
preprocessSingleArg('decat')
preprocessSingleArg('templatestyles')
preprocessSingleArg('child templatestyles')
preprocessSingleArg('grandchild templatestyles')
end
-- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
function p.infobox(frame)
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame
end
parseDataParameters()
return _infobox()
end
-- For calling via #invoke within a template
function p.infoboxTemplate(frame)
origArgs = {}
for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end
parseDataParameters()
return _infobox()
end
return p
fp87jbtssohpg9xuzothkxxa73s7kjy
Moduuli:WikidataCoords
828
311
50963
1222
2026-06-11T19:59:06Z
Olksolo
356
fix namespace
50963
Scribunto
text/plain
local p = {};
-- Значения аргументов по умолчанию
local defaultArgs = {
['lat_deg'] = '',
['lat_min'] = '0',
['lat_sec'] = '0',
['lat_dir'] = 'N',
['lon_deg'] = '0',
['lon_min'] = '0',
['lon_sec'] = '0',
['lon_dir'] = 'E'
};
-- Соотношение именованных и числовых параметров
local argsMap = {
'lat_deg',
'lat_min',
'lat_sec',
'lat_dir',
'lon_deg',
'lon_min',
'lon_sec',
'lon_dir'
};
-- Метод вызывает шаблон, добавляя к параметрам координаты из Викиданных
function p.execTplWithCoords( frame )
local moduleWikidata = require( 'Moduuli:Wikidata' );
local pFrame = frame:getParent();
local args = mw.clone( pFrame.args );
setmetatable( args, nil );
local template = mw.text.trim( args[1] );
args[1] = nil;
if not args.lat_deg or args.lat_deg == '' then
-- Получение координат из Викиданных
frame.args = {
['property'] = 'p625',
['plain'] = true
};
local coords = moduleWikidata.formatProperty( frame );
coords = string.gsub( coords, ''', '\'' );
coords = string.gsub( coords, '"', '"' );
-- Преобразование координат в значения отдельных параметров
coords = mw.text.split( coords, ', ', true );
local lat = coords[1];
local lon = coords[2];
if lat and lat ~= '' then
args.lat_deg = string.match( lat, '%d+°' );
args.lat_min = string.match( lat, '%d+\'' );
args.lat_sec = string.match( lat, '[0-9%.]+"' );
args.lat_dir = string.match( lat, '[NS]' );
end
if lon and lon ~= '' then
args.lon_deg = string.match( lon, '%d+°' );
args.lon_min = string.match( lon, '%d+\'' );
args.lon_sec = string.match( lon, '[0-9%.]+"' );
args.lon_dir = string.match( lon, '[EW]' );
end
end
-- Установка значений по умолчанию
for name, value in pairs( defaultArgs ) do
if not args[name] or args[name] == '' then
args[name] = value;
end
args[name] = mw.text.trim( args[name], '°\'" ' );
end
-- Если во втором параметре указан формат вывода
if args[2] then
local outType = mw.text.trim( args[2] );
if outType == '12345678' then
for i, name in ipairs( argsMap ) do
args[i] = args[name];
args[name] = nil;
end
end
end
return frame:expandTemplate{ title = template, args = args };
end
return p;
bsejzynzvlajzhixkvobsnucf78xdqn
Ynys Môn
0
4402
50968
32023
2026-06-11T20:35:57Z
Olksolo
356
UIC
50968
wikitext
text/x-wiki
{{UIC}}
'''Ynys Môn''' ({{k-en|Anglesey}}) on [[Kymrinmua]]n suurin suari. Yhtes [[Ynys Gybi]]n suaren da pienembien elämättömien suarienke se muvvostau Ynys Mônan muakunnan.
[[Kategourii:Ynys Mônan suaret]]
[[Kategourii:Kymrinmuan suaret]]
ii3v95mbvjadhecl85irfc3bj0hl8c8
Ynys Catrin
0
6806
50966
31311
2026-06-11T20:18:13Z
Olksolo
356
UIC
50966
wikitext
text/x-wiki
{{UIC}}
'''Ynys Catrin''' ({{k-en|St Catherine's Island}}) on suari [[Kymrinmua]]s.
[[Kategourii:Sir Benfron suaret]]
gedwrjifbk72ktesqxp2okhn5yi9tcn
Llyn Tegid
0
7186
50965
32007
2026-06-11T20:16:15Z
Olksolo
356
50965
wikitext
text/x-wiki
{{UIC}}
'''Llyn Tegid''' ({{k-en|Bala Lake}}) on [[Kymrinmua]]n suurin luonnolline järvi. Se sijaiččou [[Y Bala]]n kylän suvipuolel [[Gwynedd]]an muakunnas. [[Afon Dyfrdwy]] -jogi virduau järven läbi.
[[Kategourii:Kymrinmuan järvet]]
1rgyzvfvnkpur3uyra04s2zytcv33na
Vladimir R´agojev
0
8201
50967
34377
2026-06-11T20:33:49Z
Olksolo
356
50967
wikitext
text/x-wiki
{{UIC}}
'''Vladimir R´agojev''' rodivui 8.pakkaskuudu 1935 Priäzän piirin Kolatsellän kyläs. Vuvvennu 1959 loppi Petroskoin valdivonyliopiston histouriellis-fololougizen tiedokunnan suomelas-ugrilazen ozaston. Vuvves 1964 ruadoi Kielen, literatuuran da histourien instituutas. Vuvvennu 1979 kirjutti Karjalan kielen Tihvinän paginluadu -monografien da väitteli filolougien kandiduatakse. Kuului Suomen da Nevvostoliiton välizeh ruadojoukkoh, kudaI sellitteli kielikyzymyksii. Kuului Suomelas-ugrilazeh seurah. Tutkimuksen piäruavonnu oli karjalan kieli. On painanuh läs 30 tiedoruaduo, niilöin luvus Karjalan kielen näytteitä (Tihvinän karjala). Kiändi livvin karjalakse Jevangelien Matfein mugah. Ruadoi suuris kanzoinvälizis projektois - Jevroupan lingvistiekkuatlassu, Suomelas-ugrilazien kielien lingvistiekkuatlassu. Kuoli 28. kevätkuudu 2019 Petroskois.
clg4cdrqj6pda72o6atahuh7r0745ee
Robin Tunney
0
8209
50969
33939
2026-06-11T20:39:36Z
Olksolo
356
remove extra photo
50969
wikitext
text/x-wiki
{{Ristikanzu}}
'''Robin Tunney''' (19. kezäkuudu 1972 - nygöi; Chicago, Illinois, Yhtysvallat) on ameriekkalaine näyttelii. Häi on näytellyh rouliloi teatrois, televiizoras da fil'mois.
Tunney muutti 18-vuodehizennu Los Angelesah da sai äijy roulii televiizoras. Tunneyn läbimurdo oli rouli ičetuhozennu neijistämisigäzenny vuvvennu 1995 luajitus fil'mas Empire Records, midä jälles häi sai enzimäzen piäroulin fil'mas The Craft.
[[Kategourii:Kino|T]]
gtgu3mifgtsf8lf9frutpg9m1crpvet
Käyttäi pagin:Fembriha
3
16469
50962
50929
2026-06-11T19:50:22Z
Fembriha
8650
/* */ Vastavus
50962
wikitext
text/x-wiki
Перед тем, как в корне менять все названия химических элеметов, сначала следует посоветоваться с авторами этих статей и со знатоками карельского языка. Не нужно слепо копировать эти названия из финского языка. Давайте обсудим. Если ответа не последует, все изменения будут удалены. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 3. Oraskuuta 2026 kello 22.48 (MSK)
:Добрый день. Недавно в сети появились разработки на ливвиковском карельском и северном собственно-карельском наречиях, касающиеся астрономических терминов, названий государств и территорий и таблицы Менделеева (файл с таблицей есть на викиданных и на странице, посвящённой этой таблице https://olo.wikipedia.org/wiki/Hiimiellizien_alguainehien_periodalline_sisteemu). Считаю, что они более актуальны и структурированы, что весьма хорошо для развития научного стиля для карельского языка [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 4. Oraskuuta 2026 kello 12.56 (MSK)
:Большинство изменений, касающихся лексики, оттуда [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 4. Oraskuuta 2026 kello 12.57 (MSK)
::Кто автор этих разработок и где именно они опубликованы? Прежде, чем изменять массу статей в Википедии, не стоит ли сначала ознакомить других людей со своими разработками? Почему не учитывалось мнение экспертов по ливвиковскому наречию карельского языка? Например, термин для свинца существует уже 8 лет и был выбран после консультации с экспертами. Зачем его менять именно сейчас и заимствовать из финского языка?
::Что касается статей о планетах и о флаге - в Большом русско-карельском словаре (ливвиковское наречие) Бойко Т.П. и Маркиановой Л.Ф. есть перевод слов: символ - simvolu, планета - planiettu, флаг - flagu. Может быть не стоит выдумывать новые формы слов, если уже есть существующие? Давайте вернёмся к тому, что было.
::Если вам хочется помочь развитию карельского языка, то не лучше ли не менять стандартные слова, а написать новую статью о предметах и явлениях, которые ещё пока не охвачены Карельской Википедией?
:: [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 4. Oraskuuta 2026 kello 19.27 (MSK)
::Пожалуйста, перед тем, как менять существующие карельские слова, изучите получше карельский язык. В его алфавите нет буквы W. А среди долгих гласных в карельском языке нет oo и ee. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 14.14 (MSK)
:::В алфавите нет, но в заимствованиях могут встречаться, например, в иностранных именах собственных (имена людей, топонимы), недавних неадаптированных заимствованиях или терминах (WC, QR-koodu, cubewano), или международных системах транслитерации, например, пиньинь или системе Поливанова. Долгие aa, oo и ee также могут встречаться в заимствованных словах, например, Aazii, treener, eepossu или koodu. [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 14.31 (MSK)
::::Примеры слов из разговорника за авторством Л. Маркиановой [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 14.40 (MSK)
:::Я так же как и вы хочу развивать Википедию и чтоб на ней не было большой путаницы и неопределённости, что есть сейчас. Но я думаю, что вряд ли в ближайшее время кто-то на официальном уровне будет озабочен транслитерацией японского и китайского для карельского языка или стандартизацией химических элементов, но можно начать отсюда. Это очень хорошо усилит самостоятельность карельского языка, на мой взгляд. А как вы думаете? [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 15.26 (MSK)
::::Да, частично согласен с Вами. Новые слова будут такими, какие мы создадим здесь. Когда Вы создаёте свои новые слова, не имеющиеся в словарях, то проблем нет. Но вот многие слова уже были созданы до Вас, например, карельское слово для обозначения свинца и других химических элементов. Причём, при создании проводились консультации с экспертами. И в таком случае стоит сначала спросить мнения тех, кто это слово создавал. А иначе возможно так, что в один прекрасный день придёт новый "специалист" и заменит и Ваши новые слова, не спросив никого. Поэтому давайте сначала обсуждать темы - здесь или в группе в соцсетях, а потом уже решать, какой вариант лучше. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 19.51 (MSK)
::::Слово "код" по-карельски тоже давно и успешно употребляется в СМИ и в интернете, например, "Telefonan koudu" (https://olo.ruwiki.ru/wiki/Kondupohju) [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 20.26 (MSK)
:::::Насчёт слова "Код", если оно в такой форме действительно используется, то я поменяю написание в шаблоне на "koudu" обратно. Насчёт химических элементов хотелось бы обсудить в виду того, что многие элементы выглядят как просто русские слова, записанные латиницей. В русских заимствованиях нет ничего плохого, особенно когда они уже устоявшиеся с давних времён, но в новой лексике, думаю, к вводу новых слов стоит подходить с более комплексным подходом. Например, среди называний элементов есть как названия более латинизированные, кончающиеся на -um, так и, как написано выше, с полностью русскоязычным написанием, в некоторых даже перенята замена H на Г как в русском языке, например, '''G'''afnii, когда в карельском оригинальная фонема присутствует. Где-то есть дифтонги, а где-то нет. И самое грустное, что в словари они так и не вошли, даже нет вариантов для самых базовых элементов. Базовые элементы есть в словарях собственно-карельского, можно их позаимствовать оттуда, а остальные привести к общей форме на -um с некоторыми особенностями карельской фонетики, например, не как в финском Kalsium, а Kalčium, Sirkonium, где оригинальный близкий к Ц в карельском усваивается как S, как в слове Sivilizatsii, Europium с подходящим и довольно частым дифтонгом вначале и как многие слова на -АВ, -ОВ. -ЕВ, например, časounu или souhouzu, и так далее. Получится некая общая для всех карельских наречий таблица с разницей лишь в паре элементов, а главное, понятная и легко усваиваемая, так как окончание на -um как в ливвиковском, так и в собственно-карельском склоняется по самой стандартной для наречия модели. Ну и близкая к оригинальным латинским наименованиям форма позволит и в будущем легко принимать в карельский язык химические термины. Как вы считаете? [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 21.01 (MSK)
:::::: Звучит как оригинальное исследование ([[ru:ВП:ОРИСС]], [[en:WP:OR]], [[fi:WP:EUT]]). Давайте вы сначала напишете статью с этими соображениями, опубликуете её в рецензируемом журнале (или хотя бы в тезисах какой-нибудь конференеции), а потом сошлётесь на неё на страничках нашей Википедии. [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 9. Oraskuuta 2026 kello 10.58 (MSK)
:::::Варианта Jygeitina нет в словарях, но если это и вправду специально составленный термин, то выглядит хорошо. Извините за данную оплошность с Lyijy [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 21.13 (MSK)
::::::С принципами написания слов, изложенными Вами, можно согласиться. Но проблема в том, что сейчас пока большинство говорящих и изучающих карельский язык берут информацию о написании из словарей (например Большого русско-карельского словаря Бойко и Маркиановой) и из карелоязычных СМИ, в которых не только нет научных терминов, но и совпадающие случаи переводятся по разному. Например,"европейский" - "jevroupan", но "часовня" - "časounu". Необходимо работать с учёными-составителями словарей и приходить к общему знаменателю. Согласитесь, в Википедии исправить статью намного легче, чем статью в бумажном словаре. Поэтому, может быть временно оставить спорные случаи как они есть сейчас, а в новых словах (и словарях) применять новый подход. И конечно, надо быть на связи со всеми экспертами по карельскому языку, которые входят в Термино-Орфографическую Комиссию, и убеждать их принять новые подходы. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 22.24 (MSK)
:::::::В Финляндии в СМИ используется вариант Eurouppu. Это слово вообще многострадальное, у него в одном словаре 3-4 варианта может встретиться разных, но, как будто, это самый приемлемый и произносится удобно. [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 22.27 (MSK)
::::::::в СМИ на ливвиковском карельском языке [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 22.27 (MSK)
:::::::::Приводите примеры, когда что-либо утверждаете.
:::::::::И ещё раз - давайте не будем менять устоявшиеся названия стран. Не будьте святее финнов, которые оставили названия для Ирландии и Шотландии как есть без добавлений mua. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 23.04 (MSK)
::::::::::Eurouppu, например, тут https://yle.fi/a/74-20074201
::::::::::Про Ирландию и Шотландию нет в словаре вариантов, приходилось искать, но как будто вариант образования на подобие Уэльса (Kymrinmua) вполне неплох. В эстонском языке по такой же модели, например, строится, Iirimaa, Šotimaa, Kõmrimaa* иногда. Полукалька с английского, тут ещё Thaimua есть на ливви-вики [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 23.40 (MSK)
:::::::::::С этим можно было бы согласиться, но я предлагаю не спешить со спорными названиями, а вынести всё на широкую дискуссию с участием экспертов. Есть много других тем, которые безболезненно можно развивать в статьях в Википедии прямо сейчас, которые ещё не затронуты вообще - физика, математика, биология и т.д. Давайте не устраивать войну статей. Ведь карельский язык намного шире, чем географические и химические термины. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 9. Oraskuuta 2026 kello 00.09 (MSK)
:::::::: А в СМИ на ливвиковском языке в Карелии используют вариант Jevrouppu: https://dictorpus.krc.karelia.ru/en/corpus/text/2361 (тест из "Oma Mua"). [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 9. Oraskuuta 2026 kello 11.08 (MSK)
:::::::::Добрый день, там не только вариант Jevrouppu встречается, вот примеры: [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 9. Oraskuuta 2026 kello 14.29 (MSK)
:::::::::[[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 9. Oraskuuta 2026 kello 14.30 (MSK)
:::::::::Примеры: [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 9. Oraskuuta 2026 kello 14.36 (MSK)
:::::::::Примеры:
:::::::::# Nadežda Mičurova. Tervehytty parandai griba.
:::::::::# Valentina Libertsova. 25 vigua, mikse pidäy lugie Oma Mua -lehtie. Lugijan merkit.
:::::::::[[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 9. Oraskuuta 2026 kello 14.39 (MSK)
:::::::::: И ещё 5 копеек: [[:File:Petroskoi, Jevroupan uuličču 2.jpg]] [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 11. Kezäkuuta 2026 kello 11.29 (MSK)
:::::::::::К списку названий переводов улиц имеется некоторое количество вопросов. Например, из ниоткуда взявшиеся дифтонги в фамилиях, например, Čapuajevan, Ruazinan, Terouhinan и etc, или разные формы одних и тех же корней в словах, например, '''Avtou'''busan и '''Auto'''miehen. Ни в коем случае не несу смысл, что лучше бы вообще не делали, наоборот это очень круто, что на улицах Петрозаводска со временем карельского языка побольше становится. Вариант же Jevrouppu, полагаю, выбран по принципу максимальной схожести с формой из русского языка. Тем более, в СМИ и в литературе и другие формы этого слова встречаются. [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 11. Kezäkuuta 2026 kello 22.50 (MSK)
== Moduuli:Wikidata/number ==
Горшочек, не вари!
Я сделаю заплатку для Moduuli:Wikidata/number, чтоб на declination для лебедя не спотыкался. [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 3. Kezäkuuta 2026 kello 23.56 (MSK)
:Спасибо большое. Будет очень круто! [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 3. Kezäkuuta 2026 kello 23.57 (MSK)
: Поправил.<br> Насколько я понимаю, для протяжённых объектов по-хорошему нужно показывать диапазоном. Но это надо побольше кода написать, чтобы определять, протяжённый объект или нет... [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 3. Kezäkuuta 2026 kello 23.59 (MSK)
== шаблоны/модули ==
Хорошо б, конечно, если бы вы при копировании шаблонов/модулей указывали, откуда вы их взяли. Всё-таки лицензия CC-BY-SA требует указания автора и источника. Это можно делать в пояснении к правке, которой создаётся новая страница. Либо добавить в код модуля в комментарий в шапке. Либо добавить в текст документации шаблона или модуля. Кстати, при копировании шаблонов из других вики надо бы также копировать и документацию (это подстраница /doc). [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 5. Kezäkuuta 2026 kello 11.33 (MSK)
25ypanwh08fiiqya6z5bqgk8pusq9rs
50973
50962
2026-06-12T05:28:24Z
Olksolo
356
vastaus käyttäjän Fembriha viestiin ([[mw:c:Special:MyLanguage/User:JWBTH/CD|CD]])
50973
wikitext
text/x-wiki
Перед тем, как в корне менять все названия химических элеметов, сначала следует посоветоваться с авторами этих статей и со знатоками карельского языка. Не нужно слепо копировать эти названия из финского языка. Давайте обсудим. Если ответа не последует, все изменения будут удалены. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 3. Oraskuuta 2026 kello 22.48 (MSK)
:Добрый день. Недавно в сети появились разработки на ливвиковском карельском и северном собственно-карельском наречиях, касающиеся астрономических терминов, названий государств и территорий и таблицы Менделеева (файл с таблицей есть на викиданных и на странице, посвящённой этой таблице https://olo.wikipedia.org/wiki/Hiimiellizien_alguainehien_periodalline_sisteemu). Считаю, что они более актуальны и структурированы, что весьма хорошо для развития научного стиля для карельского языка [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 4. Oraskuuta 2026 kello 12.56 (MSK)
:Большинство изменений, касающихся лексики, оттуда [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 4. Oraskuuta 2026 kello 12.57 (MSK)
::Кто автор этих разработок и где именно они опубликованы? Прежде, чем изменять массу статей в Википедии, не стоит ли сначала ознакомить других людей со своими разработками? Почему не учитывалось мнение экспертов по ливвиковскому наречию карельского языка? Например, термин для свинца существует уже 8 лет и был выбран после консультации с экспертами. Зачем его менять именно сейчас и заимствовать из финского языка?
::Что касается статей о планетах и о флаге - в Большом русско-карельском словаре (ливвиковское наречие) Бойко Т.П. и Маркиановой Л.Ф. есть перевод слов: символ - simvolu, планета - planiettu, флаг - flagu. Может быть не стоит выдумывать новые формы слов, если уже есть существующие? Давайте вернёмся к тому, что было.
::Если вам хочется помочь развитию карельского языка, то не лучше ли не менять стандартные слова, а написать новую статью о предметах и явлениях, которые ещё пока не охвачены Карельской Википедией?
:: [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 4. Oraskuuta 2026 kello 19.27 (MSK)
::Пожалуйста, перед тем, как менять существующие карельские слова, изучите получше карельский язык. В его алфавите нет буквы W. А среди долгих гласных в карельском языке нет oo и ee. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 14.14 (MSK)
:::В алфавите нет, но в заимствованиях могут встречаться, например, в иностранных именах собственных (имена людей, топонимы), недавних неадаптированных заимствованиях или терминах (WC, QR-koodu, cubewano), или международных системах транслитерации, например, пиньинь или системе Поливанова. Долгие aa, oo и ee также могут встречаться в заимствованных словах, например, Aazii, treener, eepossu или koodu. [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 14.31 (MSK)
::::Примеры слов из разговорника за авторством Л. Маркиановой [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 14.40 (MSK)
:::Я так же как и вы хочу развивать Википедию и чтоб на ней не было большой путаницы и неопределённости, что есть сейчас. Но я думаю, что вряд ли в ближайшее время кто-то на официальном уровне будет озабочен транслитерацией японского и китайского для карельского языка или стандартизацией химических элементов, но можно начать отсюда. Это очень хорошо усилит самостоятельность карельского языка, на мой взгляд. А как вы думаете? [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 15.26 (MSK)
::::Да, частично согласен с Вами. Новые слова будут такими, какие мы создадим здесь. Когда Вы создаёте свои новые слова, не имеющиеся в словарях, то проблем нет. Но вот многие слова уже были созданы до Вас, например, карельское слово для обозначения свинца и других химических элементов. Причём, при создании проводились консультации с экспертами. И в таком случае стоит сначала спросить мнения тех, кто это слово создавал. А иначе возможно так, что в один прекрасный день придёт новый "специалист" и заменит и Ваши новые слова, не спросив никого. Поэтому давайте сначала обсуждать темы - здесь или в группе в соцсетях, а потом уже решать, какой вариант лучше. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 19.51 (MSK)
::::Слово "код" по-карельски тоже давно и успешно употребляется в СМИ и в интернете, например, "Telefonan koudu" (https://olo.ruwiki.ru/wiki/Kondupohju) [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 20.26 (MSK)
:::::Насчёт слова "Код", если оно в такой форме действительно используется, то я поменяю написание в шаблоне на "koudu" обратно. Насчёт химических элементов хотелось бы обсудить в виду того, что многие элементы выглядят как просто русские слова, записанные латиницей. В русских заимствованиях нет ничего плохого, особенно когда они уже устоявшиеся с давних времён, но в новой лексике, думаю, к вводу новых слов стоит подходить с более комплексным подходом. Например, среди называний элементов есть как названия более латинизированные, кончающиеся на -um, так и, как написано выше, с полностью русскоязычным написанием, в некоторых даже перенята замена H на Г как в русском языке, например, '''G'''afnii, когда в карельском оригинальная фонема присутствует. Где-то есть дифтонги, а где-то нет. И самое грустное, что в словари они так и не вошли, даже нет вариантов для самых базовых элементов. Базовые элементы есть в словарях собственно-карельского, можно их позаимствовать оттуда, а остальные привести к общей форме на -um с некоторыми особенностями карельской фонетики, например, не как в финском Kalsium, а Kalčium, Sirkonium, где оригинальный близкий к Ц в карельском усваивается как S, как в слове Sivilizatsii, Europium с подходящим и довольно частым дифтонгом вначале и как многие слова на -АВ, -ОВ. -ЕВ, например, časounu или souhouzu, и так далее. Получится некая общая для всех карельских наречий таблица с разницей лишь в паре элементов, а главное, понятная и легко усваиваемая, так как окончание на -um как в ливвиковском, так и в собственно-карельском склоняется по самой стандартной для наречия модели. Ну и близкая к оригинальным латинским наименованиям форма позволит и в будущем легко принимать в карельский язык химические термины. Как вы считаете? [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 21.01 (MSK)
:::::: Звучит как оригинальное исследование ([[ru:ВП:ОРИСС]], [[en:WP:OR]], [[fi:WP:EUT]]). Давайте вы сначала напишете статью с этими соображениями, опубликуете её в рецензируемом журнале (или хотя бы в тезисах какой-нибудь конференеции), а потом сошлётесь на неё на страничках нашей Википедии. [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 9. Oraskuuta 2026 kello 10.58 (MSK)
:::::Варианта Jygeitina нет в словарях, но если это и вправду специально составленный термин, то выглядит хорошо. Извините за данную оплошность с Lyijy [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 21.13 (MSK)
::::::С принципами написания слов, изложенными Вами, можно согласиться. Но проблема в том, что сейчас пока большинство говорящих и изучающих карельский язык берут информацию о написании из словарей (например Большого русско-карельского словаря Бойко и Маркиановой) и из карелоязычных СМИ, в которых не только нет научных терминов, но и совпадающие случаи переводятся по разному. Например,"европейский" - "jevroupan", но "часовня" - "časounu". Необходимо работать с учёными-составителями словарей и приходить к общему знаменателю. Согласитесь, в Википедии исправить статью намного легче, чем статью в бумажном словаре. Поэтому, может быть временно оставить спорные случаи как они есть сейчас, а в новых словах (и словарях) применять новый подход. И конечно, надо быть на связи со всеми экспертами по карельскому языку, которые входят в Термино-Орфографическую Комиссию, и убеждать их принять новые подходы. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 22.24 (MSK)
:::::::В Финляндии в СМИ используется вариант Eurouppu. Это слово вообще многострадальное, у него в одном словаре 3-4 варианта может встретиться разных, но, как будто, это самый приемлемый и произносится удобно. [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 22.27 (MSK)
::::::::в СМИ на ливвиковском карельском языке [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 22.27 (MSK)
:::::::::Приводите примеры, когда что-либо утверждаете.
:::::::::И ещё раз - давайте не будем менять устоявшиеся названия стран. Не будьте святее финнов, которые оставили названия для Ирландии и Шотландии как есть без добавлений mua. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 8. Oraskuuta 2026 kello 23.04 (MSK)
::::::::::Eurouppu, например, тут https://yle.fi/a/74-20074201
::::::::::Про Ирландию и Шотландию нет в словаре вариантов, приходилось искать, но как будто вариант образования на подобие Уэльса (Kymrinmua) вполне неплох. В эстонском языке по такой же модели, например, строится, Iirimaa, Šotimaa, Kõmrimaa* иногда. Полукалька с английского, тут ещё Thaimua есть на ливви-вики [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 8. Oraskuuta 2026 kello 23.40 (MSK)
:::::::::::С этим можно было бы согласиться, но я предлагаю не спешить со спорными названиями, а вынести всё на широкую дискуссию с участием экспертов. Есть много других тем, которые безболезненно можно развивать в статьях в Википедии прямо сейчас, которые ещё не затронуты вообще - физика, математика, биология и т.д. Давайте не устраивать войну статей. Ведь карельский язык намного шире, чем географические и химические термины. [[Käyttäi:Onegaborg|Onegaborg]] ([[Käyttäi pagin:Onegaborg|pagin]]) 9. Oraskuuta 2026 kello 00.09 (MSK)
:::::::: А в СМИ на ливвиковском языке в Карелии используют вариант Jevrouppu: https://dictorpus.krc.karelia.ru/en/corpus/text/2361 (тест из "Oma Mua"). [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 9. Oraskuuta 2026 kello 11.08 (MSK)
:::::::::Добрый день, там не только вариант Jevrouppu встречается, вот примеры: [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 9. Oraskuuta 2026 kello 14.29 (MSK)
:::::::::[[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 9. Oraskuuta 2026 kello 14.30 (MSK)
:::::::::Примеры: [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 9. Oraskuuta 2026 kello 14.36 (MSK)
:::::::::Примеры:
:::::::::# Nadežda Mičurova. Tervehytty parandai griba.
:::::::::# Valentina Libertsova. 25 vigua, mikse pidäy lugie Oma Mua -lehtie. Lugijan merkit.
:::::::::[[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 9. Oraskuuta 2026 kello 14.39 (MSK)
:::::::::: И ещё 5 копеек: [[:File:Petroskoi, Jevroupan uuličču 2.jpg]] [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 11. Kezäkuuta 2026 kello 11.29 (MSK)
:::::::::::К списку названий переводов улиц имеется некоторое количество вопросов. Например, из ниоткуда взявшиеся дифтонги в фамилиях, например, Čapuajevan, Ruazinan, Terouhinan и etc, или разные формы одних и тех же корней в словах, например, '''Avtou'''busan и '''Auto'''miehen. Ни в коем случае не несу смысл, что лучше бы вообще не делали, наоборот это очень круто, что на улицах Петрозаводска со временем карельского языка побольше становится. Вариант же Jevrouppu, полагаю, выбран по принципу максимальной схожести с формой из русского языка. Тем более, в СМИ и в литературе и другие формы этого слова встречаются. [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 11. Kezäkuuta 2026 kello 22.50 (MSK)
:::::::::::: Сойдёмся на том, что это вариативность написания. Она бывает и в других языках (матрац/матрас, зверушка/зверюшка, калоши/галоши). [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 12. Kezäkuuta 2026 kello 08.28 (MSK)
== Moduuli:Wikidata/number ==
Горшочек, не вари!
Я сделаю заплатку для Moduuli:Wikidata/number, чтоб на declination для лебедя не спотыкался. [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 3. Kezäkuuta 2026 kello 23.56 (MSK)
:Спасибо большое. Будет очень круто! [[Käyttäi:Fembriha|Fembriha]] ([[Käyttäi pagin:Fembriha|pagin]]) 3. Kezäkuuta 2026 kello 23.57 (MSK)
: Поправил.<br> Насколько я понимаю, для протяжённых объектов по-хорошему нужно показывать диапазоном. Но это надо побольше кода написать, чтобы определять, протяжённый объект или нет... [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 3. Kezäkuuta 2026 kello 23.59 (MSK)
== шаблоны/модули ==
Хорошо б, конечно, если бы вы при копировании шаблонов/модулей указывали, откуда вы их взяли. Всё-таки лицензия CC-BY-SA требует указания автора и источника. Это можно делать в пояснении к правке, которой создаётся новая страница. Либо добавить в код модуля в комментарий в шапке. Либо добавить в текст документации шаблона или модуля. Кстати, при копировании шаблонов из других вики надо бы также копировать и документацию (это подстраница /doc). [[Käyttäi:Olksolo|Olksolo]] ([[Käyttäi pagin:Olksolo|pagin]]) 5. Kezäkuuta 2026 kello 11.33 (MSK)
mdmdqeos9dtzsg5c56y7vmcl11fsk2e
Moduuli:Navbox
828
16858
50941
2026-06-11T18:30:22Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Navbox&oldid=1340240090
50941
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Navbox&oldid=1340240090
require('strict')
local p = {}
local cfg = mw.loadData('Module:Navbox/configuration')
local inArray = require("Module:TableTools").inArray
local getArgs -- lazily initialized
local hiding_templatestyles = {}
-- global passthrough variables
local passthrough = {
[cfg.arg.above]=true,[cfg.arg.aboveclass]=true,[cfg.arg.abovestyle]=true,
[cfg.arg.basestyle]=true,
[cfg.arg.below]=true,[cfg.arg.belowclass]=true,[cfg.arg.belowstyle]=true,
[cfg.arg.bodyclass]=true,
[cfg.arg.groupclass]=true,
[cfg.arg.image]=true,[cfg.arg.imageclass]=true,[cfg.arg.imagestyle]=true,
[cfg.arg.imageleft]=true,[cfg.arg.imageleftstyle]=true,
[cfg.arg.listclass]=true,
[cfg.arg.name]=true,
[cfg.arg.navbar]=true,
[cfg.arg.state]=true,
[cfg.arg.title]=true,[cfg.arg.titleclass]=true,[cfg.arg.titlestyle]=true,
argHash=true
}
-- helper functions
local andnum = function(s, n) return string.format(cfg.arg[s .. '_and_num'], n) end
local isblank = function(v) return (v or '') == '' end
local function concatstrings(s)
local r = table.concat(s, '')
if r:match('^%s*$') then return nil end
return r
end
local function concatstyles(s)
local r = ''
for _, v in ipairs(s) do
v = mw.text.trim(v, "%s;")
if not isblank(v) then r = r .. v .. ';' end
end
if isblank(r) then return nil end
return r
end
local function getSubgroup(args, listnum, listText, prefix)
local subArgs = {
[cfg.arg.border] = cfg.keyword.border_subgroup,
[cfg.arg.navbar] = cfg.keyword.navbar_plain,
argHash = 0
}
local hasSubArgs = false
local subgroups_and_num = prefix and {prefix} or cfg.arg.subgroups_and_num
for k, v in pairs(args) do
k = tostring(k)
for _, w in ipairs(subgroups_and_num) do
w = string.format(w, listnum) .. "_"
if (#k > #w) and (k:sub(1, #w) == w) then
subArgs[k:sub(#w + 1)] = v
hasSubArgs = true
subArgs.argHash = subArgs.argHash + (v and #v or 0)
end
end
end
return hasSubArgs and p._navbox(subArgs) or listText
end
-- Main functions
function p._navbox(args)
if args.type == cfg.keyword.with_collapsible_groups then
return p._withCollapsibleGroups(args)
elseif args.type == cfg.keyword.with_columns then
return p._withColumns(args)
end
local function striped(wikitext, border)
-- Return wikitext with markers replaced for odd/even striping.
-- Child (subgroup) navboxes are flagged with a category that is removed
-- by parent navboxes. The result is that the category shows all pages
-- where a child navbox is not contained in a parent navbox.
local orphanCat = cfg.category.orphan
if border == cfg.keyword.border_subgroup and args[cfg.arg.orphan] ~= cfg.keyword.orphan_yes then
-- No change; striping occurs in outermost navbox.
return wikitext .. orphanCat
end
local first, second = cfg.class.navbox_odd_part, cfg.class.navbox_even_part
if args[cfg.arg.evenodd] then
if args[cfg.arg.evenodd] == cfg.keyword.evenodd_swap then
first, second = second, first
else
first = args[cfg.arg.evenodd]
second = first
end
end
local changer
if first == second then
changer = first
else
local index = 0
changer = function (code)
if code == '0' then
-- Current occurrence is for a group before a nested table.
-- Set it to first as a valid although pointless class.
-- The next occurrence will be the first row after a title
-- in a subgroup and will also be first.
index = 0
return first
end
index = index + 1
return index % 2 == 1 and first or second
end
end
local regex = orphanCat:gsub('([%[%]])', '%%%1')
return (wikitext:gsub(regex, ''):gsub(cfg.marker.regex, changer)) -- () omits gsub count
end
local function processItem(item, nowrapitems)
if item:sub(1, 2) == '{|' then
-- Applying nowrap to lines in a table does not make sense.
-- Add newlines to compensate for trim of x in |parm=x in a template.
return '\n' .. item .. '\n'
end
if nowrapitems == cfg.keyword.nowrapitems_yes then
local lines = {}
for line in (item .. '\n'):gmatch('([^\n]*)\n') do
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
if prefix and not content:match(cfg.pattern.nowrap) then
line = string.format(cfg.nowrap_item, prefix, content)
end
table.insert(lines, line)
end
item = table.concat(lines, '\n')
end
if item:match('^[*:;#]') then
return '\n' .. item .. '\n'
end
return item
end
local function has_navbar()
return args[cfg.arg.navbar] ~= cfg.keyword.navbar_off
and args[cfg.arg.navbar] ~= cfg.keyword.navbar_plain
and (
args[cfg.arg.name]
or mw.getCurrentFrame():getParent():getTitle():gsub(cfg.pattern.sandbox, '')
~= cfg.pattern.navbox
)
end
-- extract text color from css, which is the only permitted inline CSS for the navbar
local function extract_color(css_str)
-- return nil because navbar takes its argument into mw.html which handles
-- nil gracefully, removing the associated style attribute
return mw.ustring.match(';' .. css_str .. ';', '.*;%s*([Cc][Oo][Ll][Oo][Rr]%s*:%s*.-)%s*;') or nil
end
local function renderNavBar(titleCell)
if has_navbar() then
local navbar = require('Module:Navbar')._navbar
titleCell:wikitext(navbar{
[cfg.navbar.name] = args[cfg.arg.name],
[cfg.navbar.mini] = 1,
[cfg.navbar.fontstyle] = extract_color(
(args[cfg.arg.basestyle] or '') .. ';' .. (args[cfg.arg.titlestyle] or '')
)
})
end
end
local function renderTitleRow(tbl)
if not args[cfg.arg.title] then return end
local titleRow = tbl:tag('tr')
local titleCell = titleRow:tag('th'):attr('scope', 'col')
local titleColspan = 2
if args[cfg.arg.imageleft] then titleColspan = titleColspan + 1 end
if args[cfg.arg.image] then titleColspan = titleColspan + 1 end
titleCell
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.titlestyle])
:addClass(cfg.class.navbox_title)
:attr('colspan', titleColspan)
renderNavBar(titleCell)
titleCell
:tag('div')
-- id for aria-labelledby attribute
:attr('id', mw.uri.anchorEncode(args[cfg.arg.title]) .. args.argHash)
:addClass(args[cfg.arg.titleclass])
:css('font-size', '114%')
:css('margin', '0 4em')
:wikitext(processItem(args[cfg.arg.title]))
end
local function getAboveBelowColspan()
local ret = 2
if args[cfg.arg.imageleft] then ret = ret + 1 end
if args[cfg.arg.image] then ret = ret + 1 end
return ret
end
local function renderAboveRow(tbl)
if not args[cfg.arg.above] then return end
tbl:tag('tr')
:tag('td')
:addClass(cfg.class.navbox_abovebelow)
:addClass(args[cfg.arg.aboveclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.abovestyle])
:attr('colspan', getAboveBelowColspan())
:tag('div')
-- id for aria-labelledby attribute, if no title
:attr('id', (not args[cfg.arg.title]) and
(mw.uri.anchorEncode(args[cfg.arg.above]) .. args.argHash)
or nil)
:wikitext(processItem(args[cfg.arg.above], args[cfg.arg.nowrapitems]))
end
local function renderBelowRow(tbl)
if not args[cfg.arg.below] then return end
tbl:tag('tr')
:tag('td')
:addClass(cfg.class.navbox_abovebelow)
:addClass(args[cfg.arg.belowclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.belowstyle])
:attr('colspan', getAboveBelowColspan())
:tag('div')
:wikitext(processItem(args[cfg.arg.below], args[cfg.arg.nowrapitems]))
end
local function renderListRow(tbl, index, listnum, listnums_size)
local row = tbl:tag('tr')
if index == 1 and args[cfg.arg.imageleft] then
row
:tag('td')
:addClass(cfg.class.noviewer)
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '0 2px 0 0')
:cssText(args[cfg.arg.imageleftstyle])
:attr('rowspan', listnums_size)
:tag('div')
:wikitext(processItem(args[cfg.arg.imageleft]))
end
local group_and_num = andnum('group', listnum)
local groupstyle_and_num = andnum('groupstyle', listnum)
if args[group_and_num] then
local groupCell = row:tag('th')
-- id for aria-labelledby attribute, if lone group with no title or above
if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then
groupCell
:attr('id', mw.uri.anchorEncode(args[cfg.arg.group1]) .. args.argHash)
end
groupCell
:attr('scope', 'row')
:addClass(cfg.class.navbox_group)
:addClass(args[cfg.arg.groupclass])
:cssText(args[cfg.arg.basestyle])
-- If groupwidth not specified, minimize width
:css('width', args[cfg.arg.groupwidth] or '1%')
groupCell
:cssText(args[cfg.arg.groupstyle])
:cssText(args[groupstyle_and_num])
:wikitext(args[group_and_num])
end
local listCell = row:tag('td')
if args[group_and_num] then
listCell
:addClass(cfg.class.navbox_list_with_group)
else
listCell:attr('colspan', 2)
end
if not args[cfg.arg.groupwidth] then
listCell:css('width', '100%')
end
local rowstyle -- usually nil so cssText(rowstyle) usually adds nothing
if index % 2 == 1 then
rowstyle = args[cfg.arg.oddstyle]
else
rowstyle = args[cfg.arg.evenstyle]
end
local list_and_num = andnum('list', listnum)
local listText = inArray(cfg.keyword.subgroups, args[list_and_num])
and getSubgroup(args, listnum, args[list_and_num]) or args[list_and_num]
local oddEven = cfg.marker.oddeven
if listText:sub(1, 12) == '</div><table' then
-- Assume list text is for a subgroup navbox so no automatic striping for this row.
oddEven = listText:find(cfg.pattern.navbox_title) and cfg.marker.restart or cfg.class.navbox_odd_part
end
local liststyle_and_num = andnum('liststyle', listnum)
local listclass_and_num = andnum('listclass', listnum)
listCell
:css('padding', '0')
:cssText(args[cfg.arg.liststyle])
:cssText(rowstyle)
:cssText(args[liststyle_and_num])
:addClass(cfg.class.navbox_list)
:addClass(cfg.class.navbox_part .. oddEven)
:addClass(args[cfg.arg.listclass])
:addClass(args[listclass_and_num])
:tag('div')
:css('padding',
(index == 1 and args[cfg.arg.list1padding]) or args[cfg.arg.listpadding] or '0 0.25em'
)
:wikitext(processItem(listText, args[cfg.arg.nowrapitems]))
if index == 1 and args[cfg.arg.image] then
row
:tag('td')
:addClass(cfg.class.noviewer)
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '0 0 0 2px')
:cssText(args[cfg.arg.imagestyle])
:attr('rowspan', listnums_size)
:tag('div')
:wikitext(processItem(args[cfg.arg.image]))
end
end
local function has_list_class(htmlclass)
local patterns = {
'^' .. htmlclass .. '$',
'%s' .. htmlclass .. '$',
'^' .. htmlclass .. '%s',
'%s' .. htmlclass .. '%s'
}
for arg, _ in pairs(args) do
if type(arg) == 'string' and mw.ustring.find(arg, cfg.pattern.class) then
for _, pattern in ipairs(patterns) do
if mw.ustring.find(args[arg] or '', pattern) then
return true
end
end
end
end
return false
end
-- there are a lot of list classes in the wild, so we add their TemplateStyles
local function add_list_styles()
local frame = mw.getCurrentFrame()
local function add_list_templatestyles(htmlclass, templatestyles)
if has_list_class(htmlclass) then
return frame:extensionTag{
name = 'templatestyles', args = { src = templatestyles }
}
else
return ''
end
end
local hlist_styles = add_list_templatestyles('hlist', cfg.hlist_templatestyles)
local plainlist_styles = add_list_templatestyles('plainlist', cfg.plainlist_templatestyles)
-- a second workaround for [[phab:T303378]]
-- when that issue is fixed, we can actually use has_navbar not to emit the
-- tag here if we want
if has_navbar() and hlist_styles == '' then
hlist_styles = frame:extensionTag{
name = 'templatestyles', args = { src = cfg.hlist_templatestyles }
}
end
-- hlist -> plainlist is best-effort to preserve old Common.css ordering.
-- this ordering is not a guarantee because most navboxes will emit only
-- one of these classes [hlist_note]
return hlist_styles .. plainlist_styles
end
local function needsHorizontalLists(border)
if border == cfg.keyword.border_subgroup or args[cfg.arg.tracking] == cfg.keyword.tracking_no then
return false
end
return not has_list_class(cfg.pattern.hlist) and not has_list_class(cfg.pattern.plainlist)
end
local function hasBackgroundColors()
for _, key in ipairs({cfg.arg.titlestyle, cfg.arg.groupstyle,
cfg.arg.basestyle, cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('background', 1, true) then
return true
end
end
return false
end
local function hasBorders()
for _, key in ipairs({cfg.arg.groupstyle, cfg.arg.basestyle,
cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('border', 1, true) then
return true
end
end
return false
end
local function isIllegible()
local styleratio = require('Module:Color contrast')._styleratio
for key, style in pairs(args) do
if tostring(key):match(cfg.pattern.style) then
if styleratio{mw.text.unstripNoWiki(style)} < 4.5 then
return true
end
end
end
return false
end
local function getTrackingCategories(border)
local cats = {}
if needsHorizontalLists(border) then table.insert(cats, cfg.category.horizontal_lists) end
if hasBackgroundColors() then table.insert(cats, cfg.category.background_colors) end
if isIllegible() then table.insert(cats, cfg.category.illegible) end
if hasBorders() then table.insert(cats, cfg.category.borders) end
return cats
end
local function renderTrackingCategories(builder, border)
local title = mw.title.getCurrentTitle()
if title.namespace ~= 10 then return end -- not in template space
local subpage = title.subpageText
if subpage == cfg.keyword.subpage_doc or subpage == cfg.keyword.subpage_sandbox
or subpage == cfg.keyword.subpage_testcases then return end
for _, cat in ipairs(getTrackingCategories(border)) do
builder:wikitext('[[Category:' .. cat .. ']]')
end
end
local function renderMainTable(border, listnums)
local tbl = mw.html.create('table')
:addClass(cfg.class.nowraplinks)
:addClass(args[cfg.arg.bodyclass])
local state = args[cfg.arg.state]
if args[cfg.arg.title] and state ~= cfg.keyword.state_plain and state ~= cfg.keyword.state_off then
if state == cfg.keyword.state_collapsed then
state = cfg.class.collapsed
end
tbl
:addClass(cfg.class.collapsible)
:addClass(state or cfg.class.autocollapse)
end
tbl:css('border-spacing', 0)
if border == cfg.keyword.border_subgroup or border == cfg.keyword.border_none then
tbl
:addClass(cfg.class.navbox_subgroup)
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
else -- regular navbox - bodystyle and style will be applied to the wrapper table
tbl
:addClass(cfg.class.navbox_inner)
:css('background', 'transparent')
:css('color', 'inherit')
end
tbl:cssText(args[cfg.arg.innerstyle])
renderTitleRow(tbl)
renderAboveRow(tbl)
local listnums_size = #listnums
for i, listnum in ipairs(listnums) do
renderListRow(tbl, i, listnum, listnums_size)
end
renderBelowRow(tbl)
return tbl
end
local function add_navbox_styles(hiding_templatestyles)
local frame = mw.getCurrentFrame()
-- This is a lambda so that it doesn't need the frame as a parameter
local function add_user_styles(templatestyles)
if not isblank(templatestyles) then
return frame:extensionTag{
name = 'templatestyles', args = { src = templatestyles }
}
end
return ''
end
-- get templatestyles. load base from config so that Lua only needs to do
-- the work once of parser tag expansion
local base_templatestyles = cfg.templatestyles
local templatestyles = add_user_styles(args[cfg.arg.templatestyles])
local child_templatestyles = add_user_styles(args[cfg.arg.child_templatestyles])
-- The 'navbox-styles' div exists to wrap the styles to work around T200206
-- more elegantly. Instead of combinatorial rules, this ends up being linear
-- number of CSS rules.
return mw.html.create('div')
:addClass(cfg.class.navbox_styles)
:wikitext(
add_list_styles() .. -- see [hlist_note] applied to 'before base_templatestyles'
base_templatestyles ..
templatestyles ..
child_templatestyles ..
table.concat(hiding_templatestyles)
)
:done()
end
-- work around [[phab:T303378]]
-- for each arg: find all the templatestyles strip markers, insert them into a
-- table. then remove all templatestyles markers from the arg
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
local argHash = 0
for k, arg in pairs(args) do
if type(arg) == 'string' then
for marker in string.gfind(arg, strip_marker_pattern) do
table.insert(hiding_templatestyles, marker)
end
argHash = argHash + #arg
args[k] = string.gsub(arg, strip_marker_pattern, '')
end
end
if not args.argHash then args.argHash = argHash end
local listnums = {}
for k, _ in pairs(args) do
if type(k) == 'string' then
local listnum = k:match(cfg.pattern.listnum)
if listnum and args[andnum('list', tonumber(listnum))] then
table.insert(listnums, tonumber(listnum))
end
end
end
table.sort(listnums)
local border = mw.text.trim(args[cfg.arg.border] or args[1] or '')
if border == cfg.keyword.border_child then
border = cfg.keyword.border_subgroup
end
-- render the main body of the navbox
local tbl = renderMainTable(border, listnums)
local res = mw.html.create()
-- render the appropriate wrapper for the navbox, based on the border param
if border == cfg.keyword.border_none then
res:node(add_navbox_styles(hiding_templatestyles))
local nav = res:tag('div')
:attr('role', 'navigation')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above] or (args[cfg.arg.group1]
and not args[cfg.arg.group2]) then
nav:attr(
'aria-labelledby',
mw.uri.anchorEncode(
args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
) .. args.argHash
)
else
nav:attr('aria-label', cfg.aria_label .. args.argHash)
end
elseif border == cfg.keyword.border_subgroup then
-- We assume that this navbox is being rendered in a list cell of a
-- parent navbox, and is therefore inside a div with padding:0em 0.25em.
-- We start with a </div> to avoid the padding being applied, and at the
-- end add a <div> to balance out the parent's </div>
res
:wikitext('</div>')
:node(tbl)
:wikitext('<div>')
else
res:node(add_navbox_styles(hiding_templatestyles))
local nav = res:tag('div')
:attr('role', 'navigation')
:addClass(cfg.class.navbox)
:addClass(args[cfg.arg.navboxclass])
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
:css('padding', '3px')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above]
or (args[cfg.arg.group1] and not args[cfg.arg.group2]) then
nav:attr(
'aria-labelledby',
mw.uri.anchorEncode(
args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
) .. args.argHash
)
else
nav:attr('aria-label', cfg.aria_label .. args.argHash)
end
end
if (args[cfg.arg.nocat] or cfg.keyword.nocat_false):lower() == cfg.keyword.nocat_false then
renderTrackingCategories(res, border)
end
return striped(tostring(res), border)
end --p._navbox
function p._withCollapsibleGroups(pargs)
-- table for args passed to navbox
local targs = {}
-- process args
local passthroughLocal = {
[cfg.arg.bodystyle] = true,
[cfg.arg.border] = true,
[cfg.arg.style] = true,
}
for k,v in pairs(pargs) do
if k and type(k) == 'string' then
if passthrough[k] or passthroughLocal[k] then
targs[k] = v
elseif (k:match(cfg.pattern.num)) then
local n = k:match(cfg.pattern.num)
local list_and_num = andnum('list', n)
if ((k:match(cfg.pattern.listnum) or k:match(cfg.pattern.contentnum))
and targs[list_and_num] == nil
and pargs[andnum('group', n)] == nil
and pargs[andnum('sect', n)] == nil
and pargs[andnum('section', n)] == nil) then
targs[list_and_num] = concatstrings({
pargs[list_and_num] or '',
pargs[andnum('content', n)] or ''
})
if (targs[list_and_num] and inArray(cfg.keyword.subgroups, targs[list_and_num])) then
targs[list_and_num] = getSubgroup(pargs, n, targs[list_and_num])
end
elseif ((k:match(cfg.pattern.groupnum) or k:match(cfg.pattern.sectnum) or k:match(cfg.pattern.sectionnum))
and targs[list_and_num] == nil) then
local titlestyle = concatstyles({
pargs[cfg.arg.groupstyle] or '',
pargs[cfg.arg.secttitlestyle] or '',
pargs[andnum('groupstyle', n)] or '',
pargs[andnum('sectiontitlestyle', n)] or ''
})
local liststyle = concatstyles({
pargs[cfg.arg.liststyle] or '',
pargs[cfg.arg.contentstyle] or '',
pargs[andnum('liststyle', n)] or '',
pargs[andnum('contentstyle', n)] or ''
})
local title = concatstrings({
pargs[andnum('group', n)] or '',
pargs[andnum('sect', n)] or '',
pargs[andnum('section', n)] or ''
})
local list = concatstrings({
pargs[list_and_num] or '',
pargs[andnum('content', n)] or ''
})
if list and inArray(cfg.keyword.subgroups, list) then
list = getSubgroup(pargs, n, list)
end
local abbr_and_num = andnum('abbr', n)
local state = (pargs[abbr_and_num] and pargs[abbr_and_num] == pargs[cfg.arg.selected])
and cfg.keyword.state_uncollapsed
or (pargs[andnum('state', n)] or cfg.keyword.state_collapsed)
targs[list_and_num] =p._navbox({
cfg.keyword.border_child,
[cfg.arg.navbar] = cfg.keyword.navbar_plain,
[cfg.arg.state] = state,
[cfg.arg.basestyle] = pargs[cfg.arg.basestyle],
[cfg.arg.title] = title,
[cfg.arg.titlestyle] = titlestyle,
[andnum('list', 1)] = list,
[cfg.arg.liststyle] = liststyle,
[cfg.arg.listclass] = pargs[andnum('listclass', n)],
[cfg.arg.image] = pargs[andnum('image', n)],
[cfg.arg.imageleft] = pargs[andnum('imageleft', n)],
[cfg.arg.listpadding] = pargs[cfg.arg.listpadding],
argHash = pargs.argHash
})
end
end
end
end
-- ordering of style and bodystyle
targs[cfg.arg.style] = concatstyles({targs[cfg.arg.style] or '', targs[cfg.arg.bodystyle] or ''})
targs[cfg.arg.bodystyle] = nil
-- child or subgroup
if targs[cfg.arg.border] == nil then targs[cfg.arg.border] = pargs[1] end
return p._navbox(targs)
end --p._withCollapsibleGroups
function p._withColumns(pargs)
-- table for args passed to navbox
local targs = {}
-- tables of column numbers
local colheadernums = {}
local colnums = {}
local colfooternums = {}
-- process args
local passthroughLocal = {
[cfg.arg.evenstyle]=true,
[cfg.arg.groupstyle]=true,
[cfg.arg.liststyle]=true,
[cfg.arg.oddstyle]=true,
[cfg.arg.state]=true,
}
for k,v in pairs(pargs) do
if passthrough[k] or passthroughLocal[k] then
targs[k] = v
elseif type(k) == 'string' then
if k:match(cfg.pattern.listnum) then
local n = k:match(cfg.pattern.listnum)
targs[andnum('liststyle', n + 2)] = pargs[andnum('liststyle', n)]
targs[andnum('group', n + 2)] = pargs[andnum('group', n)]
targs[andnum('groupstyle', n + 2)] = pargs[andnum('groupstyle', n)]
if v and inArray(cfg.keyword.subgroups, v) then
targs[andnum('list', n + 2)] = getSubgroup(pargs, n, v)
else
targs[andnum('list', n + 2)] = v
end
elseif (k:match(cfg.pattern.colheadernum) and v ~= '') then
table.insert(colheadernums, tonumber(k:match(cfg.pattern.colheadernum)))
elseif (k:match(cfg.pattern.colnum) and v ~= '') then
table.insert(colnums, tonumber(k:match(cfg.pattern.colnum)))
elseif (k:match(cfg.pattern.colfooternum) and v ~= '') then
table.insert(colfooternums, tonumber(k:match(cfg.pattern.colfooternum)))
end
end
end
table.sort(colheadernums)
table.sort(colnums)
table.sort(colfooternums)
-- HTML table for list1
local coltable = mw.html.create( 'table' ):addClass('navbox-columns-table')
local row, col
local tablestyle = ( (#colheadernums > 0) or (not isblank(pargs[cfg.arg.fullwidth])) )
and 'width:100%'
or 'width:auto; margin-left:auto; margin-right:auto'
coltable:cssText(concatstyles({
'border-spacing: 0px; text-align:left',
tablestyle,
pargs[cfg.arg.coltablestyle] or ''
}))
--- Header row ---
if (#colheadernums > 0) then
row = coltable:tag('tr')
for k, n in ipairs(colheadernums) do
col = row:tag('th'):addClass('navbox-abovebelow')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'font-weight:bold',
pargs[cfg.arg.colheaderstyle] or '',
pargs[andnum('colheaderstyle', n)] or ''
}))
col:attr('colspan', tonumber(pargs[andnum('colheadercolspan', n)]))
col:wikitext(pargs[andnum('colheader', n)])
end
end
--- Main columns ---
row = coltable:tag('tr'):css('vertical-align', 'top')
for k, n in ipairs(colnums) do
if k == 1 and isblank(pargs[andnum('colheader', 1)])
and isblank(pargs[andnum('colfooter', 1)])
and isblank(pargs[cfg.arg.fullwidth]) then
local nopad = inArray(
{'off', '0', '0em', '0px'},
mw.ustring.gsub(pargs[cfg.arg.padding] or '', '[;%%]', ''))
if not nopad then
row:tag('td'):wikitext(' ')
:css('width', (pargs[cfg.arg.padding] or '5em'))
end
end
col = row:tag('td'):addClass('navbox-list')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'padding:0px',
pargs[cfg.arg.colstyle] or '',
((n%2 == 0) and pargs[cfg.arg.evencolstyle] or pargs[cfg.arg.oddcolstyle]) or '',
pargs[andnum('colstyle', n)] or '',
'width:' .. (pargs[andnum('colwidth', n)] or pargs[cfg.arg.colwidth] or '10em')
}))
local wt = pargs[andnum('col', n)]
if wt and inArray(cfg.keyword.subgroups, wt) then
wt = getSubgroup(pargs, n, wt, cfg.arg.col_and_num)
end
col:tag('div'):newline():wikitext(wt):newline()
end
--- Footer row ---
if (#colfooternums > 0) then
row = coltable:tag('tr')
for k, n in ipairs(colfooternums) do
col = row:tag('td'):addClass('navbox-abovebelow')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'font-weight:bold',
pargs[cfg.arg.colfooterstyle] or '',
pargs[andnum('colfooterstyle', n)] or ''
}))
col:attr('colspan', tonumber(pargs[andnum('colfootercolspan', n)]))
col:wikitext(pargs[andnum('colfooter', n)])
end
end
-- assign table to list1
targs[andnum('list', 1)] = tostring(coltable)
if isblank(pargs[andnum('colheader', 1)])
and isblank(pargs[andnum('col', 1)])
and isblank(pargs[andnum('colfooter', 1)]) then
targs[andnum('list', 1)] = targs[andnum('list', 1)] ..
cfg.category.without_first_col
end
-- Other parameters
targs[cfg.arg.border] = pargs[cfg.arg.border] or pargs[1]
targs[cfg.arg.evenodd] = (not isblank(pargs[cfg.arg.evenodd])) and pargs[cfg.arg.evenodd] or nil
targs[cfg.arg.list1padding] = '0px'
targs[andnum('liststyle', 1)] = 'background:transparent;color:inherit;'
targs[cfg.arg.style] = concatstyles({pargs[cfg.arg.style], pargs[cfg.arg.bodystyle]})
targs[cfg.arg.tracking] = 'no'
return p._navbox(targs)
end --p._withColumns
-- Template entry points
function p.navbox (frame, boxtype)
local function readArgs(args, prefix)
local function readSubgroups(element, i)
if inArray(cfg.keyword.subgroups, args[prefix .. andnum(element, i)]) then
for _, v in ipairs(cfg.arg.subgroups_and_num) do
readArgs(args, prefix .. string.format(v, i) .. "_")
end
readArgs(args, prefix .. andnum('col', i) .. "_")
end
end
-- Read the arguments in the order they'll be output in, to make references
-- number in the right order.
local _
_ = args[prefix .. cfg.arg.title]
_ = args[prefix .. cfg.arg.above]
-- Limit this to 20 as covering 'most' cases (that's a SWAG) and because
-- iterator approach won't work here
local boxtype = args.type or cfg.keyword[boxtype]
if boxtype == cfg.keyword.with_columns then
for i = 1, 20 do
_ = args[prefix .. andnum('colheader', i)]
end
for i = 1, 20 do
readSubgroups('col', i)
end
for i = 1, 20 do
_ = args[prefix .. andnum('colfooter', i)]
end
end
for i = 1, 20 do
_ = args[prefix .. andnum('group', i)]
readSubgroups('list', i)
end
_ = args[prefix .. cfg.arg.below]
end
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local args = getArgs(frame, {wrappers = {cfg.pattern[boxtype or 'navbox']}})
readArgs(args, "")
args.argHash = nil -- we shouldn't accept argHash passed from a template
args.type = args.type or cfg.keyword[boxtype]
return p['_navbox'](args)
end
p[cfg.keyword.with_collapsible_groups] = function (frame)
return p.navbox(frame, 'with_collapsible_groups')
end
p[cfg.keyword.with_columns] = function (frame)
return p.navbox(frame, 'with_columns')
end
return p
nrcgb1bmfyuyw5r12agmmfcj64kblby
50946
50941
2026-06-11T18:38:58Z
Olksolo
356
fix namespace
50946
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Navbox&oldid=1340240090
require('strict')
local p = {}
local cfg = mw.loadData('Moduuli:Navbox/configuration')
local inArray = require("Moduuli:TableTools").inArray
local getArgs -- lazily initialized
local hiding_templatestyles = {}
-- global passthrough variables
local passthrough = {
[cfg.arg.above]=true,[cfg.arg.aboveclass]=true,[cfg.arg.abovestyle]=true,
[cfg.arg.basestyle]=true,
[cfg.arg.below]=true,[cfg.arg.belowclass]=true,[cfg.arg.belowstyle]=true,
[cfg.arg.bodyclass]=true,
[cfg.arg.groupclass]=true,
[cfg.arg.image]=true,[cfg.arg.imageclass]=true,[cfg.arg.imagestyle]=true,
[cfg.arg.imageleft]=true,[cfg.arg.imageleftstyle]=true,
[cfg.arg.listclass]=true,
[cfg.arg.name]=true,
[cfg.arg.navbar]=true,
[cfg.arg.state]=true,
[cfg.arg.title]=true,[cfg.arg.titleclass]=true,[cfg.arg.titlestyle]=true,
argHash=true
}
-- helper functions
local andnum = function(s, n) return string.format(cfg.arg[s .. '_and_num'], n) end
local isblank = function(v) return (v or '') == '' end
local function concatstrings(s)
local r = table.concat(s, '')
if r:match('^%s*$') then return nil end
return r
end
local function concatstyles(s)
local r = ''
for _, v in ipairs(s) do
v = mw.text.trim(v, "%s;")
if not isblank(v) then r = r .. v .. ';' end
end
if isblank(r) then return nil end
return r
end
local function getSubgroup(args, listnum, listText, prefix)
local subArgs = {
[cfg.arg.border] = cfg.keyword.border_subgroup,
[cfg.arg.navbar] = cfg.keyword.navbar_plain,
argHash = 0
}
local hasSubArgs = false
local subgroups_and_num = prefix and {prefix} or cfg.arg.subgroups_and_num
for k, v in pairs(args) do
k = tostring(k)
for _, w in ipairs(subgroups_and_num) do
w = string.format(w, listnum) .. "_"
if (#k > #w) and (k:sub(1, #w) == w) then
subArgs[k:sub(#w + 1)] = v
hasSubArgs = true
subArgs.argHash = subArgs.argHash + (v and #v or 0)
end
end
end
return hasSubArgs and p._navbox(subArgs) or listText
end
-- Main functions
function p._navbox(args)
if args.type == cfg.keyword.with_collapsible_groups then
return p._withCollapsibleGroups(args)
elseif args.type == cfg.keyword.with_columns then
return p._withColumns(args)
end
local function striped(wikitext, border)
-- Return wikitext with markers replaced for odd/even striping.
-- Child (subgroup) navboxes are flagged with a category that is removed
-- by parent navboxes. The result is that the category shows all pages
-- where a child navbox is not contained in a parent navbox.
local orphanCat = cfg.category.orphan
if border == cfg.keyword.border_subgroup and args[cfg.arg.orphan] ~= cfg.keyword.orphan_yes then
-- No change; striping occurs in outermost navbox.
return wikitext .. orphanCat
end
local first, second = cfg.class.navbox_odd_part, cfg.class.navbox_even_part
if args[cfg.arg.evenodd] then
if args[cfg.arg.evenodd] == cfg.keyword.evenodd_swap then
first, second = second, first
else
first = args[cfg.arg.evenodd]
second = first
end
end
local changer
if first == second then
changer = first
else
local index = 0
changer = function (code)
if code == '0' then
-- Current occurrence is for a group before a nested table.
-- Set it to first as a valid although pointless class.
-- The next occurrence will be the first row after a title
-- in a subgroup and will also be first.
index = 0
return first
end
index = index + 1
return index % 2 == 1 and first or second
end
end
local regex = orphanCat:gsub('([%[%]])', '%%%1')
return (wikitext:gsub(regex, ''):gsub(cfg.marker.regex, changer)) -- () omits gsub count
end
local function processItem(item, nowrapitems)
if item:sub(1, 2) == '{|' then
-- Applying nowrap to lines in a table does not make sense.
-- Add newlines to compensate for trim of x in |parm=x in a template.
return '\n' .. item .. '\n'
end
if nowrapitems == cfg.keyword.nowrapitems_yes then
local lines = {}
for line in (item .. '\n'):gmatch('([^\n]*)\n') do
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
if prefix and not content:match(cfg.pattern.nowrap) then
line = string.format(cfg.nowrap_item, prefix, content)
end
table.insert(lines, line)
end
item = table.concat(lines, '\n')
end
if item:match('^[*:;#]') then
return '\n' .. item .. '\n'
end
return item
end
local function has_navbar()
return args[cfg.arg.navbar] ~= cfg.keyword.navbar_off
and args[cfg.arg.navbar] ~= cfg.keyword.navbar_plain
and (
args[cfg.arg.name]
or mw.getCurrentFrame():getParent():getTitle():gsub(cfg.pattern.sandbox, '')
~= cfg.pattern.navbox
)
end
-- extract text color from css, which is the only permitted inline CSS for the navbar
local function extract_color(css_str)
-- return nil because navbar takes its argument into mw.html which handles
-- nil gracefully, removing the associated style attribute
return mw.ustring.match(';' .. css_str .. ';', '.*;%s*([Cc][Oo][Ll][Oo][Rr]%s*:%s*.-)%s*;') or nil
end
local function renderNavBar(titleCell)
if has_navbar() then
local navbar = require('Module:Navbar')._navbar
titleCell:wikitext(navbar{
[cfg.navbar.name] = args[cfg.arg.name],
[cfg.navbar.mini] = 1,
[cfg.navbar.fontstyle] = extract_color(
(args[cfg.arg.basestyle] or '') .. ';' .. (args[cfg.arg.titlestyle] or '')
)
})
end
end
local function renderTitleRow(tbl)
if not args[cfg.arg.title] then return end
local titleRow = tbl:tag('tr')
local titleCell = titleRow:tag('th'):attr('scope', 'col')
local titleColspan = 2
if args[cfg.arg.imageleft] then titleColspan = titleColspan + 1 end
if args[cfg.arg.image] then titleColspan = titleColspan + 1 end
titleCell
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.titlestyle])
:addClass(cfg.class.navbox_title)
:attr('colspan', titleColspan)
renderNavBar(titleCell)
titleCell
:tag('div')
-- id for aria-labelledby attribute
:attr('id', mw.uri.anchorEncode(args[cfg.arg.title]) .. args.argHash)
:addClass(args[cfg.arg.titleclass])
:css('font-size', '114%')
:css('margin', '0 4em')
:wikitext(processItem(args[cfg.arg.title]))
end
local function getAboveBelowColspan()
local ret = 2
if args[cfg.arg.imageleft] then ret = ret + 1 end
if args[cfg.arg.image] then ret = ret + 1 end
return ret
end
local function renderAboveRow(tbl)
if not args[cfg.arg.above] then return end
tbl:tag('tr')
:tag('td')
:addClass(cfg.class.navbox_abovebelow)
:addClass(args[cfg.arg.aboveclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.abovestyle])
:attr('colspan', getAboveBelowColspan())
:tag('div')
-- id for aria-labelledby attribute, if no title
:attr('id', (not args[cfg.arg.title]) and
(mw.uri.anchorEncode(args[cfg.arg.above]) .. args.argHash)
or nil)
:wikitext(processItem(args[cfg.arg.above], args[cfg.arg.nowrapitems]))
end
local function renderBelowRow(tbl)
if not args[cfg.arg.below] then return end
tbl:tag('tr')
:tag('td')
:addClass(cfg.class.navbox_abovebelow)
:addClass(args[cfg.arg.belowclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.belowstyle])
:attr('colspan', getAboveBelowColspan())
:tag('div')
:wikitext(processItem(args[cfg.arg.below], args[cfg.arg.nowrapitems]))
end
local function renderListRow(tbl, index, listnum, listnums_size)
local row = tbl:tag('tr')
if index == 1 and args[cfg.arg.imageleft] then
row
:tag('td')
:addClass(cfg.class.noviewer)
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '0 2px 0 0')
:cssText(args[cfg.arg.imageleftstyle])
:attr('rowspan', listnums_size)
:tag('div')
:wikitext(processItem(args[cfg.arg.imageleft]))
end
local group_and_num = andnum('group', listnum)
local groupstyle_and_num = andnum('groupstyle', listnum)
if args[group_and_num] then
local groupCell = row:tag('th')
-- id for aria-labelledby attribute, if lone group with no title or above
if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then
groupCell
:attr('id', mw.uri.anchorEncode(args[cfg.arg.group1]) .. args.argHash)
end
groupCell
:attr('scope', 'row')
:addClass(cfg.class.navbox_group)
:addClass(args[cfg.arg.groupclass])
:cssText(args[cfg.arg.basestyle])
-- If groupwidth not specified, minimize width
:css('width', args[cfg.arg.groupwidth] or '1%')
groupCell
:cssText(args[cfg.arg.groupstyle])
:cssText(args[groupstyle_and_num])
:wikitext(args[group_and_num])
end
local listCell = row:tag('td')
if args[group_and_num] then
listCell
:addClass(cfg.class.navbox_list_with_group)
else
listCell:attr('colspan', 2)
end
if not args[cfg.arg.groupwidth] then
listCell:css('width', '100%')
end
local rowstyle -- usually nil so cssText(rowstyle) usually adds nothing
if index % 2 == 1 then
rowstyle = args[cfg.arg.oddstyle]
else
rowstyle = args[cfg.arg.evenstyle]
end
local list_and_num = andnum('list', listnum)
local listText = inArray(cfg.keyword.subgroups, args[list_and_num])
and getSubgroup(args, listnum, args[list_and_num]) or args[list_and_num]
local oddEven = cfg.marker.oddeven
if listText:sub(1, 12) == '</div><table' then
-- Assume list text is for a subgroup navbox so no automatic striping for this row.
oddEven = listText:find(cfg.pattern.navbox_title) and cfg.marker.restart or cfg.class.navbox_odd_part
end
local liststyle_and_num = andnum('liststyle', listnum)
local listclass_and_num = andnum('listclass', listnum)
listCell
:css('padding', '0')
:cssText(args[cfg.arg.liststyle])
:cssText(rowstyle)
:cssText(args[liststyle_and_num])
:addClass(cfg.class.navbox_list)
:addClass(cfg.class.navbox_part .. oddEven)
:addClass(args[cfg.arg.listclass])
:addClass(args[listclass_and_num])
:tag('div')
:css('padding',
(index == 1 and args[cfg.arg.list1padding]) or args[cfg.arg.listpadding] or '0 0.25em'
)
:wikitext(processItem(listText, args[cfg.arg.nowrapitems]))
if index == 1 and args[cfg.arg.image] then
row
:tag('td')
:addClass(cfg.class.noviewer)
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '0 0 0 2px')
:cssText(args[cfg.arg.imagestyle])
:attr('rowspan', listnums_size)
:tag('div')
:wikitext(processItem(args[cfg.arg.image]))
end
end
local function has_list_class(htmlclass)
local patterns = {
'^' .. htmlclass .. '$',
'%s' .. htmlclass .. '$',
'^' .. htmlclass .. '%s',
'%s' .. htmlclass .. '%s'
}
for arg, _ in pairs(args) do
if type(arg) == 'string' and mw.ustring.find(arg, cfg.pattern.class) then
for _, pattern in ipairs(patterns) do
if mw.ustring.find(args[arg] or '', pattern) then
return true
end
end
end
end
return false
end
-- there are a lot of list classes in the wild, so we add their TemplateStyles
local function add_list_styles()
local frame = mw.getCurrentFrame()
local function add_list_templatestyles(htmlclass, templatestyles)
if has_list_class(htmlclass) then
return frame:extensionTag{
name = 'templatestyles', args = { src = templatestyles }
}
else
return ''
end
end
local hlist_styles = add_list_templatestyles('hlist', cfg.hlist_templatestyles)
local plainlist_styles = add_list_templatestyles('plainlist', cfg.plainlist_templatestyles)
-- a second workaround for [[phab:T303378]]
-- when that issue is fixed, we can actually use has_navbar not to emit the
-- tag here if we want
if has_navbar() and hlist_styles == '' then
hlist_styles = frame:extensionTag{
name = 'templatestyles', args = { src = cfg.hlist_templatestyles }
}
end
-- hlist -> plainlist is best-effort to preserve old Common.css ordering.
-- this ordering is not a guarantee because most navboxes will emit only
-- one of these classes [hlist_note]
return hlist_styles .. plainlist_styles
end
local function needsHorizontalLists(border)
if border == cfg.keyword.border_subgroup or args[cfg.arg.tracking] == cfg.keyword.tracking_no then
return false
end
return not has_list_class(cfg.pattern.hlist) and not has_list_class(cfg.pattern.plainlist)
end
local function hasBackgroundColors()
for _, key in ipairs({cfg.arg.titlestyle, cfg.arg.groupstyle,
cfg.arg.basestyle, cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('background', 1, true) then
return true
end
end
return false
end
local function hasBorders()
for _, key in ipairs({cfg.arg.groupstyle, cfg.arg.basestyle,
cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('border', 1, true) then
return true
end
end
return false
end
local function isIllegible()
local styleratio = require('Module:Color contrast')._styleratio
for key, style in pairs(args) do
if tostring(key):match(cfg.pattern.style) then
if styleratio{mw.text.unstripNoWiki(style)} < 4.5 then
return true
end
end
end
return false
end
local function getTrackingCategories(border)
local cats = {}
if needsHorizontalLists(border) then table.insert(cats, cfg.category.horizontal_lists) end
if hasBackgroundColors() then table.insert(cats, cfg.category.background_colors) end
if isIllegible() then table.insert(cats, cfg.category.illegible) end
if hasBorders() then table.insert(cats, cfg.category.borders) end
return cats
end
local function renderTrackingCategories(builder, border)
local title = mw.title.getCurrentTitle()
if title.namespace ~= 10 then return end -- not in template space
local subpage = title.subpageText
if subpage == cfg.keyword.subpage_doc or subpage == cfg.keyword.subpage_sandbox
or subpage == cfg.keyword.subpage_testcases then return end
for _, cat in ipairs(getTrackingCategories(border)) do
builder:wikitext('[[Category:' .. cat .. ']]')
end
end
local function renderMainTable(border, listnums)
local tbl = mw.html.create('table')
:addClass(cfg.class.nowraplinks)
:addClass(args[cfg.arg.bodyclass])
local state = args[cfg.arg.state]
if args[cfg.arg.title] and state ~= cfg.keyword.state_plain and state ~= cfg.keyword.state_off then
if state == cfg.keyword.state_collapsed then
state = cfg.class.collapsed
end
tbl
:addClass(cfg.class.collapsible)
:addClass(state or cfg.class.autocollapse)
end
tbl:css('border-spacing', 0)
if border == cfg.keyword.border_subgroup or border == cfg.keyword.border_none then
tbl
:addClass(cfg.class.navbox_subgroup)
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
else -- regular navbox - bodystyle and style will be applied to the wrapper table
tbl
:addClass(cfg.class.navbox_inner)
:css('background', 'transparent')
:css('color', 'inherit')
end
tbl:cssText(args[cfg.arg.innerstyle])
renderTitleRow(tbl)
renderAboveRow(tbl)
local listnums_size = #listnums
for i, listnum in ipairs(listnums) do
renderListRow(tbl, i, listnum, listnums_size)
end
renderBelowRow(tbl)
return tbl
end
local function add_navbox_styles(hiding_templatestyles)
local frame = mw.getCurrentFrame()
-- This is a lambda so that it doesn't need the frame as a parameter
local function add_user_styles(templatestyles)
if not isblank(templatestyles) then
return frame:extensionTag{
name = 'templatestyles', args = { src = templatestyles }
}
end
return ''
end
-- get templatestyles. load base from config so that Lua only needs to do
-- the work once of parser tag expansion
local base_templatestyles = cfg.templatestyles
local templatestyles = add_user_styles(args[cfg.arg.templatestyles])
local child_templatestyles = add_user_styles(args[cfg.arg.child_templatestyles])
-- The 'navbox-styles' div exists to wrap the styles to work around T200206
-- more elegantly. Instead of combinatorial rules, this ends up being linear
-- number of CSS rules.
return mw.html.create('div')
:addClass(cfg.class.navbox_styles)
:wikitext(
add_list_styles() .. -- see [hlist_note] applied to 'before base_templatestyles'
base_templatestyles ..
templatestyles ..
child_templatestyles ..
table.concat(hiding_templatestyles)
)
:done()
end
-- work around [[phab:T303378]]
-- for each arg: find all the templatestyles strip markers, insert them into a
-- table. then remove all templatestyles markers from the arg
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
local argHash = 0
for k, arg in pairs(args) do
if type(arg) == 'string' then
for marker in string.gfind(arg, strip_marker_pattern) do
table.insert(hiding_templatestyles, marker)
end
argHash = argHash + #arg
args[k] = string.gsub(arg, strip_marker_pattern, '')
end
end
if not args.argHash then args.argHash = argHash end
local listnums = {}
for k, _ in pairs(args) do
if type(k) == 'string' then
local listnum = k:match(cfg.pattern.listnum)
if listnum and args[andnum('list', tonumber(listnum))] then
table.insert(listnums, tonumber(listnum))
end
end
end
table.sort(listnums)
local border = mw.text.trim(args[cfg.arg.border] or args[1] or '')
if border == cfg.keyword.border_child then
border = cfg.keyword.border_subgroup
end
-- render the main body of the navbox
local tbl = renderMainTable(border, listnums)
local res = mw.html.create()
-- render the appropriate wrapper for the navbox, based on the border param
if border == cfg.keyword.border_none then
res:node(add_navbox_styles(hiding_templatestyles))
local nav = res:tag('div')
:attr('role', 'navigation')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above] or (args[cfg.arg.group1]
and not args[cfg.arg.group2]) then
nav:attr(
'aria-labelledby',
mw.uri.anchorEncode(
args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
) .. args.argHash
)
else
nav:attr('aria-label', cfg.aria_label .. args.argHash)
end
elseif border == cfg.keyword.border_subgroup then
-- We assume that this navbox is being rendered in a list cell of a
-- parent navbox, and is therefore inside a div with padding:0em 0.25em.
-- We start with a </div> to avoid the padding being applied, and at the
-- end add a <div> to balance out the parent's </div>
res
:wikitext('</div>')
:node(tbl)
:wikitext('<div>')
else
res:node(add_navbox_styles(hiding_templatestyles))
local nav = res:tag('div')
:attr('role', 'navigation')
:addClass(cfg.class.navbox)
:addClass(args[cfg.arg.navboxclass])
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
:css('padding', '3px')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above]
or (args[cfg.arg.group1] and not args[cfg.arg.group2]) then
nav:attr(
'aria-labelledby',
mw.uri.anchorEncode(
args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
) .. args.argHash
)
else
nav:attr('aria-label', cfg.aria_label .. args.argHash)
end
end
if (args[cfg.arg.nocat] or cfg.keyword.nocat_false):lower() == cfg.keyword.nocat_false then
renderTrackingCategories(res, border)
end
return striped(tostring(res), border)
end --p._navbox
function p._withCollapsibleGroups(pargs)
-- table for args passed to navbox
local targs = {}
-- process args
local passthroughLocal = {
[cfg.arg.bodystyle] = true,
[cfg.arg.border] = true,
[cfg.arg.style] = true,
}
for k,v in pairs(pargs) do
if k and type(k) == 'string' then
if passthrough[k] or passthroughLocal[k] then
targs[k] = v
elseif (k:match(cfg.pattern.num)) then
local n = k:match(cfg.pattern.num)
local list_and_num = andnum('list', n)
if ((k:match(cfg.pattern.listnum) or k:match(cfg.pattern.contentnum))
and targs[list_and_num] == nil
and pargs[andnum('group', n)] == nil
and pargs[andnum('sect', n)] == nil
and pargs[andnum('section', n)] == nil) then
targs[list_and_num] = concatstrings({
pargs[list_and_num] or '',
pargs[andnum('content', n)] or ''
})
if (targs[list_and_num] and inArray(cfg.keyword.subgroups, targs[list_and_num])) then
targs[list_and_num] = getSubgroup(pargs, n, targs[list_and_num])
end
elseif ((k:match(cfg.pattern.groupnum) or k:match(cfg.pattern.sectnum) or k:match(cfg.pattern.sectionnum))
and targs[list_and_num] == nil) then
local titlestyle = concatstyles({
pargs[cfg.arg.groupstyle] or '',
pargs[cfg.arg.secttitlestyle] or '',
pargs[andnum('groupstyle', n)] or '',
pargs[andnum('sectiontitlestyle', n)] or ''
})
local liststyle = concatstyles({
pargs[cfg.arg.liststyle] or '',
pargs[cfg.arg.contentstyle] or '',
pargs[andnum('liststyle', n)] or '',
pargs[andnum('contentstyle', n)] or ''
})
local title = concatstrings({
pargs[andnum('group', n)] or '',
pargs[andnum('sect', n)] or '',
pargs[andnum('section', n)] or ''
})
local list = concatstrings({
pargs[list_and_num] or '',
pargs[andnum('content', n)] or ''
})
if list and inArray(cfg.keyword.subgroups, list) then
list = getSubgroup(pargs, n, list)
end
local abbr_and_num = andnum('abbr', n)
local state = (pargs[abbr_and_num] and pargs[abbr_and_num] == pargs[cfg.arg.selected])
and cfg.keyword.state_uncollapsed
or (pargs[andnum('state', n)] or cfg.keyword.state_collapsed)
targs[list_and_num] =p._navbox({
cfg.keyword.border_child,
[cfg.arg.navbar] = cfg.keyword.navbar_plain,
[cfg.arg.state] = state,
[cfg.arg.basestyle] = pargs[cfg.arg.basestyle],
[cfg.arg.title] = title,
[cfg.arg.titlestyle] = titlestyle,
[andnum('list', 1)] = list,
[cfg.arg.liststyle] = liststyle,
[cfg.arg.listclass] = pargs[andnum('listclass', n)],
[cfg.arg.image] = pargs[andnum('image', n)],
[cfg.arg.imageleft] = pargs[andnum('imageleft', n)],
[cfg.arg.listpadding] = pargs[cfg.arg.listpadding],
argHash = pargs.argHash
})
end
end
end
end
-- ordering of style and bodystyle
targs[cfg.arg.style] = concatstyles({targs[cfg.arg.style] or '', targs[cfg.arg.bodystyle] or ''})
targs[cfg.arg.bodystyle] = nil
-- child or subgroup
if targs[cfg.arg.border] == nil then targs[cfg.arg.border] = pargs[1] end
return p._navbox(targs)
end --p._withCollapsibleGroups
function p._withColumns(pargs)
-- table for args passed to navbox
local targs = {}
-- tables of column numbers
local colheadernums = {}
local colnums = {}
local colfooternums = {}
-- process args
local passthroughLocal = {
[cfg.arg.evenstyle]=true,
[cfg.arg.groupstyle]=true,
[cfg.arg.liststyle]=true,
[cfg.arg.oddstyle]=true,
[cfg.arg.state]=true,
}
for k,v in pairs(pargs) do
if passthrough[k] or passthroughLocal[k] then
targs[k] = v
elseif type(k) == 'string' then
if k:match(cfg.pattern.listnum) then
local n = k:match(cfg.pattern.listnum)
targs[andnum('liststyle', n + 2)] = pargs[andnum('liststyle', n)]
targs[andnum('group', n + 2)] = pargs[andnum('group', n)]
targs[andnum('groupstyle', n + 2)] = pargs[andnum('groupstyle', n)]
if v and inArray(cfg.keyword.subgroups, v) then
targs[andnum('list', n + 2)] = getSubgroup(pargs, n, v)
else
targs[andnum('list', n + 2)] = v
end
elseif (k:match(cfg.pattern.colheadernum) and v ~= '') then
table.insert(colheadernums, tonumber(k:match(cfg.pattern.colheadernum)))
elseif (k:match(cfg.pattern.colnum) and v ~= '') then
table.insert(colnums, tonumber(k:match(cfg.pattern.colnum)))
elseif (k:match(cfg.pattern.colfooternum) and v ~= '') then
table.insert(colfooternums, tonumber(k:match(cfg.pattern.colfooternum)))
end
end
end
table.sort(colheadernums)
table.sort(colnums)
table.sort(colfooternums)
-- HTML table for list1
local coltable = mw.html.create( 'table' ):addClass('navbox-columns-table')
local row, col
local tablestyle = ( (#colheadernums > 0) or (not isblank(pargs[cfg.arg.fullwidth])) )
and 'width:100%'
or 'width:auto; margin-left:auto; margin-right:auto'
coltable:cssText(concatstyles({
'border-spacing: 0px; text-align:left',
tablestyle,
pargs[cfg.arg.coltablestyle] or ''
}))
--- Header row ---
if (#colheadernums > 0) then
row = coltable:tag('tr')
for k, n in ipairs(colheadernums) do
col = row:tag('th'):addClass('navbox-abovebelow')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'font-weight:bold',
pargs[cfg.arg.colheaderstyle] or '',
pargs[andnum('colheaderstyle', n)] or ''
}))
col:attr('colspan', tonumber(pargs[andnum('colheadercolspan', n)]))
col:wikitext(pargs[andnum('colheader', n)])
end
end
--- Main columns ---
row = coltable:tag('tr'):css('vertical-align', 'top')
for k, n in ipairs(colnums) do
if k == 1 and isblank(pargs[andnum('colheader', 1)])
and isblank(pargs[andnum('colfooter', 1)])
and isblank(pargs[cfg.arg.fullwidth]) then
local nopad = inArray(
{'off', '0', '0em', '0px'},
mw.ustring.gsub(pargs[cfg.arg.padding] or '', '[;%%]', ''))
if not nopad then
row:tag('td'):wikitext(' ')
:css('width', (pargs[cfg.arg.padding] or '5em'))
end
end
col = row:tag('td'):addClass('navbox-list')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'padding:0px',
pargs[cfg.arg.colstyle] or '',
((n%2 == 0) and pargs[cfg.arg.evencolstyle] or pargs[cfg.arg.oddcolstyle]) or '',
pargs[andnum('colstyle', n)] or '',
'width:' .. (pargs[andnum('colwidth', n)] or pargs[cfg.arg.colwidth] or '10em')
}))
local wt = pargs[andnum('col', n)]
if wt and inArray(cfg.keyword.subgroups, wt) then
wt = getSubgroup(pargs, n, wt, cfg.arg.col_and_num)
end
col:tag('div'):newline():wikitext(wt):newline()
end
--- Footer row ---
if (#colfooternums > 0) then
row = coltable:tag('tr')
for k, n in ipairs(colfooternums) do
col = row:tag('td'):addClass('navbox-abovebelow')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'font-weight:bold',
pargs[cfg.arg.colfooterstyle] or '',
pargs[andnum('colfooterstyle', n)] or ''
}))
col:attr('colspan', tonumber(pargs[andnum('colfootercolspan', n)]))
col:wikitext(pargs[andnum('colfooter', n)])
end
end
-- assign table to list1
targs[andnum('list', 1)] = tostring(coltable)
if isblank(pargs[andnum('colheader', 1)])
and isblank(pargs[andnum('col', 1)])
and isblank(pargs[andnum('colfooter', 1)]) then
targs[andnum('list', 1)] = targs[andnum('list', 1)] ..
cfg.category.without_first_col
end
-- Other parameters
targs[cfg.arg.border] = pargs[cfg.arg.border] or pargs[1]
targs[cfg.arg.evenodd] = (not isblank(pargs[cfg.arg.evenodd])) and pargs[cfg.arg.evenodd] or nil
targs[cfg.arg.list1padding] = '0px'
targs[andnum('liststyle', 1)] = 'background:transparent;color:inherit;'
targs[cfg.arg.style] = concatstyles({pargs[cfg.arg.style], pargs[cfg.arg.bodystyle]})
targs[cfg.arg.tracking] = 'no'
return p._navbox(targs)
end --p._withColumns
-- Template entry points
function p.navbox (frame, boxtype)
local function readArgs(args, prefix)
local function readSubgroups(element, i)
if inArray(cfg.keyword.subgroups, args[prefix .. andnum(element, i)]) then
for _, v in ipairs(cfg.arg.subgroups_and_num) do
readArgs(args, prefix .. string.format(v, i) .. "_")
end
readArgs(args, prefix .. andnum('col', i) .. "_")
end
end
-- Read the arguments in the order they'll be output in, to make references
-- number in the right order.
local _
_ = args[prefix .. cfg.arg.title]
_ = args[prefix .. cfg.arg.above]
-- Limit this to 20 as covering 'most' cases (that's a SWAG) and because
-- iterator approach won't work here
local boxtype = args.type or cfg.keyword[boxtype]
if boxtype == cfg.keyword.with_columns then
for i = 1, 20 do
_ = args[prefix .. andnum('colheader', i)]
end
for i = 1, 20 do
readSubgroups('col', i)
end
for i = 1, 20 do
_ = args[prefix .. andnum('colfooter', i)]
end
end
for i = 1, 20 do
_ = args[prefix .. andnum('group', i)]
readSubgroups('list', i)
end
_ = args[prefix .. cfg.arg.below]
end
if not getArgs then
getArgs = require('Moduuli:Arguments').getArgs
end
local args = getArgs(frame, {wrappers = {cfg.pattern[boxtype or 'navbox']}})
readArgs(args, "")
args.argHash = nil -- we shouldn't accept argHash passed from a template
args.type = args.type or cfg.keyword[boxtype]
return p['_navbox'](args)
end
p[cfg.keyword.with_collapsible_groups] = function (frame)
return p.navbox(frame, 'with_collapsible_groups')
end
p[cfg.keyword.with_columns] = function (frame)
return p.navbox(frame, 'with_columns')
end
return p
fbrh5lpm3oxajmgyjez9l2x7mh54fq1
50952
50946
2026-06-11T18:46:03Z
Olksolo
356
fix namespace
50952
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Navbox&oldid=1340240090
require('strict')
local p = {}
local cfg = mw.loadData('Moduuli:Navbox/configuration')
local inArray = require("Moduuli:TableTools").inArray
local getArgs -- lazily initialized
local hiding_templatestyles = {}
-- global passthrough variables
local passthrough = {
[cfg.arg.above]=true,[cfg.arg.aboveclass]=true,[cfg.arg.abovestyle]=true,
[cfg.arg.basestyle]=true,
[cfg.arg.below]=true,[cfg.arg.belowclass]=true,[cfg.arg.belowstyle]=true,
[cfg.arg.bodyclass]=true,
[cfg.arg.groupclass]=true,
[cfg.arg.image]=true,[cfg.arg.imageclass]=true,[cfg.arg.imagestyle]=true,
[cfg.arg.imageleft]=true,[cfg.arg.imageleftstyle]=true,
[cfg.arg.listclass]=true,
[cfg.arg.name]=true,
[cfg.arg.navbar]=true,
[cfg.arg.state]=true,
[cfg.arg.title]=true,[cfg.arg.titleclass]=true,[cfg.arg.titlestyle]=true,
argHash=true
}
-- helper functions
local andnum = function(s, n) return string.format(cfg.arg[s .. '_and_num'], n) end
local isblank = function(v) return (v or '') == '' end
local function concatstrings(s)
local r = table.concat(s, '')
if r:match('^%s*$') then return nil end
return r
end
local function concatstyles(s)
local r = ''
for _, v in ipairs(s) do
v = mw.text.trim(v, "%s;")
if not isblank(v) then r = r .. v .. ';' end
end
if isblank(r) then return nil end
return r
end
local function getSubgroup(args, listnum, listText, prefix)
local subArgs = {
[cfg.arg.border] = cfg.keyword.border_subgroup,
[cfg.arg.navbar] = cfg.keyword.navbar_plain,
argHash = 0
}
local hasSubArgs = false
local subgroups_and_num = prefix and {prefix} or cfg.arg.subgroups_and_num
for k, v in pairs(args) do
k = tostring(k)
for _, w in ipairs(subgroups_and_num) do
w = string.format(w, listnum) .. "_"
if (#k > #w) and (k:sub(1, #w) == w) then
subArgs[k:sub(#w + 1)] = v
hasSubArgs = true
subArgs.argHash = subArgs.argHash + (v and #v or 0)
end
end
end
return hasSubArgs and p._navbox(subArgs) or listText
end
-- Main functions
function p._navbox(args)
if args.type == cfg.keyword.with_collapsible_groups then
return p._withCollapsibleGroups(args)
elseif args.type == cfg.keyword.with_columns then
return p._withColumns(args)
end
local function striped(wikitext, border)
-- Return wikitext with markers replaced for odd/even striping.
-- Child (subgroup) navboxes are flagged with a category that is removed
-- by parent navboxes. The result is that the category shows all pages
-- where a child navbox is not contained in a parent navbox.
local orphanCat = cfg.category.orphan
if border == cfg.keyword.border_subgroup and args[cfg.arg.orphan] ~= cfg.keyword.orphan_yes then
-- No change; striping occurs in outermost navbox.
return wikitext .. orphanCat
end
local first, second = cfg.class.navbox_odd_part, cfg.class.navbox_even_part
if args[cfg.arg.evenodd] then
if args[cfg.arg.evenodd] == cfg.keyword.evenodd_swap then
first, second = second, first
else
first = args[cfg.arg.evenodd]
second = first
end
end
local changer
if first == second then
changer = first
else
local index = 0
changer = function (code)
if code == '0' then
-- Current occurrence is for a group before a nested table.
-- Set it to first as a valid although pointless class.
-- The next occurrence will be the first row after a title
-- in a subgroup and will also be first.
index = 0
return first
end
index = index + 1
return index % 2 == 1 and first or second
end
end
local regex = orphanCat:gsub('([%[%]])', '%%%1')
return (wikitext:gsub(regex, ''):gsub(cfg.marker.regex, changer)) -- () omits gsub count
end
local function processItem(item, nowrapitems)
if item:sub(1, 2) == '{|' then
-- Applying nowrap to lines in a table does not make sense.
-- Add newlines to compensate for trim of x in |parm=x in a template.
return '\n' .. item .. '\n'
end
if nowrapitems == cfg.keyword.nowrapitems_yes then
local lines = {}
for line in (item .. '\n'):gmatch('([^\n]*)\n') do
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
if prefix and not content:match(cfg.pattern.nowrap) then
line = string.format(cfg.nowrap_item, prefix, content)
end
table.insert(lines, line)
end
item = table.concat(lines, '\n')
end
if item:match('^[*:;#]') then
return '\n' .. item .. '\n'
end
return item
end
local function has_navbar()
return args[cfg.arg.navbar] ~= cfg.keyword.navbar_off
and args[cfg.arg.navbar] ~= cfg.keyword.navbar_plain
and (
args[cfg.arg.name]
or mw.getCurrentFrame():getParent():getTitle():gsub(cfg.pattern.sandbox, '')
~= cfg.pattern.navbox
)
end
-- extract text color from css, which is the only permitted inline CSS for the navbar
local function extract_color(css_str)
-- return nil because navbar takes its argument into mw.html which handles
-- nil gracefully, removing the associated style attribute
return mw.ustring.match(';' .. css_str .. ';', '.*;%s*([Cc][Oo][Ll][Oo][Rr]%s*:%s*.-)%s*;') or nil
end
local function renderNavBar(titleCell)
if has_navbar() then
local navbar = require('Moduuli:Navbar')._navbar
titleCell:wikitext(navbar{
[cfg.navbar.name] = args[cfg.arg.name],
[cfg.navbar.mini] = 1,
[cfg.navbar.fontstyle] = extract_color(
(args[cfg.arg.basestyle] or '') .. ';' .. (args[cfg.arg.titlestyle] or '')
)
})
end
end
local function renderTitleRow(tbl)
if not args[cfg.arg.title] then return end
local titleRow = tbl:tag('tr')
local titleCell = titleRow:tag('th'):attr('scope', 'col')
local titleColspan = 2
if args[cfg.arg.imageleft] then titleColspan = titleColspan + 1 end
if args[cfg.arg.image] then titleColspan = titleColspan + 1 end
titleCell
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.titlestyle])
:addClass(cfg.class.navbox_title)
:attr('colspan', titleColspan)
renderNavBar(titleCell)
titleCell
:tag('div')
-- id for aria-labelledby attribute
:attr('id', mw.uri.anchorEncode(args[cfg.arg.title]) .. args.argHash)
:addClass(args[cfg.arg.titleclass])
:css('font-size', '114%')
:css('margin', '0 4em')
:wikitext(processItem(args[cfg.arg.title]))
end
local function getAboveBelowColspan()
local ret = 2
if args[cfg.arg.imageleft] then ret = ret + 1 end
if args[cfg.arg.image] then ret = ret + 1 end
return ret
end
local function renderAboveRow(tbl)
if not args[cfg.arg.above] then return end
tbl:tag('tr')
:tag('td')
:addClass(cfg.class.navbox_abovebelow)
:addClass(args[cfg.arg.aboveclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.abovestyle])
:attr('colspan', getAboveBelowColspan())
:tag('div')
-- id for aria-labelledby attribute, if no title
:attr('id', (not args[cfg.arg.title]) and
(mw.uri.anchorEncode(args[cfg.arg.above]) .. args.argHash)
or nil)
:wikitext(processItem(args[cfg.arg.above], args[cfg.arg.nowrapitems]))
end
local function renderBelowRow(tbl)
if not args[cfg.arg.below] then return end
tbl:tag('tr')
:tag('td')
:addClass(cfg.class.navbox_abovebelow)
:addClass(args[cfg.arg.belowclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.belowstyle])
:attr('colspan', getAboveBelowColspan())
:tag('div')
:wikitext(processItem(args[cfg.arg.below], args[cfg.arg.nowrapitems]))
end
local function renderListRow(tbl, index, listnum, listnums_size)
local row = tbl:tag('tr')
if index == 1 and args[cfg.arg.imageleft] then
row
:tag('td')
:addClass(cfg.class.noviewer)
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '0 2px 0 0')
:cssText(args[cfg.arg.imageleftstyle])
:attr('rowspan', listnums_size)
:tag('div')
:wikitext(processItem(args[cfg.arg.imageleft]))
end
local group_and_num = andnum('group', listnum)
local groupstyle_and_num = andnum('groupstyle', listnum)
if args[group_and_num] then
local groupCell = row:tag('th')
-- id for aria-labelledby attribute, if lone group with no title or above
if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then
groupCell
:attr('id', mw.uri.anchorEncode(args[cfg.arg.group1]) .. args.argHash)
end
groupCell
:attr('scope', 'row')
:addClass(cfg.class.navbox_group)
:addClass(args[cfg.arg.groupclass])
:cssText(args[cfg.arg.basestyle])
-- If groupwidth not specified, minimize width
:css('width', args[cfg.arg.groupwidth] or '1%')
groupCell
:cssText(args[cfg.arg.groupstyle])
:cssText(args[groupstyle_and_num])
:wikitext(args[group_and_num])
end
local listCell = row:tag('td')
if args[group_and_num] then
listCell
:addClass(cfg.class.navbox_list_with_group)
else
listCell:attr('colspan', 2)
end
if not args[cfg.arg.groupwidth] then
listCell:css('width', '100%')
end
local rowstyle -- usually nil so cssText(rowstyle) usually adds nothing
if index % 2 == 1 then
rowstyle = args[cfg.arg.oddstyle]
else
rowstyle = args[cfg.arg.evenstyle]
end
local list_and_num = andnum('list', listnum)
local listText = inArray(cfg.keyword.subgroups, args[list_and_num])
and getSubgroup(args, listnum, args[list_and_num]) or args[list_and_num]
local oddEven = cfg.marker.oddeven
if listText:sub(1, 12) == '</div><table' then
-- Assume list text is for a subgroup navbox so no automatic striping for this row.
oddEven = listText:find(cfg.pattern.navbox_title) and cfg.marker.restart or cfg.class.navbox_odd_part
end
local liststyle_and_num = andnum('liststyle', listnum)
local listclass_and_num = andnum('listclass', listnum)
listCell
:css('padding', '0')
:cssText(args[cfg.arg.liststyle])
:cssText(rowstyle)
:cssText(args[liststyle_and_num])
:addClass(cfg.class.navbox_list)
:addClass(cfg.class.navbox_part .. oddEven)
:addClass(args[cfg.arg.listclass])
:addClass(args[listclass_and_num])
:tag('div')
:css('padding',
(index == 1 and args[cfg.arg.list1padding]) or args[cfg.arg.listpadding] or '0 0.25em'
)
:wikitext(processItem(listText, args[cfg.arg.nowrapitems]))
if index == 1 and args[cfg.arg.image] then
row
:tag('td')
:addClass(cfg.class.noviewer)
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '0 0 0 2px')
:cssText(args[cfg.arg.imagestyle])
:attr('rowspan', listnums_size)
:tag('div')
:wikitext(processItem(args[cfg.arg.image]))
end
end
local function has_list_class(htmlclass)
local patterns = {
'^' .. htmlclass .. '$',
'%s' .. htmlclass .. '$',
'^' .. htmlclass .. '%s',
'%s' .. htmlclass .. '%s'
}
for arg, _ in pairs(args) do
if type(arg) == 'string' and mw.ustring.find(arg, cfg.pattern.class) then
for _, pattern in ipairs(patterns) do
if mw.ustring.find(args[arg] or '', pattern) then
return true
end
end
end
end
return false
end
-- there are a lot of list classes in the wild, so we add their TemplateStyles
local function add_list_styles()
local frame = mw.getCurrentFrame()
local function add_list_templatestyles(htmlclass, templatestyles)
if has_list_class(htmlclass) then
return frame:extensionTag{
name = 'templatestyles', args = { src = templatestyles }
}
else
return ''
end
end
local hlist_styles = add_list_templatestyles('hlist', cfg.hlist_templatestyles)
local plainlist_styles = add_list_templatestyles('plainlist', cfg.plainlist_templatestyles)
-- a second workaround for [[phab:T303378]]
-- when that issue is fixed, we can actually use has_navbar not to emit the
-- tag here if we want
if has_navbar() and hlist_styles == '' then
hlist_styles = frame:extensionTag{
name = 'templatestyles', args = { src = cfg.hlist_templatestyles }
}
end
-- hlist -> plainlist is best-effort to preserve old Common.css ordering.
-- this ordering is not a guarantee because most navboxes will emit only
-- one of these classes [hlist_note]
return hlist_styles .. plainlist_styles
end
local function needsHorizontalLists(border)
if border == cfg.keyword.border_subgroup or args[cfg.arg.tracking] == cfg.keyword.tracking_no then
return false
end
return not has_list_class(cfg.pattern.hlist) and not has_list_class(cfg.pattern.plainlist)
end
local function hasBackgroundColors()
for _, key in ipairs({cfg.arg.titlestyle, cfg.arg.groupstyle,
cfg.arg.basestyle, cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('background', 1, true) then
return true
end
end
return false
end
local function hasBorders()
for _, key in ipairs({cfg.arg.groupstyle, cfg.arg.basestyle,
cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('border', 1, true) then
return true
end
end
return false
end
local function isIllegible()
local styleratio = require('Moduuli:Color contrast')._styleratio
for key, style in pairs(args) do
if tostring(key):match(cfg.pattern.style) then
if styleratio{mw.text.unstripNoWiki(style)} < 4.5 then
return true
end
end
end
return false
end
local function getTrackingCategories(border)
local cats = {}
if needsHorizontalLists(border) then table.insert(cats, cfg.category.horizontal_lists) end
if hasBackgroundColors() then table.insert(cats, cfg.category.background_colors) end
if isIllegible() then table.insert(cats, cfg.category.illegible) end
if hasBorders() then table.insert(cats, cfg.category.borders) end
return cats
end
local function renderTrackingCategories(builder, border)
local title = mw.title.getCurrentTitle()
if title.namespace ~= 10 then return end -- not in template space
local subpage = title.subpageText
if subpage == cfg.keyword.subpage_doc or subpage == cfg.keyword.subpage_sandbox
or subpage == cfg.keyword.subpage_testcases then return end
for _, cat in ipairs(getTrackingCategories(border)) do
builder:wikitext('[[Category:' .. cat .. ']]')
end
end
local function renderMainTable(border, listnums)
local tbl = mw.html.create('table')
:addClass(cfg.class.nowraplinks)
:addClass(args[cfg.arg.bodyclass])
local state = args[cfg.arg.state]
if args[cfg.arg.title] and state ~= cfg.keyword.state_plain and state ~= cfg.keyword.state_off then
if state == cfg.keyword.state_collapsed then
state = cfg.class.collapsed
end
tbl
:addClass(cfg.class.collapsible)
:addClass(state or cfg.class.autocollapse)
end
tbl:css('border-spacing', 0)
if border == cfg.keyword.border_subgroup or border == cfg.keyword.border_none then
tbl
:addClass(cfg.class.navbox_subgroup)
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
else -- regular navbox - bodystyle and style will be applied to the wrapper table
tbl
:addClass(cfg.class.navbox_inner)
:css('background', 'transparent')
:css('color', 'inherit')
end
tbl:cssText(args[cfg.arg.innerstyle])
renderTitleRow(tbl)
renderAboveRow(tbl)
local listnums_size = #listnums
for i, listnum in ipairs(listnums) do
renderListRow(tbl, i, listnum, listnums_size)
end
renderBelowRow(tbl)
return tbl
end
local function add_navbox_styles(hiding_templatestyles)
local frame = mw.getCurrentFrame()
-- This is a lambda so that it doesn't need the frame as a parameter
local function add_user_styles(templatestyles)
if not isblank(templatestyles) then
return frame:extensionTag{
name = 'templatestyles', args = { src = templatestyles }
}
end
return ''
end
-- get templatestyles. load base from config so that Lua only needs to do
-- the work once of parser tag expansion
local base_templatestyles = cfg.templatestyles
local templatestyles = add_user_styles(args[cfg.arg.templatestyles])
local child_templatestyles = add_user_styles(args[cfg.arg.child_templatestyles])
-- The 'navbox-styles' div exists to wrap the styles to work around T200206
-- more elegantly. Instead of combinatorial rules, this ends up being linear
-- number of CSS rules.
return mw.html.create('div')
:addClass(cfg.class.navbox_styles)
:wikitext(
add_list_styles() .. -- see [hlist_note] applied to 'before base_templatestyles'
base_templatestyles ..
templatestyles ..
child_templatestyles ..
table.concat(hiding_templatestyles)
)
:done()
end
-- work around [[phab:T303378]]
-- for each arg: find all the templatestyles strip markers, insert them into a
-- table. then remove all templatestyles markers from the arg
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
local argHash = 0
for k, arg in pairs(args) do
if type(arg) == 'string' then
for marker in string.gfind(arg, strip_marker_pattern) do
table.insert(hiding_templatestyles, marker)
end
argHash = argHash + #arg
args[k] = string.gsub(arg, strip_marker_pattern, '')
end
end
if not args.argHash then args.argHash = argHash end
local listnums = {}
for k, _ in pairs(args) do
if type(k) == 'string' then
local listnum = k:match(cfg.pattern.listnum)
if listnum and args[andnum('list', tonumber(listnum))] then
table.insert(listnums, tonumber(listnum))
end
end
end
table.sort(listnums)
local border = mw.text.trim(args[cfg.arg.border] or args[1] or '')
if border == cfg.keyword.border_child then
border = cfg.keyword.border_subgroup
end
-- render the main body of the navbox
local tbl = renderMainTable(border, listnums)
local res = mw.html.create()
-- render the appropriate wrapper for the navbox, based on the border param
if border == cfg.keyword.border_none then
res:node(add_navbox_styles(hiding_templatestyles))
local nav = res:tag('div')
:attr('role', 'navigation')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above] or (args[cfg.arg.group1]
and not args[cfg.arg.group2]) then
nav:attr(
'aria-labelledby',
mw.uri.anchorEncode(
args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
) .. args.argHash
)
else
nav:attr('aria-label', cfg.aria_label .. args.argHash)
end
elseif border == cfg.keyword.border_subgroup then
-- We assume that this navbox is being rendered in a list cell of a
-- parent navbox, and is therefore inside a div with padding:0em 0.25em.
-- We start with a </div> to avoid the padding being applied, and at the
-- end add a <div> to balance out the parent's </div>
res
:wikitext('</div>')
:node(tbl)
:wikitext('<div>')
else
res:node(add_navbox_styles(hiding_templatestyles))
local nav = res:tag('div')
:attr('role', 'navigation')
:addClass(cfg.class.navbox)
:addClass(args[cfg.arg.navboxclass])
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
:css('padding', '3px')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above]
or (args[cfg.arg.group1] and not args[cfg.arg.group2]) then
nav:attr(
'aria-labelledby',
mw.uri.anchorEncode(
args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
) .. args.argHash
)
else
nav:attr('aria-label', cfg.aria_label .. args.argHash)
end
end
if (args[cfg.arg.nocat] or cfg.keyword.nocat_false):lower() == cfg.keyword.nocat_false then
renderTrackingCategories(res, border)
end
return striped(tostring(res), border)
end --p._navbox
function p._withCollapsibleGroups(pargs)
-- table for args passed to navbox
local targs = {}
-- process args
local passthroughLocal = {
[cfg.arg.bodystyle] = true,
[cfg.arg.border] = true,
[cfg.arg.style] = true,
}
for k,v in pairs(pargs) do
if k and type(k) == 'string' then
if passthrough[k] or passthroughLocal[k] then
targs[k] = v
elseif (k:match(cfg.pattern.num)) then
local n = k:match(cfg.pattern.num)
local list_and_num = andnum('list', n)
if ((k:match(cfg.pattern.listnum) or k:match(cfg.pattern.contentnum))
and targs[list_and_num] == nil
and pargs[andnum('group', n)] == nil
and pargs[andnum('sect', n)] == nil
and pargs[andnum('section', n)] == nil) then
targs[list_and_num] = concatstrings({
pargs[list_and_num] or '',
pargs[andnum('content', n)] or ''
})
if (targs[list_and_num] and inArray(cfg.keyword.subgroups, targs[list_and_num])) then
targs[list_and_num] = getSubgroup(pargs, n, targs[list_and_num])
end
elseif ((k:match(cfg.pattern.groupnum) or k:match(cfg.pattern.sectnum) or k:match(cfg.pattern.sectionnum))
and targs[list_and_num] == nil) then
local titlestyle = concatstyles({
pargs[cfg.arg.groupstyle] or '',
pargs[cfg.arg.secttitlestyle] or '',
pargs[andnum('groupstyle', n)] or '',
pargs[andnum('sectiontitlestyle', n)] or ''
})
local liststyle = concatstyles({
pargs[cfg.arg.liststyle] or '',
pargs[cfg.arg.contentstyle] or '',
pargs[andnum('liststyle', n)] or '',
pargs[andnum('contentstyle', n)] or ''
})
local title = concatstrings({
pargs[andnum('group', n)] or '',
pargs[andnum('sect', n)] or '',
pargs[andnum('section', n)] or ''
})
local list = concatstrings({
pargs[list_and_num] or '',
pargs[andnum('content', n)] or ''
})
if list and inArray(cfg.keyword.subgroups, list) then
list = getSubgroup(pargs, n, list)
end
local abbr_and_num = andnum('abbr', n)
local state = (pargs[abbr_and_num] and pargs[abbr_and_num] == pargs[cfg.arg.selected])
and cfg.keyword.state_uncollapsed
or (pargs[andnum('state', n)] or cfg.keyword.state_collapsed)
targs[list_and_num] =p._navbox({
cfg.keyword.border_child,
[cfg.arg.navbar] = cfg.keyword.navbar_plain,
[cfg.arg.state] = state,
[cfg.arg.basestyle] = pargs[cfg.arg.basestyle],
[cfg.arg.title] = title,
[cfg.arg.titlestyle] = titlestyle,
[andnum('list', 1)] = list,
[cfg.arg.liststyle] = liststyle,
[cfg.arg.listclass] = pargs[andnum('listclass', n)],
[cfg.arg.image] = pargs[andnum('image', n)],
[cfg.arg.imageleft] = pargs[andnum('imageleft', n)],
[cfg.arg.listpadding] = pargs[cfg.arg.listpadding],
argHash = pargs.argHash
})
end
end
end
end
-- ordering of style and bodystyle
targs[cfg.arg.style] = concatstyles({targs[cfg.arg.style] or '', targs[cfg.arg.bodystyle] or ''})
targs[cfg.arg.bodystyle] = nil
-- child or subgroup
if targs[cfg.arg.border] == nil then targs[cfg.arg.border] = pargs[1] end
return p._navbox(targs)
end --p._withCollapsibleGroups
function p._withColumns(pargs)
-- table for args passed to navbox
local targs = {}
-- tables of column numbers
local colheadernums = {}
local colnums = {}
local colfooternums = {}
-- process args
local passthroughLocal = {
[cfg.arg.evenstyle]=true,
[cfg.arg.groupstyle]=true,
[cfg.arg.liststyle]=true,
[cfg.arg.oddstyle]=true,
[cfg.arg.state]=true,
}
for k,v in pairs(pargs) do
if passthrough[k] or passthroughLocal[k] then
targs[k] = v
elseif type(k) == 'string' then
if k:match(cfg.pattern.listnum) then
local n = k:match(cfg.pattern.listnum)
targs[andnum('liststyle', n + 2)] = pargs[andnum('liststyle', n)]
targs[andnum('group', n + 2)] = pargs[andnum('group', n)]
targs[andnum('groupstyle', n + 2)] = pargs[andnum('groupstyle', n)]
if v and inArray(cfg.keyword.subgroups, v) then
targs[andnum('list', n + 2)] = getSubgroup(pargs, n, v)
else
targs[andnum('list', n + 2)] = v
end
elseif (k:match(cfg.pattern.colheadernum) and v ~= '') then
table.insert(colheadernums, tonumber(k:match(cfg.pattern.colheadernum)))
elseif (k:match(cfg.pattern.colnum) and v ~= '') then
table.insert(colnums, tonumber(k:match(cfg.pattern.colnum)))
elseif (k:match(cfg.pattern.colfooternum) and v ~= '') then
table.insert(colfooternums, tonumber(k:match(cfg.pattern.colfooternum)))
end
end
end
table.sort(colheadernums)
table.sort(colnums)
table.sort(colfooternums)
-- HTML table for list1
local coltable = mw.html.create( 'table' ):addClass('navbox-columns-table')
local row, col
local tablestyle = ( (#colheadernums > 0) or (not isblank(pargs[cfg.arg.fullwidth])) )
and 'width:100%'
or 'width:auto; margin-left:auto; margin-right:auto'
coltable:cssText(concatstyles({
'border-spacing: 0px; text-align:left',
tablestyle,
pargs[cfg.arg.coltablestyle] or ''
}))
--- Header row ---
if (#colheadernums > 0) then
row = coltable:tag('tr')
for k, n in ipairs(colheadernums) do
col = row:tag('th'):addClass('navbox-abovebelow')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'font-weight:bold',
pargs[cfg.arg.colheaderstyle] or '',
pargs[andnum('colheaderstyle', n)] or ''
}))
col:attr('colspan', tonumber(pargs[andnum('colheadercolspan', n)]))
col:wikitext(pargs[andnum('colheader', n)])
end
end
--- Main columns ---
row = coltable:tag('tr'):css('vertical-align', 'top')
for k, n in ipairs(colnums) do
if k == 1 and isblank(pargs[andnum('colheader', 1)])
and isblank(pargs[andnum('colfooter', 1)])
and isblank(pargs[cfg.arg.fullwidth]) then
local nopad = inArray(
{'off', '0', '0em', '0px'},
mw.ustring.gsub(pargs[cfg.arg.padding] or '', '[;%%]', ''))
if not nopad then
row:tag('td'):wikitext(' ')
:css('width', (pargs[cfg.arg.padding] or '5em'))
end
end
col = row:tag('td'):addClass('navbox-list')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'padding:0px',
pargs[cfg.arg.colstyle] or '',
((n%2 == 0) and pargs[cfg.arg.evencolstyle] or pargs[cfg.arg.oddcolstyle]) or '',
pargs[andnum('colstyle', n)] or '',
'width:' .. (pargs[andnum('colwidth', n)] or pargs[cfg.arg.colwidth] or '10em')
}))
local wt = pargs[andnum('col', n)]
if wt and inArray(cfg.keyword.subgroups, wt) then
wt = getSubgroup(pargs, n, wt, cfg.arg.col_and_num)
end
col:tag('div'):newline():wikitext(wt):newline()
end
--- Footer row ---
if (#colfooternums > 0) then
row = coltable:tag('tr')
for k, n in ipairs(colfooternums) do
col = row:tag('td'):addClass('navbox-abovebelow')
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
'font-weight:bold',
pargs[cfg.arg.colfooterstyle] or '',
pargs[andnum('colfooterstyle', n)] or ''
}))
col:attr('colspan', tonumber(pargs[andnum('colfootercolspan', n)]))
col:wikitext(pargs[andnum('colfooter', n)])
end
end
-- assign table to list1
targs[andnum('list', 1)] = tostring(coltable)
if isblank(pargs[andnum('colheader', 1)])
and isblank(pargs[andnum('col', 1)])
and isblank(pargs[andnum('colfooter', 1)]) then
targs[andnum('list', 1)] = targs[andnum('list', 1)] ..
cfg.category.without_first_col
end
-- Other parameters
targs[cfg.arg.border] = pargs[cfg.arg.border] or pargs[1]
targs[cfg.arg.evenodd] = (not isblank(pargs[cfg.arg.evenodd])) and pargs[cfg.arg.evenodd] or nil
targs[cfg.arg.list1padding] = '0px'
targs[andnum('liststyle', 1)] = 'background:transparent;color:inherit;'
targs[cfg.arg.style] = concatstyles({pargs[cfg.arg.style], pargs[cfg.arg.bodystyle]})
targs[cfg.arg.tracking] = 'no'
return p._navbox(targs)
end --p._withColumns
-- Template entry points
function p.navbox (frame, boxtype)
local function readArgs(args, prefix)
local function readSubgroups(element, i)
if inArray(cfg.keyword.subgroups, args[prefix .. andnum(element, i)]) then
for _, v in ipairs(cfg.arg.subgroups_and_num) do
readArgs(args, prefix .. string.format(v, i) .. "_")
end
readArgs(args, prefix .. andnum('col', i) .. "_")
end
end
-- Read the arguments in the order they'll be output in, to make references
-- number in the right order.
local _
_ = args[prefix .. cfg.arg.title]
_ = args[prefix .. cfg.arg.above]
-- Limit this to 20 as covering 'most' cases (that's a SWAG) and because
-- iterator approach won't work here
local boxtype = args.type or cfg.keyword[boxtype]
if boxtype == cfg.keyword.with_columns then
for i = 1, 20 do
_ = args[prefix .. andnum('colheader', i)]
end
for i = 1, 20 do
readSubgroups('col', i)
end
for i = 1, 20 do
_ = args[prefix .. andnum('colfooter', i)]
end
end
for i = 1, 20 do
_ = args[prefix .. andnum('group', i)]
readSubgroups('list', i)
end
_ = args[prefix .. cfg.arg.below]
end
if not getArgs then
getArgs = require('Moduuli:Arguments').getArgs
end
local args = getArgs(frame, {wrappers = {cfg.pattern[boxtype or 'navbox']}})
readArgs(args, "")
args.argHash = nil -- we shouldn't accept argHash passed from a template
args.type = args.type or cfg.keyword[boxtype]
return p['_navbox'](args)
end
p[cfg.keyword.with_collapsible_groups] = function (frame)
return p.navbox(frame, 'with_collapsible_groups')
end
p[cfg.keyword.with_columns] = function (frame)
return p.navbox(frame, 'with_columns')
end
return p
gwp237fef5yy5eikuojq30wq08aqukq
Moduuli:Navbox/configuration
828
16859
50942
2026-06-11T18:31:41Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Navbox/configuration&oldid=1340098247
50942
Scribunto
text/plain
-- import from https://en.wikipedia.org/w/index.php?title=Module:Navbox/configuration&oldid=1340098247
return {
aria_label = 'Navbox',
nowrap_item = '%s<span class="nowrap">%s</span>',
templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:Navbox/styles.css' }
},
hlist_templatestyles = 'Hlist/styles.css',
plainlist_templatestyles = 'Plainlist/styles.css',
-- do not localize marker table
marker = {
oddeven = '\127_ODDEVEN_\127',
restart = '\127_ODDEVEN0_\127',
regex = '\127_ODDEVEN(%d?)_\127'
},
category = {
orphan = '[[Category:Navbox orphans]]',
horizontal_lists = 'Navigational boxes without horizontal lists',
background_colors = 'Navboxes using background colours',
illegible = 'Potentially illegible navboxes',
borders = 'Navboxes using borders',
without_first_col = '[[Category:Pages using navbox columns without the first column]]'
},
keyword = {
border_subgroup = 'subgroup',
border_child = 'child',
border_none = 'none',
evenodd_swap = 'swap',
navbar_off = 'off',
navbar_plain = 'plain',
nocat_false = 'false',
nowrapitems_yes = 'yes',
orphan_yes = 'yes',
state_collapsed = 'collapsed',
state_off = 'off',
state_plain = 'plain',
state_uncollapsed = 'uncollapsed',
subgroups = {'subgroup', 'child', ''},
subpage_doc = 'doc',
subpage_sandbox = 'sandbox',
subpage_testcases = 'testcases',
tracking_no = 'no',
with_collapsible_groups = 'with collapsible groups',
with_collapsible_groups_short = 'collapsible',
with_columns = 'with columns',
with_columns_short = 'columns',
},
class = {
autocollapse = 'autocollapse',
collapsible = 'mw-collapsible',
collapsed = 'mw-collapsed',
-- Warning
navbox = 'navbox', -- WMF currently hides 'navbox' from mobile,
-- so you probably shouldn't change the navbox class.
navbox_abovebelow = 'navbox-abovebelow',
navbox_group = 'navbox-group',
navbox_image = 'navbox-image',
navbox_inner = 'navbox-inner',
navbox_list = 'navbox-list',
navbox_list_with_group = 'navbox-list-with-group',
navbox_part = 'navbox-', -- do not l10n
navbox_styles = 'navbox-styles',
navbox_subgroup = 'navbox-subgroup',
navbox_title = 'navbox-title', -- l10n only if you change pattern.navbox_title below
navbox_odd_part = 'odd', -- do not l10n
navbox_even_part = 'even', -- do not l10n
nomobile = 'nomobile',
nowraplinks = 'nowraplinks',
noviewer = 'noviewer', -- used to remove images from MediaViewer
notheme = 'notheme'
},
pattern = {
class = 'class',
colnum = '^col(%d+)$',
colheadernum = '^col(%d+)header$',
colfooternum = '^col(%d+)footer$',
contentnum = '^content(%d+)$',
groupnum = '^group(%d+)$',
hlist = 'hlist',
listnum = '^list(%d+)$',
navbox = 'Template:Navbox',
navbox_title = '<th[^>]*"navbox%-title"',
nowrap = '^<span class="nowrap">',
num = '^%a+(%d+)$',
plainlist = 'plainlist',
sandbox = '/sandbox$',
sectionnum = '^section(%d+)$',
sectnum = '^sect(%d+)$',
style = 'style$',
with_collapsible_groups = 'Template:Navbox with collapsible groups',
with_columns = 'Template:Navbox with columns',
},
arg = {
abbr_and_num = 'abbr%d',
above = 'above',
aboveclass = 'aboveclass',
abovestyle = 'abovestyle',
basestyle = 'basestyle',
below = 'below',
belowclass = 'belowclass',
belowstyle = 'belowstyle',
bodyclass = 'bodyclass',
bodystyle = 'bodystyle',
border = 'border',
content_and_num = 'content%d',
contentstyle = 'contentstyle',
contentstyle_and_num = 'content%dstyle',
colheaderstyle = 'colheaderstyle',
colheader_and_num = 'col%dheader',
colheaderstyle_and_num = 'col%dheaderstyle',
colheadercolspan_and_num = 'col%dheadercolspan',
colstyle = 'colstyle',
col_and_num = 'col%d',
colstyle_and_num = 'col%dstyle',
colwidth = 'colwidth',
colwidth_and_num = 'col%dwidth',
colfooterstyle = 'colfooterstyle',
colfooter_and_num = 'col%dfooter',
colfooterstyle_and_num = 'col%dfooterstyle',
colfootercolspan_and_num = 'col%dfootercolspan',
coltablestyle = 'coltablestyle',
evencolstyle = 'evencolstyle',
evenodd = 'evenodd',
evenstyle = 'evenstyle',
fullwidth = 'fullwidth',
group1 = 'group1',
group2 = 'group2',
group_and_num = 'group%d',
groupclass = 'groupclass',
groupstyle = 'groupstyle',
groupstyle_and_num = 'group%dstyle',
groupwidth = 'groupwidth',
image = 'image',
image_and_num = 'image%d',
imageclass = 'imageclass',
imageleft = 'imageleft',
imageleft_and_num = 'imageleft%d',
imageleftstyle = 'imageleftstyle',
imagestyle = 'imagestyle',
innerstyle = 'innerstyle',
list1padding = 'list1padding',
list_and_num = 'list%d',
listclass = 'listclass',
listclass_and_num = 'list%dclass',
listpadding = 'listpadding',
liststyle = 'liststyle',
liststyle_and_num = 'list%dstyle',
name = 'name',
navbar = 'navbar',
navboxclass = 'navboxclass',
nocat = 'nocat',
nowrapitems = 'nowrapitems',
oddcolstyle = 'oddcolstyle',
oddstyle = 'oddstyle',
orphan = 'orphan',
padding = 'padding',
sect_and_num = 'sect%d',
section_and_num = 'section%d',
sectiontitlestyle_and_num = 'section%dtitlestyle',
secttitlestyle = 'secttitlestyle',
selected = 'selected',
state = 'state',
state_and_num = 'state%d',
style = 'style',
subgroups_and_num = {'subgroup%d', 'child%d', '%d'},
templatestyles = 'templatestyles',
child_templatestyles = 'child templatestyles',
title = 'title',
titleclass = 'titleclass',
titlestyle = 'titlestyle',
tracking = 'tracking',
},
-- names of navbar arguments
navbar = {
name = 1,
fontstyle = 'fontstyle',
mini = 'mini'
}
}
iq2jwsfhix47dlsb7xnffoujwmkqx0a
50953
50942
2026-06-11T18:47:14Z
Olksolo
356
fix namespace
50953
Scribunto
text/plain
-- import from https://en.wikipedia.org/w/index.php?title=Module:Navbox/configuration&oldid=1340098247
return {
aria_label = 'Navbox',
nowrap_item = '%s<span class="nowrap">%s</span>',
templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Moduuli:Navbox/styles.css' }
},
hlist_templatestyles = 'Hlist/styles.css',
plainlist_templatestyles = 'Plainlist/styles.css',
-- do not localize marker table
marker = {
oddeven = '\127_ODDEVEN_\127',
restart = '\127_ODDEVEN0_\127',
regex = '\127_ODDEVEN(%d?)_\127'
},
category = {
orphan = '[[Category:Navbox orphans]]',
horizontal_lists = 'Navigational boxes without horizontal lists',
background_colors = 'Navboxes using background colours',
illegible = 'Potentially illegible navboxes',
borders = 'Navboxes using borders',
without_first_col = '[[Category:Pages using navbox columns without the first column]]'
},
keyword = {
border_subgroup = 'subgroup',
border_child = 'child',
border_none = 'none',
evenodd_swap = 'swap',
navbar_off = 'off',
navbar_plain = 'plain',
nocat_false = 'false',
nowrapitems_yes = 'yes',
orphan_yes = 'yes',
state_collapsed = 'collapsed',
state_off = 'off',
state_plain = 'plain',
state_uncollapsed = 'uncollapsed',
subgroups = {'subgroup', 'child', ''},
subpage_doc = 'doc',
subpage_sandbox = 'sandbox',
subpage_testcases = 'testcases',
tracking_no = 'no',
with_collapsible_groups = 'with collapsible groups',
with_collapsible_groups_short = 'collapsible',
with_columns = 'with columns',
with_columns_short = 'columns',
},
class = {
autocollapse = 'autocollapse',
collapsible = 'mw-collapsible',
collapsed = 'mw-collapsed',
-- Warning
navbox = 'navbox', -- WMF currently hides 'navbox' from mobile,
-- so you probably shouldn't change the navbox class.
navbox_abovebelow = 'navbox-abovebelow',
navbox_group = 'navbox-group',
navbox_image = 'navbox-image',
navbox_inner = 'navbox-inner',
navbox_list = 'navbox-list',
navbox_list_with_group = 'navbox-list-with-group',
navbox_part = 'navbox-', -- do not l10n
navbox_styles = 'navbox-styles',
navbox_subgroup = 'navbox-subgroup',
navbox_title = 'navbox-title', -- l10n only if you change pattern.navbox_title below
navbox_odd_part = 'odd', -- do not l10n
navbox_even_part = 'even', -- do not l10n
nomobile = 'nomobile',
nowraplinks = 'nowraplinks',
noviewer = 'noviewer', -- used to remove images from MediaViewer
notheme = 'notheme'
},
pattern = {
class = 'class',
colnum = '^col(%d+)$',
colheadernum = '^col(%d+)header$',
colfooternum = '^col(%d+)footer$',
contentnum = '^content(%d+)$',
groupnum = '^group(%d+)$',
hlist = 'hlist',
listnum = '^list(%d+)$',
navbox = 'Template:Navbox',
navbox_title = '<th[^>]*"navbox%-title"',
nowrap = '^<span class="nowrap">',
num = '^%a+(%d+)$',
plainlist = 'plainlist',
sandbox = '/sandbox$',
sectionnum = '^section(%d+)$',
sectnum = '^sect(%d+)$',
style = 'style$',
with_collapsible_groups = 'Template:Navbox with collapsible groups',
with_columns = 'Template:Navbox with columns',
},
arg = {
abbr_and_num = 'abbr%d',
above = 'above',
aboveclass = 'aboveclass',
abovestyle = 'abovestyle',
basestyle = 'basestyle',
below = 'below',
belowclass = 'belowclass',
belowstyle = 'belowstyle',
bodyclass = 'bodyclass',
bodystyle = 'bodystyle',
border = 'border',
content_and_num = 'content%d',
contentstyle = 'contentstyle',
contentstyle_and_num = 'content%dstyle',
colheaderstyle = 'colheaderstyle',
colheader_and_num = 'col%dheader',
colheaderstyle_and_num = 'col%dheaderstyle',
colheadercolspan_and_num = 'col%dheadercolspan',
colstyle = 'colstyle',
col_and_num = 'col%d',
colstyle_and_num = 'col%dstyle',
colwidth = 'colwidth',
colwidth_and_num = 'col%dwidth',
colfooterstyle = 'colfooterstyle',
colfooter_and_num = 'col%dfooter',
colfooterstyle_and_num = 'col%dfooterstyle',
colfootercolspan_and_num = 'col%dfootercolspan',
coltablestyle = 'coltablestyle',
evencolstyle = 'evencolstyle',
evenodd = 'evenodd',
evenstyle = 'evenstyle',
fullwidth = 'fullwidth',
group1 = 'group1',
group2 = 'group2',
group_and_num = 'group%d',
groupclass = 'groupclass',
groupstyle = 'groupstyle',
groupstyle_and_num = 'group%dstyle',
groupwidth = 'groupwidth',
image = 'image',
image_and_num = 'image%d',
imageclass = 'imageclass',
imageleft = 'imageleft',
imageleft_and_num = 'imageleft%d',
imageleftstyle = 'imageleftstyle',
imagestyle = 'imagestyle',
innerstyle = 'innerstyle',
list1padding = 'list1padding',
list_and_num = 'list%d',
listclass = 'listclass',
listclass_and_num = 'list%dclass',
listpadding = 'listpadding',
liststyle = 'liststyle',
liststyle_and_num = 'list%dstyle',
name = 'name',
navbar = 'navbar',
navboxclass = 'navboxclass',
nocat = 'nocat',
nowrapitems = 'nowrapitems',
oddcolstyle = 'oddcolstyle',
oddstyle = 'oddstyle',
orphan = 'orphan',
padding = 'padding',
sect_and_num = 'sect%d',
section_and_num = 'section%d',
sectiontitlestyle_and_num = 'section%dtitlestyle',
secttitlestyle = 'secttitlestyle',
selected = 'selected',
state = 'state',
state_and_num = 'state%d',
style = 'style',
subgroups_and_num = {'subgroup%d', 'child%d', '%d'},
templatestyles = 'templatestyles',
child_templatestyles = 'child templatestyles',
title = 'title',
titleclass = 'titleclass',
titlestyle = 'titlestyle',
tracking = 'tracking',
},
-- names of navbar arguments
navbar = {
name = 1,
fontstyle = 'fontstyle',
mini = 'mini'
}
}
mgad3amhvzz0hfqolpmcfhhx4nw1dtd
Moduuli:Navbox/styles.css
828
16860
50943
2026-06-11T18:33:04Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Navbox/styles.css&oldid=1353707246
50943
sanitized-css
text/css
/* {{pp|small=y}} */
.navbox {
box-sizing: border-box;
border: 1px solid #a2a9b1;
width: 100%;
clear: both;
font-size: 88%;
text-align: center;
padding: 1px;
margin: 1em auto 0; /* Prevent preceding content from clinging to navboxes */
}
.navbox .navbox {
margin-top: 0; /* No top margin for nested navboxes */
}
.navbox + .navbox-styles + .navbox,
/* category positions are wrapped in an "empty" span in Parsoid [[phab:T378906]] */
.navbox + span.mw-empty-elt + .navbox-styles + .navbox {
margin-top: -1px; /* Single pixel border between adjacent navboxes */
}
.navbox-inner,
.navbox-subgroup {
width: 100%;
}
.navbox-group,
.navbox-title,
.navbox-abovebelow {
padding: 0.25em 1em;
line-height: 1.5em;
text-align: center;
}
.navbox-group {
white-space: nowrap;
/* @noflip */
text-align: right;
}
.navbox,
.navbox-subgroup {
background-color: #fdfdfd;
color:inherit;
}
.navbox-list {
line-height: 1.5em;
border-color: #fdfdfd; /* Must match background color */
}
.navbox-list-with-group {
text-align: left;
border-left-width: 2px;
border-left-style: solid;
}
/* cell spacing for navbox cells */
/* Borders above 2nd, 3rd, etc. rows */
/* TODO: figure out how to replace tr as structure;
* with div structure it should be just a matter of first-child */
tr + tr > .navbox-abovebelow,
tr + tr > .navbox-group,
tr + tr > .navbox-image,
tr + tr > .navbox-list {
border-top: 2px solid #fdfdfd; /* Must match background color */
}
.navbox-title {
background-color: #ccf; /* Level 1 color */
color:inherit;
}
.navbox-abovebelow,
.navbox-group,
.navbox-subgroup .navbox-title {
background-color: #ddf; /* Level 2 color */
color:inherit;
}
.navbox-subgroup .navbox-group,
.navbox-subgroup .navbox-abovebelow {
background-color: #e6e6ff; /* Level 3 color */
color:inherit;
}
.navbox-even {
background-color: #f7f7f7;
color:inherit;
}
.navbox-odd {
background-color: transparent;
color:inherit;
}
/* TODO: figure out how to remove reliance on td as structure */
.navbox .hlist td dl,
.navbox .hlist td ol,
.navbox .hlist td ul,
.navbox td.hlist dl,
.navbox td.hlist ol,
.navbox td.hlist ul {
padding: 0.125em 0;
}
.navbox .navbar {
display: block;
font-size: 100%;
}
.navbox-title .navbar {
/* @noflip */
float: left;
/* @noflip */
text-align: left;
/* @noflip */
margin-right: 0.5em;
}
/** T367463 */
body.skin--responsive .navbox-image img {
max-width: none !important;
}
@media print {
body.ns-0 .navbox {
display: none !important;
}
}
ku94g873nj9xaasowc6yies69ls74c5
Moduuli:TableTools
828
16861
50944
2026-06-11T18:35:07Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:TableTools&oldid=1240903756
50944
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:TableTools&oldid=1240903756
------------------------------------------------------------------------------------
-- TableTools --
-- --
-- This module includes a number of functions for dealing with Lua tables. --
-- It is a meta-module, meant to be called from other Lua modules, and should not --
-- be called directly from #invoke. --
------------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local p = {}
-- Define often-used variables and functions.
local floor = math.floor
local infinity = math.huge
local checkType = libraryUtil.checkType
local checkTypeMulti = libraryUtil.checkTypeMulti
------------------------------------------------------------------------------------
-- isPositiveInteger
--
-- This function returns true if the given value is a positive integer, and false
-- if not. Although it doesn't operate on tables, it is included here as it is
-- useful for determining whether a given table key is in the array part or the
-- hash part of a table.
------------------------------------------------------------------------------------
function p.isPositiveInteger(v)
return type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity
end
------------------------------------------------------------------------------------
-- isNan
--
-- This function returns true if the given number is a NaN value, and false if
-- not. Although it doesn't operate on tables, it is included here as it is useful
-- for determining whether a value can be a valid table key. Lua will generate an
-- error if a NaN is used as a table key.
------------------------------------------------------------------------------------
function p.isNan(v)
return type(v) == 'number' and v ~= v
end
------------------------------------------------------------------------------------
-- shallowClone
--
-- This returns a clone of a table. The value returned is a new table, but all
-- subtables and functions are shared. Metamethods are respected, but the returned
-- table will have no metatable of its own.
------------------------------------------------------------------------------------
function p.shallowClone(t)
checkType('shallowClone', 1, t, 'table')
local ret = {}
for k, v in pairs(t) do
ret[k] = v
end
return ret
end
------------------------------------------------------------------------------------
-- removeDuplicates
--
-- This removes duplicate values from an array. Non-positive-integer keys are
-- ignored. The earliest value is kept, and all subsequent duplicate values are
-- removed, but otherwise the array order is unchanged.
------------------------------------------------------------------------------------
function p.removeDuplicates(arr)
checkType('removeDuplicates', 1, arr, 'table')
local isNan = p.isNan
local ret, exists = {}, {}
for _, v in ipairs(arr) do
if isNan(v) then
-- NaNs can't be table keys, and they are also unique, so we don't need to check existence.
ret[#ret + 1] = v
elseif not exists[v] then
ret[#ret + 1] = v
exists[v] = true
end
end
return ret
end
------------------------------------------------------------------------------------
-- numKeys
--
-- This takes a table and returns an array containing the numbers of any numerical
-- keys that have non-nil values, sorted in numerical order.
------------------------------------------------------------------------------------
function p.numKeys(t)
checkType('numKeys', 1, t, 'table')
local isPositiveInteger = p.isPositiveInteger
local nums = {}
for k in pairs(t) do
if isPositiveInteger(k) then
nums[#nums + 1] = k
end
end
table.sort(nums)
return nums
end
------------------------------------------------------------------------------------
-- affixNums
--
-- This takes a table and returns an array containing the numbers of keys with the
-- specified prefix and suffix. For example, for the table
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", affixNums will return
-- {1, 3, 6}.
------------------------------------------------------------------------------------
function p.affixNums(t, prefix, suffix)
checkType('affixNums', 1, t, 'table')
checkType('affixNums', 2, prefix, 'string', true)
checkType('affixNums', 3, suffix, 'string', true)
local function cleanPattern(s)
-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.
return s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')
end
prefix = prefix or ''
suffix = suffix or ''
prefix = cleanPattern(prefix)
suffix = cleanPattern(suffix)
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'
local nums = {}
for k in pairs(t) do
if type(k) == 'string' then
local num = mw.ustring.match(k, pattern)
if num then
nums[#nums + 1] = tonumber(num)
end
end
end
table.sort(nums)
return nums
end
------------------------------------------------------------------------------------
-- numData
--
-- Given a table with keys like {"foo1", "bar1", "foo2", "baz2"}, returns a table
-- of subtables in the format
-- {[1] = {foo = 'text', bar = 'text'}, [2] = {foo = 'text', baz = 'text'}}.
-- Keys that don't end with an integer are stored in a subtable named "other". The
-- compress option compresses the table so that it can be iterated over with
-- ipairs.
------------------------------------------------------------------------------------
function p.numData(t, compress)
checkType('numData', 1, t, 'table')
checkType('numData', 2, compress, 'boolean', true)
local ret = {}
for k, v in pairs(t) do
local prefix, num = mw.ustring.match(tostring(k), '^([^0-9]*)([1-9][0-9]*)$')
if num then
num = tonumber(num)
local subtable = ret[num] or {}
if prefix == '' then
-- Positional parameters match the blank string; put them at the start of the subtable instead.
prefix = 1
end
subtable[prefix] = v
ret[num] = subtable
else
local subtable = ret.other or {}
subtable[k] = v
ret.other = subtable
end
end
if compress then
local other = ret.other
ret = p.compressSparseArray(ret)
ret.other = other
end
return ret
end
------------------------------------------------------------------------------------
-- compressSparseArray
--
-- This takes an array with one or more nil values, and removes the nil values
-- while preserving the order, so that the array can be safely traversed with
-- ipairs.
------------------------------------------------------------------------------------
function p.compressSparseArray(t)
checkType('compressSparseArray', 1, t, 'table')
local ret = {}
local nums = p.numKeys(t)
for _, num in ipairs(nums) do
ret[#ret + 1] = t[num]
end
return ret
end
------------------------------------------------------------------------------------
-- sparseIpairs
--
-- This is an iterator for sparse arrays. It can be used like ipairs, but can
-- handle nil values.
------------------------------------------------------------------------------------
function p.sparseIpairs(t)
checkType('sparseIpairs', 1, t, 'table')
local nums = p.numKeys(t)
local i = 0
local lim = #nums
return function ()
i = i + 1
if i <= lim then
local key = nums[i]
return key, t[key]
else
return nil, nil
end
end
end
------------------------------------------------------------------------------------
-- size
--
-- This returns the size of a key/value pair table. It will also work on arrays,
-- but for arrays it is more efficient to use the # operator.
------------------------------------------------------------------------------------
function p.size(t)
checkType('size', 1, t, 'table')
local i = 0
for _ in pairs(t) do
i = i + 1
end
return i
end
local function defaultKeySort(item1, item2)
-- "number" < "string", so numbers will be sorted before strings.
local type1, type2 = type(item1), type(item2)
if type1 ~= type2 then
return type1 < type2
elseif type1 == 'table' or type1 == 'boolean' or type1 == 'function' then
return tostring(item1) < tostring(item2)
else
return item1 < item2
end
end
------------------------------------------------------------------------------------
-- keysToList
--
-- Returns an array of the keys in a table, sorted using either a default
-- comparison function or a custom keySort function.
------------------------------------------------------------------------------------
function p.keysToList(t, keySort, checked)
if not checked then
checkType('keysToList', 1, t, 'table')
checkTypeMulti('keysToList', 2, keySort, {'function', 'boolean', 'nil'})
end
local arr = {}
local index = 1
for k in pairs(t) do
arr[index] = k
index = index + 1
end
if keySort ~= false then
keySort = type(keySort) == 'function' and keySort or defaultKeySort
table.sort(arr, keySort)
end
return arr
end
------------------------------------------------------------------------------------
-- sortedPairs
--
-- Iterates through a table, with the keys sorted using the keysToList function.
-- If there are only numerical keys, sparseIpairs is probably more efficient.
------------------------------------------------------------------------------------
function p.sortedPairs(t, keySort)
checkType('sortedPairs', 1, t, 'table')
checkType('sortedPairs', 2, keySort, 'function', true)
local arr = p.keysToList(t, keySort, true)
local i = 0
return function ()
i = i + 1
local key = arr[i]
if key ~= nil then
return key, t[key]
else
return nil, nil
end
end
end
------------------------------------------------------------------------------------
-- isArray
--
-- Returns true if the given value is a table and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArray(v)
if type(v) ~= 'table' then
return false
end
local i = 0
for _ in pairs(v) do
i = i + 1
if v[i] == nil then
return false
end
end
return true
end
------------------------------------------------------------------------------------
-- isArrayLike
--
-- Returns true if the given value is iterable and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArrayLike(v)
if not pcall(pairs, v) then
return false
end
local i = 0
for _ in pairs(v) do
i = i + 1
if v[i] == nil then
return false
end
end
return true
end
------------------------------------------------------------------------------------
-- invert
--
-- Transposes the keys and values in an array. For example, {"a", "b", "c"} ->
-- {a = 1, b = 2, c = 3}. Duplicates are not supported (result values refer to
-- the index of the last duplicate) and NaN values are ignored.
------------------------------------------------------------------------------------
function p.invert(arr)
checkType("invert", 1, arr, "table")
local isNan = p.isNan
local map = {}
for i, v in ipairs(arr) do
if not isNan(v) then
map[v] = i
end
end
return map
end
------------------------------------------------------------------------------------
-- listToSet
--
-- Creates a set from the array part of the table. Indexing the set by any of the
-- values of the array returns true. For example, {"a", "b", "c"} ->
-- {a = true, b = true, c = true}. NaN values are ignored as Lua considers them
-- never equal to any value (including other NaNs or even themselves).
------------------------------------------------------------------------------------
function p.listToSet(arr)
checkType("listToSet", 1, arr, "table")
local isNan = p.isNan
local set = {}
for _, v in ipairs(arr) do
if not isNan(v) then
set[v] = true
end
end
return set
end
------------------------------------------------------------------------------------
-- deepCopy
--
-- Recursive deep copy function. Preserves identities of subtables.
------------------------------------------------------------------------------------
local function _deepCopy(orig, includeMetatable, already_seen)
if type(orig) ~= "table" then
return orig
end
-- already_seen stores copies of tables indexed by the original table.
local copy = already_seen[orig]
if copy ~= nil then
return copy
end
copy = {}
already_seen[orig] = copy -- memoize before any recursion, to avoid infinite loops
for orig_key, orig_value in pairs(orig) do
copy[_deepCopy(orig_key, includeMetatable, already_seen)] = _deepCopy(orig_value, includeMetatable, already_seen)
end
if includeMetatable then
local mt = getmetatable(orig)
if mt ~= nil then
setmetatable(copy, _deepCopy(mt, true, already_seen))
end
end
return copy
end
function p.deepCopy(orig, noMetatable, already_seen)
checkType("deepCopy", 3, already_seen, "table", true)
return _deepCopy(orig, not noMetatable, already_seen or {})
end
------------------------------------------------------------------------------------
-- sparseConcat
--
-- Concatenates all values in the table that are indexed by a number, in order.
-- sparseConcat{a, nil, c, d} => "acd"
-- sparseConcat{nil, b, c, d} => "bcd"
------------------------------------------------------------------------------------
function p.sparseConcat(t, sep, i, j)
local arr = {}
local arr_i = 0
for _, v in p.sparseIpairs(t) do
arr_i = arr_i + 1
arr[arr_i] = v
end
return table.concat(arr, sep, i, j)
end
------------------------------------------------------------------------------------
-- length
--
-- Finds the length of an array, or of a quasi-array with keys such as "data1",
-- "data2", etc., using an exponential search algorithm. It is similar to the
-- operator #, but may return a different value when there are gaps in the array
-- portion of the table. Intended to be used on data loaded with mw.loadData. For
-- other tables, use #.
-- Note: #frame.args in frame object always be set to 0, regardless of the number
-- of unnamed template parameters, so use this function for frame.args.
------------------------------------------------------------------------------------
function p.length(t, prefix)
-- requiring module inline so that [[Module:Exponential search]] which is
-- only needed by this one function doesn't get millions of transclusions
local expSearch = require("Module:Exponential search")
checkType('length', 1, t, 'table')
checkType('length', 2, prefix, 'string', true)
return expSearch(function (i)
local key
if prefix then
key = prefix .. tostring(i)
else
key = i
end
return t[key] ~= nil
end) or 0
end
------------------------------------------------------------------------------------
-- inArray
--
-- Returns true if searchElement is a member of the array, and false otherwise.
-- Equivalent to JavaScript array.includes(searchElement) or
-- array.includes(searchElement, fromIndex), except fromIndex is 1 indexed
------------------------------------------------------------------------------------
function p.inArray(array, searchElement, fromIndex)
checkType("inArray", 1, array, "table")
-- if searchElement is nil, error?
fromIndex = tonumber(fromIndex)
if fromIndex then
if (fromIndex < 0) then
fromIndex = #array + fromIndex + 1
end
if fromIndex < 1 then fromIndex = 1 end
for _, v in ipairs({unpack(array, fromIndex)}) do
if v == searchElement then
return true
end
end
else
for _, v in pairs(array) do
if v == searchElement then
return true
end
end
end
return false
end
------------------------------------------------------------------------------------
-- merge
--
-- Given the arrays, returns an array containing the elements of each input array
-- in sequence.
------------------------------------------------------------------------------------
function p.merge(...)
local arrays = {...}
local ret = {}
for i, arr in ipairs(arrays) do
checkType('merge', i, arr, 'table')
for _, v in ipairs(arr) do
ret[#ret + 1] = v
end
end
return ret
end
------------------------------------------------------------------------------------
-- extend
--
-- Extends the first array in place by appending all elements from the second
-- array.
------------------------------------------------------------------------------------
function p.extend(arr1, arr2)
checkType('extend', 1, arr1, 'table')
checkType('extend', 2, arr2, 'table')
for _, v in ipairs(arr2) do
arr1[#arr1 + 1] = v
end
end
return p
os664bmg1n29yj07zm414lx9lj2lb68
50956
50944
2026-06-11T18:56:10Z
Olksolo
356
fix namespace
50956
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:TableTools&oldid=1240903756
------------------------------------------------------------------------------------
-- TableTools --
-- --
-- This module includes a number of functions for dealing with Lua tables. --
-- It is a meta-module, meant to be called from other Lua modules, and should not --
-- be called directly from #invoke. --
------------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local p = {}
-- Define often-used variables and functions.
local floor = math.floor
local infinity = math.huge
local checkType = libraryUtil.checkType
local checkTypeMulti = libraryUtil.checkTypeMulti
------------------------------------------------------------------------------------
-- isPositiveInteger
--
-- This function returns true if the given value is a positive integer, and false
-- if not. Although it doesn't operate on tables, it is included here as it is
-- useful for determining whether a given table key is in the array part or the
-- hash part of a table.
------------------------------------------------------------------------------------
function p.isPositiveInteger(v)
return type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity
end
------------------------------------------------------------------------------------
-- isNan
--
-- This function returns true if the given number is a NaN value, and false if
-- not. Although it doesn't operate on tables, it is included here as it is useful
-- for determining whether a value can be a valid table key. Lua will generate an
-- error if a NaN is used as a table key.
------------------------------------------------------------------------------------
function p.isNan(v)
return type(v) == 'number' and v ~= v
end
------------------------------------------------------------------------------------
-- shallowClone
--
-- This returns a clone of a table. The value returned is a new table, but all
-- subtables and functions are shared. Metamethods are respected, but the returned
-- table will have no metatable of its own.
------------------------------------------------------------------------------------
function p.shallowClone(t)
checkType('shallowClone', 1, t, 'table')
local ret = {}
for k, v in pairs(t) do
ret[k] = v
end
return ret
end
------------------------------------------------------------------------------------
-- removeDuplicates
--
-- This removes duplicate values from an array. Non-positive-integer keys are
-- ignored. The earliest value is kept, and all subsequent duplicate values are
-- removed, but otherwise the array order is unchanged.
------------------------------------------------------------------------------------
function p.removeDuplicates(arr)
checkType('removeDuplicates', 1, arr, 'table')
local isNan = p.isNan
local ret, exists = {}, {}
for _, v in ipairs(arr) do
if isNan(v) then
-- NaNs can't be table keys, and they are also unique, so we don't need to check existence.
ret[#ret + 1] = v
elseif not exists[v] then
ret[#ret + 1] = v
exists[v] = true
end
end
return ret
end
------------------------------------------------------------------------------------
-- numKeys
--
-- This takes a table and returns an array containing the numbers of any numerical
-- keys that have non-nil values, sorted in numerical order.
------------------------------------------------------------------------------------
function p.numKeys(t)
checkType('numKeys', 1, t, 'table')
local isPositiveInteger = p.isPositiveInteger
local nums = {}
for k in pairs(t) do
if isPositiveInteger(k) then
nums[#nums + 1] = k
end
end
table.sort(nums)
return nums
end
------------------------------------------------------------------------------------
-- affixNums
--
-- This takes a table and returns an array containing the numbers of keys with the
-- specified prefix and suffix. For example, for the table
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", affixNums will return
-- {1, 3, 6}.
------------------------------------------------------------------------------------
function p.affixNums(t, prefix, suffix)
checkType('affixNums', 1, t, 'table')
checkType('affixNums', 2, prefix, 'string', true)
checkType('affixNums', 3, suffix, 'string', true)
local function cleanPattern(s)
-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.
return s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')
end
prefix = prefix or ''
suffix = suffix or ''
prefix = cleanPattern(prefix)
suffix = cleanPattern(suffix)
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'
local nums = {}
for k in pairs(t) do
if type(k) == 'string' then
local num = mw.ustring.match(k, pattern)
if num then
nums[#nums + 1] = tonumber(num)
end
end
end
table.sort(nums)
return nums
end
------------------------------------------------------------------------------------
-- numData
--
-- Given a table with keys like {"foo1", "bar1", "foo2", "baz2"}, returns a table
-- of subtables in the format
-- {[1] = {foo = 'text', bar = 'text'}, [2] = {foo = 'text', baz = 'text'}}.
-- Keys that don't end with an integer are stored in a subtable named "other". The
-- compress option compresses the table so that it can be iterated over with
-- ipairs.
------------------------------------------------------------------------------------
function p.numData(t, compress)
checkType('numData', 1, t, 'table')
checkType('numData', 2, compress, 'boolean', true)
local ret = {}
for k, v in pairs(t) do
local prefix, num = mw.ustring.match(tostring(k), '^([^0-9]*)([1-9][0-9]*)$')
if num then
num = tonumber(num)
local subtable = ret[num] or {}
if prefix == '' then
-- Positional parameters match the blank string; put them at the start of the subtable instead.
prefix = 1
end
subtable[prefix] = v
ret[num] = subtable
else
local subtable = ret.other or {}
subtable[k] = v
ret.other = subtable
end
end
if compress then
local other = ret.other
ret = p.compressSparseArray(ret)
ret.other = other
end
return ret
end
------------------------------------------------------------------------------------
-- compressSparseArray
--
-- This takes an array with one or more nil values, and removes the nil values
-- while preserving the order, so that the array can be safely traversed with
-- ipairs.
------------------------------------------------------------------------------------
function p.compressSparseArray(t)
checkType('compressSparseArray', 1, t, 'table')
local ret = {}
local nums = p.numKeys(t)
for _, num in ipairs(nums) do
ret[#ret + 1] = t[num]
end
return ret
end
------------------------------------------------------------------------------------
-- sparseIpairs
--
-- This is an iterator for sparse arrays. It can be used like ipairs, but can
-- handle nil values.
------------------------------------------------------------------------------------
function p.sparseIpairs(t)
checkType('sparseIpairs', 1, t, 'table')
local nums = p.numKeys(t)
local i = 0
local lim = #nums
return function ()
i = i + 1
if i <= lim then
local key = nums[i]
return key, t[key]
else
return nil, nil
end
end
end
------------------------------------------------------------------------------------
-- size
--
-- This returns the size of a key/value pair table. It will also work on arrays,
-- but for arrays it is more efficient to use the # operator.
------------------------------------------------------------------------------------
function p.size(t)
checkType('size', 1, t, 'table')
local i = 0
for _ in pairs(t) do
i = i + 1
end
return i
end
local function defaultKeySort(item1, item2)
-- "number" < "string", so numbers will be sorted before strings.
local type1, type2 = type(item1), type(item2)
if type1 ~= type2 then
return type1 < type2
elseif type1 == 'table' or type1 == 'boolean' or type1 == 'function' then
return tostring(item1) < tostring(item2)
else
return item1 < item2
end
end
------------------------------------------------------------------------------------
-- keysToList
--
-- Returns an array of the keys in a table, sorted using either a default
-- comparison function or a custom keySort function.
------------------------------------------------------------------------------------
function p.keysToList(t, keySort, checked)
if not checked then
checkType('keysToList', 1, t, 'table')
checkTypeMulti('keysToList', 2, keySort, {'function', 'boolean', 'nil'})
end
local arr = {}
local index = 1
for k in pairs(t) do
arr[index] = k
index = index + 1
end
if keySort ~= false then
keySort = type(keySort) == 'function' and keySort or defaultKeySort
table.sort(arr, keySort)
end
return arr
end
------------------------------------------------------------------------------------
-- sortedPairs
--
-- Iterates through a table, with the keys sorted using the keysToList function.
-- If there are only numerical keys, sparseIpairs is probably more efficient.
------------------------------------------------------------------------------------
function p.sortedPairs(t, keySort)
checkType('sortedPairs', 1, t, 'table')
checkType('sortedPairs', 2, keySort, 'function', true)
local arr = p.keysToList(t, keySort, true)
local i = 0
return function ()
i = i + 1
local key = arr[i]
if key ~= nil then
return key, t[key]
else
return nil, nil
end
end
end
------------------------------------------------------------------------------------
-- isArray
--
-- Returns true if the given value is a table and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArray(v)
if type(v) ~= 'table' then
return false
end
local i = 0
for _ in pairs(v) do
i = i + 1
if v[i] == nil then
return false
end
end
return true
end
------------------------------------------------------------------------------------
-- isArrayLike
--
-- Returns true if the given value is iterable and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArrayLike(v)
if not pcall(pairs, v) then
return false
end
local i = 0
for _ in pairs(v) do
i = i + 1
if v[i] == nil then
return false
end
end
return true
end
------------------------------------------------------------------------------------
-- invert
--
-- Transposes the keys and values in an array. For example, {"a", "b", "c"} ->
-- {a = 1, b = 2, c = 3}. Duplicates are not supported (result values refer to
-- the index of the last duplicate) and NaN values are ignored.
------------------------------------------------------------------------------------
function p.invert(arr)
checkType("invert", 1, arr, "table")
local isNan = p.isNan
local map = {}
for i, v in ipairs(arr) do
if not isNan(v) then
map[v] = i
end
end
return map
end
------------------------------------------------------------------------------------
-- listToSet
--
-- Creates a set from the array part of the table. Indexing the set by any of the
-- values of the array returns true. For example, {"a", "b", "c"} ->
-- {a = true, b = true, c = true}. NaN values are ignored as Lua considers them
-- never equal to any value (including other NaNs or even themselves).
------------------------------------------------------------------------------------
function p.listToSet(arr)
checkType("listToSet", 1, arr, "table")
local isNan = p.isNan
local set = {}
for _, v in ipairs(arr) do
if not isNan(v) then
set[v] = true
end
end
return set
end
------------------------------------------------------------------------------------
-- deepCopy
--
-- Recursive deep copy function. Preserves identities of subtables.
------------------------------------------------------------------------------------
local function _deepCopy(orig, includeMetatable, already_seen)
if type(orig) ~= "table" then
return orig
end
-- already_seen stores copies of tables indexed by the original table.
local copy = already_seen[orig]
if copy ~= nil then
return copy
end
copy = {}
already_seen[orig] = copy -- memoize before any recursion, to avoid infinite loops
for orig_key, orig_value in pairs(orig) do
copy[_deepCopy(orig_key, includeMetatable, already_seen)] = _deepCopy(orig_value, includeMetatable, already_seen)
end
if includeMetatable then
local mt = getmetatable(orig)
if mt ~= nil then
setmetatable(copy, _deepCopy(mt, true, already_seen))
end
end
return copy
end
function p.deepCopy(orig, noMetatable, already_seen)
checkType("deepCopy", 3, already_seen, "table", true)
return _deepCopy(orig, not noMetatable, already_seen or {})
end
------------------------------------------------------------------------------------
-- sparseConcat
--
-- Concatenates all values in the table that are indexed by a number, in order.
-- sparseConcat{a, nil, c, d} => "acd"
-- sparseConcat{nil, b, c, d} => "bcd"
------------------------------------------------------------------------------------
function p.sparseConcat(t, sep, i, j)
local arr = {}
local arr_i = 0
for _, v in p.sparseIpairs(t) do
arr_i = arr_i + 1
arr[arr_i] = v
end
return table.concat(arr, sep, i, j)
end
------------------------------------------------------------------------------------
-- length
--
-- Finds the length of an array, or of a quasi-array with keys such as "data1",
-- "data2", etc., using an exponential search algorithm. It is similar to the
-- operator #, but may return a different value when there are gaps in the array
-- portion of the table. Intended to be used on data loaded with mw.loadData. For
-- other tables, use #.
-- Note: #frame.args in frame object always be set to 0, regardless of the number
-- of unnamed template parameters, so use this function for frame.args.
------------------------------------------------------------------------------------
function p.length(t, prefix)
-- requiring module inline so that [[Module:Exponential search]] which is
-- only needed by this one function doesn't get millions of transclusions
local expSearch = require("Moduuli:Exponential search")
checkType('length', 1, t, 'table')
checkType('length', 2, prefix, 'string', true)
return expSearch(function (i)
local key
if prefix then
key = prefix .. tostring(i)
else
key = i
end
return t[key] ~= nil
end) or 0
end
------------------------------------------------------------------------------------
-- inArray
--
-- Returns true if searchElement is a member of the array, and false otherwise.
-- Equivalent to JavaScript array.includes(searchElement) or
-- array.includes(searchElement, fromIndex), except fromIndex is 1 indexed
------------------------------------------------------------------------------------
function p.inArray(array, searchElement, fromIndex)
checkType("inArray", 1, array, "table")
-- if searchElement is nil, error?
fromIndex = tonumber(fromIndex)
if fromIndex then
if (fromIndex < 0) then
fromIndex = #array + fromIndex + 1
end
if fromIndex < 1 then fromIndex = 1 end
for _, v in ipairs({unpack(array, fromIndex)}) do
if v == searchElement then
return true
end
end
else
for _, v in pairs(array) do
if v == searchElement then
return true
end
end
end
return false
end
------------------------------------------------------------------------------------
-- merge
--
-- Given the arrays, returns an array containing the elements of each input array
-- in sequence.
------------------------------------------------------------------------------------
function p.merge(...)
local arrays = {...}
local ret = {}
for i, arr in ipairs(arrays) do
checkType('merge', i, arr, 'table')
for _, v in ipairs(arr) do
ret[#ret + 1] = v
end
end
return ret
end
------------------------------------------------------------------------------------
-- extend
--
-- Extends the first array in place by appending all elements from the second
-- array.
------------------------------------------------------------------------------------
function p.extend(arr1, arr2)
checkType('extend', 1, arr1, 'table')
checkType('extend', 2, arr2, 'table')
for _, v in ipairs(arr2) do
arr1[#arr1 + 1] = v
end
end
return p
7cqhisj3u4k2db8t88nh4a2ho1a74e7
Moduuli:Arguments
828
16862
50945
2026-06-11T18:37:41Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Arguments&oldid=948472485
50945
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Arguments&oldid=948472485
-- This module provides easy processing of arguments passed to Scribunto from
-- #invoke. It is intended for use by other Lua modules, and should not be
-- called from #invoke directly.
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local arguments = {}
-- Generate four different tidyVal functions, so that we don't have to check the
-- options every time we call it.
local function tidyValDefault(key, val)
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val == '' then
return nil
else
return val
end
else
return val
end
end
local function tidyValTrimOnly(key, val)
if type(val) == 'string' then
return val:match('^%s*(.-)%s*$')
else
return val
end
end
local function tidyValRemoveBlanksOnly(key, val)
if type(val) == 'string' then
if val:find('%S') then
return val
else
return nil
end
else
return val
end
end
local function tidyValNoChange(key, val)
return val
end
local function matchesTitle(given, title)
local tp = type( given )
return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end
local translate_mt = { __index = function(t, k) return k end }
function arguments.getArgs(frame, options)
checkType('getArgs', 1, frame, 'table', true)
checkType('getArgs', 2, options, 'table', true)
frame = frame or {}
options = options or {}
--[[
-- Set up argument translation.
--]]
options.translate = options.translate or {}
if getmetatable(options.translate) == nil then
setmetatable(options.translate, translate_mt)
end
if options.backtranslate == nil then
options.backtranslate = {}
for k,v in pairs(options.translate) do
options.backtranslate[v] = k
end
end
if options.backtranslate and getmetatable(options.backtranslate) == nil then
setmetatable(options.backtranslate, {
__index = function(t, k)
if options.translate[k] ~= k then
return nil
else
return k
end
end
})
end
--[[
-- Get the argument tables. If we were passed a valid frame object, get the
-- frame arguments (fargs) and the parent frame arguments (pargs), depending
-- on the options set and on the parent frame's availability. If we weren't
-- passed a valid frame object, we are being called from another Lua module
-- or from the debug console, so assume that we were passed a table of args
-- directly, and assign it to a new variable (luaArgs).
--]]
local fargs, pargs, luaArgs
if type(frame.args) == 'table' and type(frame.getParent) == 'function' then
if options.wrappers then
--[[
-- The wrappers option makes Module:Arguments look up arguments in
-- either the frame argument table or the parent argument table, but
-- not both. This means that users can use either the #invoke syntax
-- or a wrapper template without the loss of performance associated
-- with looking arguments up in both the frame and the parent frame.
-- Module:Arguments will look up arguments in the parent frame
-- if it finds the parent frame's title in options.wrapper;
-- otherwise it will look up arguments in the frame object passed
-- to getArgs.
--]]
local parent = frame:getParent()
if not parent then
fargs = frame.args
else
local title = parent:getTitle():gsub('/sandbox$', '')
local found = false
if matchesTitle(options.wrappers, title) then
found = true
elseif type(options.wrappers) == 'table' then
for _,v in pairs(options.wrappers) do
if matchesTitle(v, title) then
found = true
break
end
end
end
-- We test for false specifically here so that nil (the default) acts like true.
if found or options.frameOnly == false then
pargs = parent.args
end
if not found or options.parentOnly == false then
fargs = frame.args
end
end
else
-- options.wrapper isn't set, so check the other options.
if not options.parentOnly then
fargs = frame.args
end
if not options.frameOnly then
local parent = frame:getParent()
pargs = parent and parent.args or nil
end
end
if options.parentFirst then
fargs, pargs = pargs, fargs
end
else
luaArgs = frame
end
-- Set the order of precedence of the argument tables. If the variables are
-- nil, nothing will be added to the table, which is how we avoid clashes
-- between the frame/parent args and the Lua args.
local argTables = {fargs}
argTables[#argTables + 1] = pargs
argTables[#argTables + 1] = luaArgs
--[[
-- Generate the tidyVal function. If it has been specified by the user, we
-- use that; if not, we choose one of four functions depending on the
-- options chosen. This is so that we don't have to call the options table
-- every time the function is called.
--]]
local tidyVal = options.valueFunc
if tidyVal then
if type(tidyVal) ~= 'function' then
error(
"bad value assigned to option 'valueFunc'"
.. '(function expected, got '
.. type(tidyVal)
.. ')',
2
)
end
elseif options.trim ~= false then
if options.removeBlanks ~= false then
tidyVal = tidyValDefault
else
tidyVal = tidyValTrimOnly
end
else
if options.removeBlanks ~= false then
tidyVal = tidyValRemoveBlanksOnly
else
tidyVal = tidyValNoChange
end
end
--[[
-- Set up the args, metaArgs and nilArgs tables. args will be the one
-- accessed from functions, and metaArgs will hold the actual arguments. Nil
-- arguments are memoized in nilArgs, and the metatable connects all of them
-- together.
--]]
local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}
setmetatable(args, metatable)
local function mergeArgs(tables)
--[[
-- Accepts multiple tables as input and merges their keys and values
-- into one table. If a value is already present it is not overwritten;
-- tables listed earlier have precedence. We are also memoizing nil
-- values, which can be overwritten if they are 's' (soft).
--]]
for _, t in ipairs(tables) do
for key, val in pairs(t) do
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
local tidiedVal = tidyVal(key, val)
if tidiedVal == nil then
nilArgs[key] = 's'
else
metaArgs[key] = tidiedVal
end
end
end
end
end
--[[
-- Define metatable behaviour. Arguments are memoized in the metaArgs table,
-- and are only fetched from the argument tables once. Fetching arguments
-- from the argument tables is the most resource-intensive step in this
-- module, so we try and avoid it where possible. For this reason, nil
-- arguments are also memoized, in the nilArgs table. Also, we keep a record
-- in the metatable of when pairs and ipairs have been called, so we do not
-- run pairs and ipairs on the argument tables more than once. We also do
-- not run ipairs on fargs and pargs if pairs has already been run, as all
-- the arguments will already have been copied over.
--]]
metatable.__index = function (t, key)
--[[
-- Fetches an argument when the args table is indexed. First we check
-- to see if the value is memoized, and if not we try and fetch it from
-- the argument tables. When we check memoization, we need to check
-- metaArgs before nilArgs, as both can be non-nil at the same time.
-- If the argument is not present in metaArgs, we also check whether
-- pairs has been run yet. If pairs has already been run, we return nil.
-- This is because all the arguments will have already been copied into
-- metaArgs by the mergeArgs function, meaning that any other arguments
-- must be nil.
--]]
if type(key) == 'string' then
key = options.translate[key]
end
local val = metaArgs[key]
if val ~= nil then
return val
elseif metatable.donePairs or nilArgs[key] then
return nil
end
for _, argTable in ipairs(argTables) do
local argTableVal = tidyVal(key, argTable[key])
if argTableVal ~= nil then
metaArgs[key] = argTableVal
return argTableVal
end
end
nilArgs[key] = 'h'
return nil
end
metatable.__newindex = function (t, key, val)
-- This function is called when a module tries to add a new value to the
-- args table, or tries to change an existing value.
if type(key) == 'string' then
key = options.translate[key]
end
if options.readOnly then
error(
'could not write to argument table key "'
.. tostring(key)
.. '"; the table is read-only',
2
)
elseif options.noOverwrite and args[key] ~= nil then
error(
'could not write to argument table key "'
.. tostring(key)
.. '"; overwriting existing arguments is not permitted',
2
)
elseif val == nil then
--[[
-- If the argument is to be overwritten with nil, we need to erase
-- the value in metaArgs, so that __index, __pairs and __ipairs do
-- not use a previous existing value, if present; and we also need
-- to memoize the nil in nilArgs, so that the value isn't looked
-- up in the argument tables if it is accessed again.
--]]
metaArgs[key] = nil
nilArgs[key] = 'h'
else
metaArgs[key] = val
end
end
local function translatenext(invariant)
local k, v = next(invariant.t, invariant.k)
invariant.k = k
if k == nil then
return nil
elseif type(k) ~= 'string' or not options.backtranslate then
return k, v
else
local backtranslate = options.backtranslate[k]
if backtranslate == nil then
-- Skip this one. This is a tail call, so this won't cause stack overflow
return translatenext(invariant)
else
return backtranslate, v
end
end
end
metatable.__pairs = function ()
-- Called when pairs is run on the args table.
if not metatable.donePairs then
mergeArgs(argTables)
metatable.donePairs = true
end
return translatenext, { t = metaArgs }
end
local function inext(t, i)
-- This uses our __index metamethod
local v = t[i + 1]
if v ~= nil then
return i + 1, v
end
end
metatable.__ipairs = function (t)
-- Called when ipairs is run on the args table.
return inext, t, 0
end
return args
end
return arguments
q4pqg5uzjm05gz8qzlgl807hlmhcwzs
Moduuli:Navbar
828
16863
50947
2026-06-11T18:40:38Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Navbar&oldid=1179557823
50947
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Navbar&oldid=1179557823
local p = {}
local cfg = mw.loadData('Module:Navbar/configuration')
local function get_title_arg(is_collapsible, template)
local title_arg = 1
if is_collapsible then title_arg = 2 end
if template then title_arg = 'template' end
return title_arg
end
local function choose_links(template, args)
-- The show table indicates the default displayed items.
-- view, talk, edit, hist, move, watch
-- TODO: Move to configuration.
local show = {true, true, true, false, false, false}
if template then
show[2] = false
show[3] = false
local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6,
talk = 2, edit = 3, hist = 4, move = 5, watch = 6}
-- TODO: Consider removing TableTools dependency.
for _, v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do
local num = index[v]
if num then show[num] = true end
end
end
local remove_edit_link = args.noedit
if remove_edit_link then show[3] = false end
return show
end
local function add_link(link_description, ul, is_mini, font_style)
local l
if link_description.url then
l = {'[', '', ']'}
else
l = {'[[', '|', ']]'}
end
ul:tag('li')
:addClass('nv-' .. link_description.full)
:wikitext(l[1] .. link_description.link .. l[2])
:tag(is_mini and 'abbr' or 'span')
:attr('title', link_description.html_title)
:cssText(font_style)
:wikitext(is_mini and link_description.mini or link_description.full)
:done()
:wikitext(l[3])
:done()
end
local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
if not title then
error(cfg.invalid_title .. title_text)
end
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
-- TODO: Get link_descriptions and show into the configuration module.
-- link_descriptions should be easier...
local link_descriptions = {
{ ['mini'] = 'v', ['full'] = 'view', ['html_title'] = 'View this template',
['link'] = title.fullText, ['url'] = false },
{ ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template',
['link'] = talkpage, ['url'] = false },
{ ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template',
['link'] = 'Special:EditPage/' .. title.fullText, ['url'] = false },
{ ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template',
['link'] = 'Special:PageHistory/' .. title.fullText, ['url'] = false },
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
['link'] = title:fullUrl('action=watch'), ['url'] = true }
}
local ul = mw.html.create('ul')
if has_brackets then
ul:addClass(cfg.classes.brackets)
:cssText(font_style)
end
for i, _ in ipairs(displayed_links) do
if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
end
return ul:done()
end
function p._navbar(args)
-- TODO: We probably don't need both fontstyle and fontcolor...
local font_style = args.fontstyle
local font_color = args.fontcolor
local is_collapsible = args.collapsible
local is_mini = args.mini
local is_plain = args.plain
local collapsible_class = nil
if is_collapsible then
collapsible_class = cfg.classes.collapsible
if not is_plain then is_mini = 1 end
if font_color then
font_style = (font_style or '') .. '; color: ' .. font_color .. ';'
end
end
local navbar_style = args.style
local div = mw.html.create():tag('div')
div
:addClass(cfg.classes.navbar)
:addClass(cfg.classes.plainlinks)
:addClass(cfg.classes.horizontal_list)
:addClass(collapsible_class) -- we made the determination earlier
:cssText(navbar_style)
if is_mini then div:addClass(cfg.classes.mini) end
local box_text = (args.text or cfg.box_text) .. ' '
-- the concatenated space guarantees the box text is separated
if not (is_mini or is_plain) then
div
:tag('span')
:addClass(cfg.classes.box_text)
:cssText(font_style)
:wikitext(box_text)
end
local template = args.template
local displayed_links = choose_links(template, args)
local has_brackets = args.brackets
local title_arg = get_title_arg(is_collapsible, template)
local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
div:node(list)
if is_collapsible then
local title_text_class
if is_mini then
title_text_class = cfg.classes.collapsible_title_mini
else
title_text_class = cfg.classes.collapsible_title_full
end
div:done()
:tag('div')
:addClass(title_text_class)
:cssText(font_style)
:wikitext(args[1])
end
local frame = mw.getCurrentFrame()
-- hlist -> navbar is best-effort to preserve old Common.css ordering.
return frame:extensionTag{
name = 'templatestyles', args = { src = cfg.hlist_templatestyles }
} .. frame:extensionTag{
name = 'templatestyles', args = { src = cfg.templatestyles }
} .. tostring(div:done())
end
function p.navbar(frame)
return p._navbar(require('Module:Arguments').getArgs(frame))
end
return p
dl9ttp6c9na32jkdktzffgeajp913vs
50957
50947
2026-06-11T18:57:28Z
Olksolo
356
fix namespace
50957
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Navbar&oldid=1179557823
local p = {}
local cfg = mw.loadData('Moduuli:Navbar/configuration')
local function get_title_arg(is_collapsible, template)
local title_arg = 1
if is_collapsible then title_arg = 2 end
if template then title_arg = 'template' end
return title_arg
end
local function choose_links(template, args)
-- The show table indicates the default displayed items.
-- view, talk, edit, hist, move, watch
-- TODO: Move to configuration.
local show = {true, true, true, false, false, false}
if template then
show[2] = false
show[3] = false
local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6,
talk = 2, edit = 3, hist = 4, move = 5, watch = 6}
-- TODO: Consider removing TableTools dependency.
for _, v in ipairs(require ('Moduuli:TableTools').compressSparseArray(args)) do
local num = index[v]
if num then show[num] = true end
end
end
local remove_edit_link = args.noedit
if remove_edit_link then show[3] = false end
return show
end
local function add_link(link_description, ul, is_mini, font_style)
local l
if link_description.url then
l = {'[', '', ']'}
else
l = {'[[', '|', ']]'}
end
ul:tag('li')
:addClass('nv-' .. link_description.full)
:wikitext(l[1] .. link_description.link .. l[2])
:tag(is_mini and 'abbr' or 'span')
:attr('title', link_description.html_title)
:cssText(font_style)
:wikitext(is_mini and link_description.mini or link_description.full)
:done()
:wikitext(l[3])
:done()
end
local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
if not title then
error(cfg.invalid_title .. title_text)
end
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
-- TODO: Get link_descriptions and show into the configuration module.
-- link_descriptions should be easier...
local link_descriptions = {
{ ['mini'] = 'v', ['full'] = 'view', ['html_title'] = 'View this template',
['link'] = title.fullText, ['url'] = false },
{ ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template',
['link'] = talkpage, ['url'] = false },
{ ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template',
['link'] = 'Special:EditPage/' .. title.fullText, ['url'] = false },
{ ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template',
['link'] = 'Special:PageHistory/' .. title.fullText, ['url'] = false },
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
['link'] = title:fullUrl('action=watch'), ['url'] = true }
}
local ul = mw.html.create('ul')
if has_brackets then
ul:addClass(cfg.classes.brackets)
:cssText(font_style)
end
for i, _ in ipairs(displayed_links) do
if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
end
return ul:done()
end
function p._navbar(args)
-- TODO: We probably don't need both fontstyle and fontcolor...
local font_style = args.fontstyle
local font_color = args.fontcolor
local is_collapsible = args.collapsible
local is_mini = args.mini
local is_plain = args.plain
local collapsible_class = nil
if is_collapsible then
collapsible_class = cfg.classes.collapsible
if not is_plain then is_mini = 1 end
if font_color then
font_style = (font_style or '') .. '; color: ' .. font_color .. ';'
end
end
local navbar_style = args.style
local div = mw.html.create():tag('div')
div
:addClass(cfg.classes.navbar)
:addClass(cfg.classes.plainlinks)
:addClass(cfg.classes.horizontal_list)
:addClass(collapsible_class) -- we made the determination earlier
:cssText(navbar_style)
if is_mini then div:addClass(cfg.classes.mini) end
local box_text = (args.text or cfg.box_text) .. ' '
-- the concatenated space guarantees the box text is separated
if not (is_mini or is_plain) then
div
:tag('span')
:addClass(cfg.classes.box_text)
:cssText(font_style)
:wikitext(box_text)
end
local template = args.template
local displayed_links = choose_links(template, args)
local has_brackets = args.brackets
local title_arg = get_title_arg(is_collapsible, template)
local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
div:node(list)
if is_collapsible then
local title_text_class
if is_mini then
title_text_class = cfg.classes.collapsible_title_mini
else
title_text_class = cfg.classes.collapsible_title_full
end
div:done()
:tag('div')
:addClass(title_text_class)
:cssText(font_style)
:wikitext(args[1])
end
local frame = mw.getCurrentFrame()
-- hlist -> navbar is best-effort to preserve old Common.css ordering.
return frame:extensionTag{
name = 'templatestyles', args = { src = cfg.hlist_templatestyles }
} .. frame:extensionTag{
name = 'templatestyles', args = { src = cfg.templatestyles }
} .. tostring(div:done())
end
function p.navbar(frame)
return p._navbar(require('Moduuli:Arguments').getArgs(frame))
end
return p
g05yow97tshvcudmj4dr8xzdmcjccgy
Moduuli:Navbar/configuration
828
16864
50948
2026-06-11T18:41:31Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Navbar/configuration&oldid=1358894823
50948
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Navbar/configuration&oldid=1358894823
return {
['templatestyles'] = 'Module:Navbar/styles.css',
['hlist_templatestyles'] = 'Hlist/styles.css',
['box_text'] = 'This box: ', -- default text box when not plain or mini
['title_namespace'] = 'Template', -- namespace to default to for title
['invalid_title'] = 'Invalid title ',
['classes'] = { -- set a line to nil if you don't want it
['navbar'] = 'navbar',
['plainlinks'] = 'plainlinks', -- plainlinks
['horizontal_list'] = 'hlist', -- horizontal list class
['mini'] = 'navbar-mini', -- class indicating small links in the navbar
['box_text'] = 'navbar-boxtext',
['brackets'] = 'navbar-brackets',
-- 'collapsible' is the key for a class to indicate the navbar is
-- setting up the collapsible element in addition to the normal
-- navbar.
['collapsible'] = 'navbar-collapse',
['collapsible_title_mini'] = 'navbar-ct-mini',
['collapsible_title_full'] = 'navbar-ct-full'
}
}
b73qb6uhatmrjcr4oz7ckabp75burhg
50958
50948
2026-06-11T18:58:04Z
Olksolo
356
fix namespace
50958
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Navbar/configuration&oldid=1358894823
return {
['templatestyles'] = 'Moduuli:Navbar/styles.css',
['hlist_templatestyles'] = 'Hlist/styles.css',
['box_text'] = 'This box: ', -- default text box when not plain or mini
['title_namespace'] = 'Template', -- namespace to default to for title
['invalid_title'] = 'Invalid title ',
['classes'] = { -- set a line to nil if you don't want it
['navbar'] = 'navbar',
['plainlinks'] = 'plainlinks', -- plainlinks
['horizontal_list'] = 'hlist', -- horizontal list class
['mini'] = 'navbar-mini', -- class indicating small links in the navbar
['box_text'] = 'navbar-boxtext',
['brackets'] = 'navbar-brackets',
-- 'collapsible' is the key for a class to indicate the navbar is
-- setting up the collapsible element in addition to the normal
-- navbar.
['collapsible'] = 'navbar-collapse',
['collapsible_title_mini'] = 'navbar-ct-mini',
['collapsible_title_full'] = 'navbar-ct-full'
}
}
dsv1v64y46nq1pstnswhvbgyh8ep2hp
Moduuli:Navbar/styles.css
828
16865
50949
2026-06-11T18:42:39Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Navbar/styles.css&oldid=1239400231
50949
sanitized-css
text/css
/* {{pp|small=yes}} */
.navbar {
display: inline;
font-size: 88%;
font-weight: normal;
}
.navbar-collapse {
float: left;
text-align: left;
}
.navbar-boxtext {
word-spacing: 0;
}
.navbar ul {
display: inline-block;
white-space: nowrap;
line-height: inherit;
}
.navbar-brackets::before {
margin-right: -0.125em;
content: '[ ';
}
.navbar-brackets::after {
margin-left: -0.125em;
content: ' ]';
}
.navbar li {
word-spacing: -0.125em;
}
.navbar a > span,
.navbar a > abbr {
text-decoration: inherit;
}
.navbar-mini abbr {
font-variant: small-caps;
border-bottom: none;
text-decoration: none;
cursor: inherit;
}
.navbar-ct-full {
font-size: 114%;
margin: 0 7em;
}
.navbar-ct-mini {
font-size: 114%;
margin: 0 4em;
}
/* not the usual @media screen, we simply remove navbar in @media print */
html.skin-theme-clientpref-night .navbar li a abbr {
color: var(--color-base) !important;
}
@media (prefers-color-scheme: dark) {
html.skin-theme-clientpref-os .navbar li a abbr {
color: var(--color-base) !important;
}
}
@media print {
.navbar {
display: none !important;
}
}
a68rpqs0zynjjfzlunkhpdlpnoe6c82
Moduuli:Color contrast
828
16866
50950
2026-06-11T18:44:09Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Color_contrast&oldid=1283164428
50950
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Color_contrast&oldid=1283164428
--
-- This module implements
-- {{Color contrast ratio}}
-- {{Greater color contrast ratio}}
-- {{ColorToLum}}
-- {{RGBColorToLum}}
--
local p = {}
local HTMLcolor = mw.loadData( 'Module:Color contrast/colors' )
local function sRGB (v)
if (v <= 0.03928) then
v = v / 12.92
else
v = math.pow((v+0.055)/1.055, 2.4)
end
return v
end
local function rgbdec2lum(R, G, B)
if ( 0 <= R and R < 256 and 0 <= G and G < 256 and 0 <= B and B < 256 ) then
return 0.2126 * sRGB(R/255) + 0.7152 * sRGB(G/255) + 0.0722 * sRGB(B/255)
else
return ''
end
end
local function hsl2lum(h, s, l)
if ( 0 <= h and h < 360 and 0 <= s and s <= 1 and 0 <= l and l <= 1 ) then
local c = (1 - math.abs(2*l - 1))*s
local x = c*(1 - math.abs( math.fmod(h/60, 2) - 1) )
local m = l - c/2
local r, g, b = m, m, m
if( 0 <= h and h < 60 ) then
r = r + c
g = g + x
elseif( 60 <= h and h < 120 ) then
r = r + x
g = g + c
elseif( 120 <= h and h < 180 ) then
g = g + c
b = b + x
elseif( 180 <= h and h < 240 ) then
g = g + x
b = b + c
elseif( 240 <= h and h < 300 ) then
r = r + x
b = b + c
elseif( 300 <= h and h < 360 ) then
r = r + c
b = b + x
end
return rgbdec2lum(255*r, 255*g, 255*b)
else
return ''
end
end
local function color2lum(c)
if (c == nil) then
return ''
end
-- html '#' entity
c = c:gsub("#", "#")
-- whitespace
c = c:match( '^%s*(.-)[%s;]*$' )
-- unstrip nowiki strip markers
c = mw.text.unstripNoWiki(c)
-- lowercase
c = c:lower()
-- first try to look it up
local L = HTMLcolor[c]
if (L ~= nil) then
return L
end
-- convert from hsl
if mw.ustring.match(c,'^hsl%([%s]*[0-9][0-9%.]*[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$') then
local h, s, l = mw.ustring.match(c,'^hsl%([%s]*([0-9][0-9%.]*)[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$')
return hsl2lum(tonumber(h), tonumber(s)/100, tonumber(l)/100)
end
-- convert from rgb
if mw.ustring.match(c,'^rgb%([%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*%)$') then
local R, G, B = mw.ustring.match(c,'^rgb%([%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*%)$')
return rgbdec2lum(tonumber(R), tonumber(G), tonumber(B))
end
-- convert from rgb percent
if mw.ustring.match(c,'^rgb%([%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$') then
local R, G, B = mw.ustring.match(c,'^rgb%([%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$')
return rgbdec2lum(255*tonumber(R)/100, 255*tonumber(G)/100, 255*tonumber(B)/100)
end
-- remove leading # (if there is one) and whitespace
c = mw.ustring.match(c, '^[%s#]*([a-f0-9]*)[%s]*$')
-- split into rgb
local cs = mw.text.split(c or '', '')
if( #cs == 6 ) then
local R = 16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[2])
local G = 16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[4])
local B = 16*tonumber('0x' .. cs[5]) + tonumber('0x' .. cs[6])
return rgbdec2lum(R, G, B)
elseif ( #cs == 3 ) then
local R = 16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[1])
local G = 16*tonumber('0x' .. cs[2]) + tonumber('0x' .. cs[2])
local B = 16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[3])
return rgbdec2lum(R, G, B)
end
-- failure, return blank
return ''
end
-- This exports the function for use in other modules.
-- The colour is passed as a string.
function p._lum(color)
return color2lum(color)
end
function p._greatercontrast(args)
local bias = tonumber(args['bias'] or '0') or 0
local css = (args['css'] and args['css'] ~= '') and true or false
local v1 = color2lum(args[1] or '')
local c2 = args[2] or 'white'
local v2 = color2lum(c2)
local c3 = args[3] or 'black'
local v3 = color2lum(c3)
local ratio1 = -1;
local ratio2 = -1;
if (type(v1) == 'number' and type(v2) == 'number') then
ratio1 = (v2 + 0.05)/(v1 + 0.05)
ratio1 = (ratio1 < 1) and 1/ratio1 or ratio1
end
if (type(v1) == 'number' and type(v3) == 'number') then
ratio2 = (v3 + 0.05)/(v1 + 0.05)
ratio2 = (ratio2 < 1) and 1/ratio2 or ratio2
end
if css then
local c1 = args[1] or ''
if mw.ustring.match(c1, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or
mw.ustring.match(c1, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then
c1 = '#' .. c1
end
if mw.ustring.match(c2, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or
mw.ustring.match(c2, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then
c2 = '#' .. c2
end
if mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or
mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then
c3 = '#' .. c3
end
return 'background-color:' .. c1 .. '; color:' .. ((ratio1 > 0) and (ratio2 > 0) and ((ratio1 + bias > ratio2) and c2 or c3) or '') .. ';'
end
return (ratio1 > 0) and (ratio2 > 0) and ((ratio1 + bias > ratio2) and c2 or c3) or ''
end
function p._ratio(args)
local v1 = color2lum(args[1])
local v2 = color2lum(args[2])
if (type(v1) == 'number' and type(v2) == 'number') then
-- v1 should be the brighter of the two.
if v2 > v1 then
v1, v2 = v2, v1
end
return (v1 + 0.05)/(v2 + 0.05)
else
return args['error'] or '?'
end
end
function p._styleratio(args)
local style = (args[1] or ''):lower()
local bg, fg = 'white', 'black'
local lum_bg, lum_fg = 1, 0
if args[2] then
local lum = color2lum(args[2])
if lum ~= '' then bg, lum_bg = args[2], lum end
end
if args[3] then
local lum = color2lum(args[3])
if lum ~= '' then fg, lum_fg = args[3], lum end
end
local slist = mw.text.split(mw.ustring.gsub(mw.ustring.gsub(style or '', '&#[Xx]23;', '#'), '#', '#'), ';')
for k = 1,#slist do
local s = slist[k]
local k,v = s:match( '^[%s]*([^:]-):([^:]-)[%s;]*$' )
k = k or ''
v = v or ''
if (k:match('^[%s]*(background)[%s]*$') or k:match('^[%s]*(background%-color)[%s]*$')) then
local lum = color2lum(v)
if( lum ~= '' ) then bg, lum_bg = v, lum end
elseif (k:match('^[%s]*(color)[%s]*$')) then
local lum = color2lum(v)
if( lum ~= '' ) then bg, lum_fg = v, lum end
end
end
if lum_bg > lum_fg then
return (lum_bg + 0.05)/(lum_fg + 0.05)
else
return (lum_fg + 0.05)/(lum_bg + 0.05)
end
end
--[[
Use {{#invoke:Color contrast|somecolor}} directly or
{{#invoke:Color contrast}} from a wrapper template.
Parameters:
-- |1= — required; A color to check.
--]]
function p.lum(frame)
local color = frame.args[1] or frame:getParent().args[1]
return p._lum(color)
end
function p.ratio(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
return p._ratio(args)
end
function p.styleratio(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
return p._styleratio(args)
end
function p.greatercontrast(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
return p._greatercontrast(args)
end
return p
sjkbwz42zyddcrbm0dfoc7itswpbsvg
50959
50950
2026-06-11T18:58:50Z
Olksolo
356
fix namespace
50959
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Color_contrast&oldid=1283164428
--
-- This module implements
-- {{Color contrast ratio}}
-- {{Greater color contrast ratio}}
-- {{ColorToLum}}
-- {{RGBColorToLum}}
--
local p = {}
local HTMLcolor = mw.loadData( 'Moduuli:Color contrast/colors' )
local function sRGB (v)
if (v <= 0.03928) then
v = v / 12.92
else
v = math.pow((v+0.055)/1.055, 2.4)
end
return v
end
local function rgbdec2lum(R, G, B)
if ( 0 <= R and R < 256 and 0 <= G and G < 256 and 0 <= B and B < 256 ) then
return 0.2126 * sRGB(R/255) + 0.7152 * sRGB(G/255) + 0.0722 * sRGB(B/255)
else
return ''
end
end
local function hsl2lum(h, s, l)
if ( 0 <= h and h < 360 and 0 <= s and s <= 1 and 0 <= l and l <= 1 ) then
local c = (1 - math.abs(2*l - 1))*s
local x = c*(1 - math.abs( math.fmod(h/60, 2) - 1) )
local m = l - c/2
local r, g, b = m, m, m
if( 0 <= h and h < 60 ) then
r = r + c
g = g + x
elseif( 60 <= h and h < 120 ) then
r = r + x
g = g + c
elseif( 120 <= h and h < 180 ) then
g = g + c
b = b + x
elseif( 180 <= h and h < 240 ) then
g = g + x
b = b + c
elseif( 240 <= h and h < 300 ) then
r = r + x
b = b + c
elseif( 300 <= h and h < 360 ) then
r = r + c
b = b + x
end
return rgbdec2lum(255*r, 255*g, 255*b)
else
return ''
end
end
local function color2lum(c)
if (c == nil) then
return ''
end
-- html '#' entity
c = c:gsub("#", "#")
-- whitespace
c = c:match( '^%s*(.-)[%s;]*$' )
-- unstrip nowiki strip markers
c = mw.text.unstripNoWiki(c)
-- lowercase
c = c:lower()
-- first try to look it up
local L = HTMLcolor[c]
if (L ~= nil) then
return L
end
-- convert from hsl
if mw.ustring.match(c,'^hsl%([%s]*[0-9][0-9%.]*[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$') then
local h, s, l = mw.ustring.match(c,'^hsl%([%s]*([0-9][0-9%.]*)[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$')
return hsl2lum(tonumber(h), tonumber(s)/100, tonumber(l)/100)
end
-- convert from rgb
if mw.ustring.match(c,'^rgb%([%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*[%s]*%)$') then
local R, G, B = mw.ustring.match(c,'^rgb%([%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*,[%s]*([0-9][0-9]*)[%s]*%)$')
return rgbdec2lum(tonumber(R), tonumber(G), tonumber(B))
end
-- convert from rgb percent
if mw.ustring.match(c,'^rgb%([%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*,[%s]*[0-9][0-9%.]*%%[%s]*%)$') then
local R, G, B = mw.ustring.match(c,'^rgb%([%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*,[%s]*([0-9][0-9%.]*)%%[%s]*%)$')
return rgbdec2lum(255*tonumber(R)/100, 255*tonumber(G)/100, 255*tonumber(B)/100)
end
-- remove leading # (if there is one) and whitespace
c = mw.ustring.match(c, '^[%s#]*([a-f0-9]*)[%s]*$')
-- split into rgb
local cs = mw.text.split(c or '', '')
if( #cs == 6 ) then
local R = 16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[2])
local G = 16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[4])
local B = 16*tonumber('0x' .. cs[5]) + tonumber('0x' .. cs[6])
return rgbdec2lum(R, G, B)
elseif ( #cs == 3 ) then
local R = 16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[1])
local G = 16*tonumber('0x' .. cs[2]) + tonumber('0x' .. cs[2])
local B = 16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[3])
return rgbdec2lum(R, G, B)
end
-- failure, return blank
return ''
end
-- This exports the function for use in other modules.
-- The colour is passed as a string.
function p._lum(color)
return color2lum(color)
end
function p._greatercontrast(args)
local bias = tonumber(args['bias'] or '0') or 0
local css = (args['css'] and args['css'] ~= '') and true or false
local v1 = color2lum(args[1] or '')
local c2 = args[2] or 'white'
local v2 = color2lum(c2)
local c3 = args[3] or 'black'
local v3 = color2lum(c3)
local ratio1 = -1;
local ratio2 = -1;
if (type(v1) == 'number' and type(v2) == 'number') then
ratio1 = (v2 + 0.05)/(v1 + 0.05)
ratio1 = (ratio1 < 1) and 1/ratio1 or ratio1
end
if (type(v1) == 'number' and type(v3) == 'number') then
ratio2 = (v3 + 0.05)/(v1 + 0.05)
ratio2 = (ratio2 < 1) and 1/ratio2 or ratio2
end
if css then
local c1 = args[1] or ''
if mw.ustring.match(c1, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or
mw.ustring.match(c1, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then
c1 = '#' .. c1
end
if mw.ustring.match(c2, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or
mw.ustring.match(c2, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then
c2 = '#' .. c2
end
if mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') or
mw.ustring.match(v3, '^[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]$') then
c3 = '#' .. c3
end
return 'background-color:' .. c1 .. '; color:' .. ((ratio1 > 0) and (ratio2 > 0) and ((ratio1 + bias > ratio2) and c2 or c3) or '') .. ';'
end
return (ratio1 > 0) and (ratio2 > 0) and ((ratio1 + bias > ratio2) and c2 or c3) or ''
end
function p._ratio(args)
local v1 = color2lum(args[1])
local v2 = color2lum(args[2])
if (type(v1) == 'number' and type(v2) == 'number') then
-- v1 should be the brighter of the two.
if v2 > v1 then
v1, v2 = v2, v1
end
return (v1 + 0.05)/(v2 + 0.05)
else
return args['error'] or '?'
end
end
function p._styleratio(args)
local style = (args[1] or ''):lower()
local bg, fg = 'white', 'black'
local lum_bg, lum_fg = 1, 0
if args[2] then
local lum = color2lum(args[2])
if lum ~= '' then bg, lum_bg = args[2], lum end
end
if args[3] then
local lum = color2lum(args[3])
if lum ~= '' then fg, lum_fg = args[3], lum end
end
local slist = mw.text.split(mw.ustring.gsub(mw.ustring.gsub(style or '', '&#[Xx]23;', '#'), '#', '#'), ';')
for k = 1,#slist do
local s = slist[k]
local k,v = s:match( '^[%s]*([^:]-):([^:]-)[%s;]*$' )
k = k or ''
v = v or ''
if (k:match('^[%s]*(background)[%s]*$') or k:match('^[%s]*(background%-color)[%s]*$')) then
local lum = color2lum(v)
if( lum ~= '' ) then bg, lum_bg = v, lum end
elseif (k:match('^[%s]*(color)[%s]*$')) then
local lum = color2lum(v)
if( lum ~= '' ) then bg, lum_fg = v, lum end
end
end
if lum_bg > lum_fg then
return (lum_bg + 0.05)/(lum_fg + 0.05)
else
return (lum_fg + 0.05)/(lum_bg + 0.05)
end
end
--[[
Use {{#invoke:Color contrast|somecolor}} directly or
{{#invoke:Color contrast}} from a wrapper template.
Parameters:
-- |1= — required; A color to check.
--]]
function p.lum(frame)
local color = frame.args[1] or frame:getParent().args[1]
return p._lum(color)
end
function p.ratio(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
return p._ratio(args)
end
function p.styleratio(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
return p._styleratio(args)
end
function p.greatercontrast(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
return p._greatercontrast(args)
end
return p
a0loipnczugksx1dzd0ivnqecm58v39
Moduuli:Color contrast/colors
828
16867
50951
2026-06-11T18:44:54Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Color_contrast/colors&oldid=879950256
50951
Scribunto
text/plain
return {
aliceblue = 0.92880068253475,
antiquewhite = 0.84646951707754,
aqua = 0.7874,
aquamarine = 0.8078549208338,
azure = 0.97265264954166,
beige = 0.8988459998705,
bisque = 0.80732327372979,
black = 0,
blanchedalmond = 0.85084439608156,
blue = 0.0722,
blueviolet = 0.12622014321946,
brown = 0.098224287876511,
burlywood = 0.51559844533893,
cadetblue = 0.29424681085422,
chartreuse = 0.76032025902623,
chocolate = 0.23898526114557,
coral = 0.37017930872924,
cornflowerblue = 0.30318641994179,
cornsilk = 0.93562110372965,
crimson = 0.16042199953026,
cyan = 0.7874,
darkblue = 0.018640801980939,
darkcyan = 0.20329317839046,
darkgoldenrod = 0.27264703559993,
darkgray = 0.39675523072563,
darkgreen = 0.091143429047575,
darkgrey = 0.39675523072563,
darkkhaki = 0.45747326349994,
darkmagenta = 0.07353047651207,
darkolivegreen = 0.12651920884889,
darkorange = 0.40016167026524,
darkorchid = 0.13413142174857,
darkred = 0.054889674531132,
darksalmon = 0.40541471563381,
darkseagreen = 0.43789249325969,
darkslateblue = 0.065792846227988,
darkslategray = 0.067608151928044,
darkslategrey = 0.067608151928044,
darkturquoise = 0.4874606277449,
darkviolet = 0.10999048339343,
deeppink = 0.23866895828276,
deepskyblue = 0.44481603395575,
dimgray = 0.14126329114027,
dimgrey = 0.14126329114027,
dodgerblue = 0.27442536991456,
firebrick = 0.10724525535015,
floralwhite = 0.95922484825004,
forestgreen = 0.18920812076002,
fuchsia = 0.2848,
gainsboro = 0.71569350050648,
ghostwhite = 0.94311261886323,
gold = 0.69860877428159,
goldenrod = 0.41919977809569,
gray = 0.2158605001139,
green = 0.15438342968146,
greenyellow = 0.80609472611453,
grey = 0.2158605001139,
honeydew = 0.96336535554782,
hotpink = 0.34658438169715,
indianred = 0.21406134963884,
indigo = 0.03107561486337,
ivory = 0.99071270600615,
khaki = 0.77012343394121,
lavender = 0.80318750514521,
lavenderblush = 0.90172748631046,
lawngreen = 0.73905893124963,
lemonchiffon = 0.94038992245622,
lightblue = 0.63709141280807,
lightcoral = 0.35522120733135,
lightcyan = 0.94587293494829,
lightgoldenrodyellow = 0.93348351018297,
lightgray = 0.65140563741982,
lightgreen = 0.69091979956865,
lightgrey = 0.65140563741982,
lightpink = 0.58566152734898,
lightsalmon = 0.4780675225206,
lightseagreen = 0.35050145117042,
lightskyblue = 0.56195637618331,
lightslategray = 0.23830165007287,
lightslategrey = 0.23830165007287,
lightsteelblue = 0.53983888284666,
lightyellow = 0.98161818392882,
lime = 0.7152,
limegreen = 0.44571042246098,
linen = 0.88357340984379,
magenta = 0.2848,
maroon = 0.045891942324215,
mediumaquamarine = 0.49389703310801,
mediumblue = 0.044077780212328,
mediumorchid = 0.21639251153773,
mediumpurple = 0.22905858091648,
mediumseagreen = 0.34393112338131,
mediumslateblue = 0.20284629471622,
mediumspringgreen = 0.70704308194184,
mediumturquoise = 0.5133827926448,
mediumvioletred = 0.14371899849357,
midnightblue = 0.02071786635086,
mintcream = 0.97834604947588,
mistyrose = 0.82183047859185,
moccasin = 0.80083000991567,
navajowhite = 0.76519682342785,
navy = 0.015585128108224,
oldlace = 0.91900633405549,
olive = 0.20027537200568,
olivedrab = 0.22593150951929,
orange = 0.4817026703631,
orangered = 0.25516243753416,
orchid = 0.31348806761439,
palegoldenrod = 0.78792647887614,
palegreen = 0.77936759006353,
paleturquoise = 0.76436077921714,
palevioletred = 0.28754994117889,
papayawhip = 0.87797100199835,
peachpuff = 0.74905589878251,
peru = 0.30113074877936,
pink = 0.63271070702466,
plum = 0.45734221587969,
powderblue = 0.68254586500605,
purple = 0.061477070432439,
rebeccapurple = 0.07492341159447,
red = 0.2126,
rosybrown = 0.32319457649407,
royalblue = 0.16663210743188,
saddlebrown = 0.097922285020521,
salmon = 0.36977241527596,
sandybrown = 0.46628543696283,
seagreen = 0.19734199706275,
seashell = 0.92737862206922,
sienna = 0.13697631337098,
silver = 0.52711512570581,
skyblue = 0.55291668518184,
slateblue = 0.14784278062136,
slategray = 0.20896704076536,
slategrey = 0.20896704076536,
snow = 0.96533341834849,
springgreen = 0.73052306068529,
steelblue = 0.20562642207625,
tan = 0.48237604163921,
teal = 0.16996855778968,
thistle = 0.56818401093733,
tomato = 0.30638612719415,
turquoise = 0.5895536427578,
violet = 0.40315452986676,
wheat = 0.74909702820482,
white = 1,
whitesmoke = 0.91309865179342,
yellow = 0.9278,
yellowgreen = 0.50762957208707,
}
chi69ar1btd4wp6xbk3uez6sfu0vipn
Šablonu:Hlist/styles.css
10
16868
50954
2026-06-11T18:52:57Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Template:Hlist/styles.css&oldid=1333133064
50954
sanitized-css
text/css
/* {{pp-template}} */
/*
* hlist styles are defined in core and Minerva and differ in Minerva. The
* current definitions here (2023-01-01) are sufficient to override Minerva
* without use of the hlist-separated class. The most problematic styles were
* related to margin, padding, and the bullet. Check files listed at
* [[MediaWiki talk:Common.css/to do#hlist-separated]]
*/
/*
* TODO: When the majority of readership supports it (or some beautiful world
* in which grade C support is above the minimum threshold), use :is()
*/
.hlist dl,
.hlist ol,
.hlist ul {
margin: 0;
padding: 0;
}
/* Display list items inline */
.hlist dd,
.hlist dt,
.hlist li {
/*
* don't trust the note that says margin doesn't work with inline
* removing margin: 0 makes dds have margins again
* We also want to reset margin-right in Minerva
*/
margin: 0;
display: inline;
}
/* Display requested top-level lists inline */
.hlist.inline,
.hlist.inline dl,
.hlist.inline ol,
.hlist.inline ul,
/* Display nested lists inline */
.hlist dl dl,
.hlist dl ol,
.hlist dl ul,
.hlist ol dl,
.hlist ol ol,
.hlist ol ul,
.hlist ul dl,
.hlist ul ol,
.hlist ul ul {
display: inline;
}
/* Hide empty list items */
.hlist .mw-empty-li {
display: none;
}
/* TODO: :not() can maybe be used here to remove the later rule. naive test
* seems to work. more testing needed. like so:
*.hlist dt:not(:last-child)::after {
* content: ": ";
*}
*.hlist dd:not(:last-child)::after,
*.hlist li:not(:last-child)::after {
* content: " · ";
* font-weight: bold;
*}
*/
/* Generate interpuncts */
.hlist dt::after {
content: ": ";
}
.hlist dd::after,
.hlist li::after {
content: "\a0· ";
font-weight: bold;
}
.hlist dd:last-child::after,
.hlist dt:last-child::after,
.hlist li:last-child::after {
content: none;
}
/* Add parentheses around nested lists */
.hlist dd dd:first-child::before,
.hlist dd dt:first-child::before,
.hlist dd li:first-child::before,
.hlist dt dd:first-child::before,
.hlist dt dt:first-child::before,
.hlist dt li:first-child::before,
.hlist li dd:first-child::before,
.hlist li dt:first-child::before,
.hlist li li:first-child::before {
content: " (";
font-weight: normal;
}
.hlist dd dd:last-child::after,
.hlist dd dt:last-child::after,
.hlist dd li:last-child::after,
.hlist dt dd:last-child::after,
.hlist dt dt:last-child::after,
.hlist dt li:last-child::after,
.hlist li dd:last-child::after,
.hlist li dt:last-child::after,
.hlist li li:last-child::after {
content: ")";
font-weight: normal;
}
/* Put ordinals in front of ordered list items */
.hlist ol {
counter-reset: listitem;
}
.hlist ol > li {
counter-increment: listitem;
}
.hlist ol > li::before {
content: " " counter(listitem) "\a0";
}
.hlist dd ol > li:first-child::before,
.hlist dt ol > li:first-child::before,
.hlist li ol > li:first-child::before {
content: " (" counter(listitem) "\a0";
}
c4a9gdxc068l0us4sz11634bne7iv2z
Moduuli:Exponential search
828
16869
50955
2026-06-11T18:55:27Z
Olksolo
356
imported from https://en.wikipedia.org/w/index.php?title=Module:Exponential_search&oldid=1138644443
50955
Scribunto
text/plain
-- imported from https://en.wikipedia.org/w/index.php?title=Module:Exponential_search&oldid=1138644443
-- This module provides a generic exponential search algorithm.
require[[strict]]
local checkType = require('libraryUtil').checkType
local floor = math.floor
local function midPoint(lower, upper)
return floor(lower + (upper - lower) / 2)
end
local function search(testFunc, i, lower, upper)
if testFunc(i) then
if i + 1 == upper then
return i
end
lower = i
if upper then
i = midPoint(lower, upper)
else
i = i * 2
end
return search(testFunc, i, lower, upper)
else
upper = i
i = midPoint(lower, upper)
return search(testFunc, i, lower, upper)
end
end
return function (testFunc, init)
checkType('Exponential search', 1, testFunc, 'function')
checkType('Exponential search', 2, init, 'number', true)
if init and (init < 1 or init ~= floor(init) or init == math.huge) then
error(string.format(
"invalid init value '%s' detected in argument #2 to " ..
"'Exponential search' (init value must be a positive integer)",
tostring(init)
), 2)
end
init = init or 2
if not testFunc(1) then
return nil
end
return search(testFunc, init, 1, nil)
end
18ayyanbl5quveu16tfr8xavolc48x6
Šablonu:Potd/2026-06-12
10
16870
50961
2026-06-11T19:42:59Z
Frhdkazan
283
Uuzi sivu: Stonewall Inn with Orlando nightclub shooting memorial during Pride 2016 (50126p).jpg
50961
wikitext
text/x-wiki
Stonewall Inn with Orlando nightclub shooting memorial during Pride 2016 (50126p).jpg
afwo0wvpgb48fibsozy9tebnou51r8w
Šablonu:Motd/2026-06-12
10
16871
50964
2026-06-11T20:00:28Z
Frhdkazan
283
Uuzi sivu: Ondel-Ondel Betawi Street Performance in Jakarta.webm
50964
wikitext
text/x-wiki
Ondel-Ondel Betawi Street Performance in Jakarta.webm
goeaw7eywwebkx9bopee0ypxs3y1xxl
Moduuli:Infobox/styles.css
828
16872
50971
2026-06-11T21:12:14Z
Olksolo
356
import from https://en.wikipedia.org/w/index.php?title=Module:Infobox/styles.css&oldid=1358620234
50971
sanitized-css
text/css
/* {{pp|small=y}} */
/*
* This TemplateStyles sheet deliberately does NOT include the full set of
* infobox styles. We are still working to migrate all of the manual
* infoboxes. See [[MediaWiki talk:Common.css/to do#Infobox]]
* DO NOT ADD THEM HERE
*/
/* NOTE: This is maintained both here and in [[MediaWiki:Common.css]] until migration is complete.
* Starting with bare minimum for the benefit of [[mw:Manual:Safemode]]. */
@media (min-width: 640px) {
.infobox {
/* @noflip */
margin-left: 1em;
/* @noflip */
float: right;
/* @noflip */
clear: right;
width: 22em;
}
}
/*
* not strictly certain these styles are necessary since the modules now
* exclusively output infobox-subbox or infobox, not both
* just replicating the module faithfully
*/
.infobox-subbox {
padding: 0;
border: none;
margin: -3px;
width: auto;
min-width: 100%;
font-size: 100%;
clear: none;
float: none;
background-color: transparent;
color:inherit;
}
.infobox-3cols-child {
margin: -3px;
}
.infobox .navbar {
font-size: 100%;
}
/* remove when infobox is not a table anymore */
.infobox-hiddenrow,
/* we mean it, Minerva. but also Vector 2022 in the future at some point */
body.skin--responsive.skin--responsive .infobox .infobox-hiddenrow {
display: none;
}
/* Dark theme: [[William Wragg]], [[Coral Castle]] */
@media screen {
html.skin-theme-clientpref-night .infobox-full-data:not(.notheme) > div:not(.notheme)[style] {
background: #1f1f23 !important;
/* switch with var( --color-base ) when supported. */
color: #f8f9fa;
}
}
@media screen and (prefers-color-scheme: dark) {
html.skin-theme-clientpref-os .infobox-full-data:not(.notheme) > div:not(.notheme)[style] {
background: #1f1f23 !important;
/* switch with var( --color-base ) when supported. */
color: #f8f9fa;
}
}
/* Since infobox is a table, many infobox templates take advantage of this to
* add columns and rows to the infobox itself rather than as part of a new table
* inside them. This class should be discouraged and removed on the long term,
* but allows us to at least identify these tables going forward
* Currently in use on: [[Module:Infobox3cols]]
* Fixes issue described in [[phab:F55300125]] on Vector 2022.
*/
@media (min-width: 640px) {
body.skin--responsive .infobox-table {
display: table !important;
}
body.skin--responsive .infobox-table > caption {
display: table-caption !important;
}
body.skin--responsive .infobox-table > tbody {
display: table-row-group;
}
body.skin--responsive .infobox-table th,
body.skin--responsive .infobox-table td {
padding-left: inherit;
padding-right: inherit;
}
}
bi1nsztkx4350a55cuzjhaotvp5h216