„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 = {} | ||
-- | -- Villámgyors formázó: csak a ténylegesen megjelenő sorokon fut le | ||
local function formazSzinonimak(szoveg) | local function formazSzinonimak(szoveg) | ||
if not szoveg or szoveg == "" then return "" end | if not szoveg or szoveg == "" then return "" end | ||
-- | -- Gyors csere, csak a legszükségesebbekre | ||
local tiszta = mw.ustring.gsub(szoveg, "[đ÷¤]", "") | local tiszta = mw.ustring.gsub(szoveg, "[đ÷¤]", "") | ||
-- | -- Elválasztó csere (egyszerű karakternélküli kereséssel) | ||
tiszta = mw.ustring.gsub(tiszta, "≡≡", "###") | tiszta = mw.ustring.gsub(tiszta, "≡≡", "###") | ||
tiszta = mw.ustring.gsub(tiszta, "==", "###") | tiszta = mw.ustring.gsub(tiszta, "==", "###") | ||
tiszta = mw.ustring.gsub(tiszta, "−−", "###") | tiszta = mw.ustring.gsub(tiszta, "−−", "###") | ||
tiszta = mw.ustring.gsub(tiszta, "%-%-", "###") | tiszta = mw.ustring.gsub(tiszta, "%%-%%-", "###") | ||
local | local reszek = mw.text.split(tiszta, "###", true) | ||
local lista = {} | |||
for i=1, #reszek do | |||
for | local r = mw.text.trim(reszek[i]) | ||
local | if r ~= "" then | ||
if | -- Minimális dőltetés-korrekció | ||
-- | r = "''" .. r .. "''" | ||
r = r:gsub("≡", "''≡''"):gsub("=", "''=''"):gsub("−", "''−''") | |||
r = r:gsub("var%.", "''var.''"):gsub("subsp%.", "''subsp.''") | |||
r = r:gsub("''''", "") | |||
table.insert(lista, "<li>" .. r .. "</li>") | |||
table.insert( | |||
end | end | ||
end | end | ||
return #lista > 0 and ('<ul style="margin-left: 1.1em; list-style-type: disc; padding: 0; margin: 0;">' .. table.concat(lista) .. "</ul>") or "" | |||
end | end | ||
function p.tablazat(frame) | function p.tablazat(frame) | ||
-- | -- Paraméter átvétele a sablonból | ||
local | local args = frame:getParent().args | ||
local | local szuro = args[1] and mw.text.trim(args[1]) or "" | ||
if szuro == "" then szuro = nil end | |||
if | |||
local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData') | |||
local status, | if not status then return "Hiba: Adatmodul nem érhető el." end | ||
if not status then return "Hiba: | local nyers = dataModul.getAdatok() | ||
local | |||
local rows = {} | local rows = {} | ||
local | local counter = 0 | ||
local | local isVisible = true | ||
-- | -- Iteráció a sorokon | ||
for sor in mw.ustring.gmatch( | for sor in mw.ustring.gmatch(nyers, "[^\r\n]+") do | ||
local | local prefix = mw.ustring.sub(sor, 1, 1) | ||
if prefix == "ß" then | |||
-- Nemzetség detektálása | |||
if | |||
-- Nemzetség | |||
local nemz, tip = mw.ustring.match(sor, "^ß%s*([^:]+)::%s*(.+)") | local nemz, tip = mw.ustring.match(sor, "^ß%s*([^:]+)::%s*(.+)") | ||
if nemz then | if nemz then | ||
local tisztaNemz = mw.text.trim(nemz):gsub("¤", "") | |||
if not szuro or szuro == tisztaNemz then | |||
isVisible = true | |||
if not | counter = counter + 1 | ||
taxon_link = "'''[[:Kategória:" .. | local taxon_link = "'''[[:Kategória:" .. tisztaNemz .. "|" .. tisztaNemz .. "]]'''" | ||
table.insert(rows, "|-\n| " .. counter .. "\n| " .. taxon_link .. "\n| " .. formazSzinonimak(tip)) | |||
else | else | ||
isVisible = false | |||
end | end | ||
end | end | ||
elseif | elseif prefix == "Ł" and isVisible then | ||
-- Faj | -- Faj detektálása (csak ha a nemzetség szűrő engedi) | ||
local tiszta_sor = mw.ustring.sub(sor, 2) | local tiszta_sor = mw.ustring.sub(sor, 2) | ||
local t, sz = mw.ustring.match(tiszta_sor, "^%s*([^¤]+)¤¤¤(.*)") | local t, sz = mw.ustring.match(tiszta_sor, "^%s*([^¤]+)¤¤¤(.*)") | ||
if t then | if t then | ||
counter = counter + 1 | |||
taxon_link = "''[[" .. | local taxon_link = "''[[" .. mw.text.trim(t) .. "]]''" | ||
table.insert(rows, "|-\n| " .. counter .. "\n| " .. taxon_link .. "\n| " .. formazSzinonimak(sz)) | |||
end | end | ||
end | end | ||
-- | -- Kényszerített leállás, ha túl sok az adat (Wiki CPU korlát védelem) | ||
if counter > 1000 then | |||
table.insert(rows, "|-\n| colspan='3' style='color:red;' | A lista túl hosszú, kérlek használj nemzetség szűrőt!") | |||
break | |||
if | |||
table.insert(rows, "|-\n| colspan='3' | |||
break | |||
end | end | ||
end | end | ||
local head = '{| class="wikitable sortable datatable-hook stripe hover compact" data-page-length="50" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, szinonima\n' | |||
local | return frame:preprocess(head .. table.concat(rows, "\n") .. "\n|}") | ||
end | end | ||
return p | return p | ||
A lap 2026. január 7., 10:21-kori változata
A modult a Modul:CactaceaeTaxonok/doc lapon tudod dokumentálni
local p = {}
-- Villámgyors formázó: csak a ténylegesen megjelenő sorokon fut le
local function formazSzinonimak(szoveg)
if not szoveg or szoveg == "" then return "" end
-- Gyors csere, csak a legszükségesebbekre
local tiszta = mw.ustring.gsub(szoveg, "[đ÷¤]", "")
-- Elválasztó csere (egyszerű karakternélküli kereséssel)
tiszta = mw.ustring.gsub(tiszta, "≡≡", "###")
tiszta = mw.ustring.gsub(tiszta, "==", "###")
tiszta = mw.ustring.gsub(tiszta, "−−", "###")
tiszta = mw.ustring.gsub(tiszta, "%%-%%-", "###")
local reszek = mw.text.split(tiszta, "###", true)
local lista = {}
for i=1, #reszek do
local r = mw.text.trim(reszek[i])
if r ~= "" then
-- Minimális dőltetés-korrekció
r = "''" .. r .. "''"
r = r:gsub("≡", "''≡''"):gsub("=", "''=''"):gsub("−", "''−''")
r = r:gsub("var%.", "''var.''"):gsub("subsp%.", "''subsp.''")
r = r:gsub("''''", "")
table.insert(lista, "<li>" .. r .. "</li>")
end
end
return #lista > 0 and ('<ul style="margin-left: 1.1em; list-style-type: disc; padding: 0; margin: 0;">' .. table.concat(lista) .. "</ul>") or ""
end
function p.tablazat(frame)
-- Paraméter átvétele a sablonból
local args = frame:getParent().args
local szuro = args[1] and mw.text.trim(args[1]) or ""
if szuro == "" then szuro = nil end
local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData')
if not status then return "Hiba: Adatmodul nem érhető el." end
local nyers = dataModul.getAdatok()
local rows = {}
local counter = 0
local isVisible = true
-- Iteráció a sorokon
for sor in mw.ustring.gmatch(nyers, "[^\r\n]+") do
local prefix = mw.ustring.sub(sor, 1, 1)
if prefix == "ß" then
-- Nemzetség detektálása
local nemz, tip = mw.ustring.match(sor, "^ß%s*([^:]+)::%s*(.+)")
if nemz then
local tisztaNemz = mw.text.trim(nemz):gsub("¤", "")
if not szuro or szuro == tisztaNemz then
isVisible = true
counter = counter + 1
local taxon_link = "'''[[:Kategória:" .. tisztaNemz .. "|" .. tisztaNemz .. "]]'''"
table.insert(rows, "|-\n| " .. counter .. "\n| " .. taxon_link .. "\n| " .. formazSzinonimak(tip))
else
isVisible = false
end
end
elseif prefix == "Ł" and isVisible then
-- Faj detektálása (csak ha a nemzetség szűrő engedi)
local tiszta_sor = mw.ustring.sub(sor, 2)
local t, sz = mw.ustring.match(tiszta_sor, "^%s*([^¤]+)¤¤¤(.*)")
if t then
counter = counter + 1
local taxon_link = "''[[" .. mw.text.trim(t) .. "]]''"
table.insert(rows, "|-\n| " .. counter .. "\n| " .. taxon_link .. "\n| " .. formazSzinonimak(sz))
end
end
-- Kényszerített leállás, ha túl sok az adat (Wiki CPU korlát védelem)
if counter > 1000 then
table.insert(rows, "|-\n| colspan='3' style='color:red;' | A lista túl hosszú, kérlek használj nemzetség szűrőt!")
break
end
end
local head = '{| class="wikitable sortable datatable-hook stripe hover compact" data-page-length="50" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, szinonima\n'
return frame:preprocess(head .. table.concat(rows, "\n") .. "\n|}")
end
return p