„Modul:CactaceaeTaxonok” változatai közötti eltérés
Megjelenés
Nincs szerkesztési összefoglaló |
Nincs szerkesztési összefoglaló |
||
| 1. sor: | 1. sor: | ||
local p = {} | local p = {} | ||
-- | -- Gyors formázó a szinonimákhoz és típusfajokhoz | ||
local function | local function formazSzinonimak(sor) | ||
if not | if not sor or sor == "" then return "" end | ||
-- | |||
-- | local lista = {} | ||
-- A 3-as és 4-es jelölők mentén darabolunk | |||
-- Minták: 3 ≡≡ ... 3# vagy 3 == ... 3# vagy 4 ≡ ... 4# | |||
return | for szint, jel, tartalom in sor:gmatch("(%d)%s*([^%d%s#]+)%s*([^#]+)%s*%d#") do | ||
local tiszta_tartalom = mw.text.trim(tartalom) | |||
if tiszta_tartalom ~= "" then | |||
-- Botanikai rövidítések (var., subsp., f.) állóvá tétele a dőlt szövegben | |||
local f = "''" .. tiszta_tartalom .. "''" | |||
f = f:gsub("var%.", "''var.''"):gsub("subsp%.", "''subsp.''"):gsub("f%.", "''f.''") | |||
-- Speciális jelek (≡, ==, −) ne legyenek dőltek | |||
local sor_elem = "''" .. jel .. "'' " .. f | |||
sor_elem = sor_elem:gsub("''''", "") -- Takarítás | |||
table.insert(lista, "<li>" .. sor_elem .. "</li>") | |||
end | |||
end | |||
if #lista == 0 then return "" end | |||
return '<ul style="margin-left:1.1em; list-style-type:disc; padding:0; margin:0;">' .. table.concat(lista) .. "</ul>" | |||
end | end | ||
| 15. sor: | 30. sor: | ||
local szuro = args[1] and mw.text.trim(args[1]) or "" | local szuro = args[1] and mw.text.trim(args[1]) or "" | ||
local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData') | local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData') | ||
if not status then return "Hiba: | if not status then return "Hiba: Modul:CactaceaeTaxonokData nem található." end | ||
local nyers = dataModul.getAdatok() | local nyers = dataModul.getAdatok() | ||
| 26. sor: | 37. sor: | ||
local counter = 0 | local counter = 0 | ||
local isVisible = false | local isVisible = false | ||
-- Soronkénti feldolgozás | -- Soronkénti feldolgozás az új formátum alapján | ||
for sor in nyers:gmatch("[^\r\n]+") do | for sor in nyers:gmatch("[^\r\n]+") do | ||
local | local szint = sor:sub(1, 1) | ||
-- | -- 1-es szint: Nemzetség (pl. 1 Acanthocalycium :: Type: ...) | ||
if | if szint == "1" then | ||
local nemz, extra = sor:match("^1%s+([^%s:]+)%s*(.*)") | |||
if nemz then | |||
if | if szuro == "" or nemz == szuro then | ||
isVisible = true | isVisible = true | ||
counter = counter + 1 | counter = counter + 1 | ||
local | -- A nemzetség sor végén lévő 1# előtti részt formázzuk | ||
table.insert(rows, | local tipus_info = extra:match("::%s*(.-)%s*1#") or "" | ||
else isVisible = false end | |||
table.insert(rows, "|-\n| " .. counter .. "\n| '''[[:Kategória:" .. nemz .. "|" .. nemz .. "]]'''\n| " .. formazSzinonimak(tipus_info)) | |||
else | |||
-- | isVisible = false | ||
elseif | end | ||
local | end | ||
if | |||
-- 2-es szint: Faj (pl. 2 Acanthocalycium glaucum 2# 3 ...) | |||
elseif szint == "2" and isVisible then | |||
local fajnev, maradek = sor:match("^2%s+([^2#]+)2#%s*(.*)") | |||
if fajnev then | |||
counter = counter + 1 | counter = counter + 1 | ||
table.insert(rows, | local tiszta_fajnev = mw.text.trim(fajnev) | ||
table.insert(rows, "|-\n| " .. counter .. "\n| ''[[" .. tiszta_fajnev .. "]]''\n| " .. formazSzinonimak(maradek)) | |||
end | end | ||
end | end | ||
end | end | ||
if #rows == 0 then return | if #rows == 0 then | ||
return szuro ~= "" and "Nincs találat a következő nemzetségre: " .. szuro or "Nincs megjeleníthető adat." | |||
end | end | ||
local head = '{| class="wikitable sortable datatable-hook stripe hover compact" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, | local head = '{| class="wikitable sortable datatable-hook stripe hover compact" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, szinonimák\n' | ||
return frame:preprocess(head .. table.concat( | return frame:preprocess(head .. table.concat(rows, "\n") .. "\n|}") | ||
end | end | ||
return p | return p | ||
A lap 2026. január 9., 18:33-kori változata
A modult a Modul:CactaceaeTaxonok/doc lapon tudod dokumentálni
local p = {}
-- Gyors formázó a szinonimákhoz és típusfajokhoz
local function formazSzinonimak(sor)
if not sor or sor == "" then return "" end
local lista = {}
-- A 3-as és 4-es jelölők mentén darabolunk
-- Minták: 3 ≡≡ ... 3# vagy 3 == ... 3# vagy 4 ≡ ... 4#
for szint, jel, tartalom in sor:gmatch("(%d)%s*([^%d%s#]+)%s*([^#]+)%s*%d#") do
local tiszta_tartalom = mw.text.trim(tartalom)
if tiszta_tartalom ~= "" then
-- Botanikai rövidítések (var., subsp., f.) állóvá tétele a dőlt szövegben
local f = "''" .. tiszta_tartalom .. "''"
f = f:gsub("var%.", "''var.''"):gsub("subsp%.", "''subsp.''"):gsub("f%.", "''f.''")
-- Speciális jelek (≡, ==, −) ne legyenek dőltek
local sor_elem = "''" .. jel .. "'' " .. f
sor_elem = sor_elem:gsub("''''", "") -- Takarítás
table.insert(lista, "<li>" .. sor_elem .. "</li>")
end
end
if #lista == 0 then return "" end
return '<ul style="margin-left:1.1em; list-style-type:disc; padding:0; margin:0;">' .. table.concat(lista) .. "</ul>"
end
function p.tablazat(frame)
local args = frame:getParent().args
local szuro = args[1] and mw.text.trim(args[1]) or ""
local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData')
if not status then return "Hiba: Modul:CactaceaeTaxonokData nem található." end
local nyers = dataModul.getAdatok()
local rows = {}
local counter = 0
local isVisible = false
-- Soronkénti feldolgozás az új formátum alapján
for sor in nyers:gmatch("[^\r\n]+") do
local szint = sor:sub(1, 1)
-- 1-es szint: Nemzetség (pl. 1 Acanthocalycium :: Type: ...)
if szint == "1" then
local nemz, extra = sor:match("^1%s+([^%s:]+)%s*(.*)")
if nemz then
if szuro == "" or nemz == szuro then
isVisible = true
counter = counter + 1
-- A nemzetség sor végén lévő 1# előtti részt formázzuk
local tipus_info = extra:match("::%s*(.-)%s*1#") or ""
table.insert(rows, "|-\n| " .. counter .. "\n| '''[[:Kategória:" .. nemz .. "|" .. nemz .. "]]'''\n| " .. formazSzinonimak(tipus_info))
else
isVisible = false
end
end
-- 2-es szint: Faj (pl. 2 Acanthocalycium glaucum 2# 3 ...)
elseif szint == "2" and isVisible then
local fajnev, maradek = sor:match("^2%s+([^2#]+)2#%s*(.*)")
if fajnev then
counter = counter + 1
local tiszta_fajnev = mw.text.trim(fajnev)
table.insert(rows, "|-\n| " .. counter .. "\n| ''[[" .. tiszta_fajnev .. "]]''\n| " .. formazSzinonimak(maradek))
end
end
end
if #rows == 0 then
return szuro ~= "" and "Nincs találat a következő nemzetségre: " .. szuro or "Nincs megjeleníthető adat."
end
local head = '{| class="wikitable sortable datatable-hook stripe hover compact" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, szinonimák\n'
return frame:preprocess(head .. table.concat(rows, "\n") .. "\n|}")
end
return p