Modul:CactaceaeTaxonok
Megjelenés
A modult a Modul:CactaceaeTaxonok/doc lapon tudod dokumentálni
local p = {}
-- Ultra-gyors formázó: csak a ténylegesen megjelenő sorokon fut le
local function formazSzinonimak(szoveg)
if not szoveg or szoveg == "" then return "" end
-- Alapvető karaktertisztítás
local tiszta = mw.ustring.gsub(szoveg, "[đ÷¤]", "")
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
-- 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 (sablonból vagy közvetlenül)
local args = frame:getParent().args
local szuro = args[1] and mw.text.trim(args[1]) or ""
-- Ha NINCS szűrő megadva, adjunk hibaüzenetet ahelyett, hogy megölnénk a szervert
if szuro == "" then
return "<div style='color:red; font-weight:bold; border:1px solid red; padding:10px;'>Hiba: Az adatbázis túl nagy a teljes megjelenítéshez. Kérlek, adj meg egy nemzetséget! (Például: {{CactaceaeTaxonokTáblázat|Acanthocalycium}})</div>"
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 = false
-- Soronkénti feldolgozás
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(mw.ustring.gsub(nemz, "¤", ""))
-- Csak ha egyezik a szűrővel
if tisztaNemz == szuro 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 fenti nemzetségben vagyunk)
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
end
if counter == 0 then
return "Nincs találat a következő nemzetségre: " .. szuro
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