Modul:CactaceaeTaxonok
Megjelenés
A modult a Modul:CactaceaeTaxonok/doc lapon tudod dokumentálni
local p = {}
-- Segédfüggvény a szimbólumok és HTML lista kezeléséhez
local function formazSzinonimak(szoveg)
if not szoveg or szoveg == "" then return "" end
-- 1. Felesleges karakterek törlése
local tiszta = szoveg:gsub("[đ÷]", ""):gsub("¤+", "")
-- 2. Átalakítások jelölőkké (ideiglenes elválasztó karaktert használunk: | )
tiszta = tiszta:gsub("≡≡", ", ≡")
tiszta = tiszta:gsub("==", "|=")
tiszta = tiszta:gsub("−−", "|−")
tiszta = tiszta:gsub("%-%-", "|−")
tiszta = tiszta:gsub(">≡", ", >≡")
tiszta = tiszta:gsub(">−", ", >−")
-- 3. Darabolás az elválasztó mentén és HTML lista építése
local res = ""
local elso = true
-- A string elosztása a '|' mentén (ahol új listapontot kértél)
for resz in mw.text.gsplit(tiszta, "|", true) do
local tiszta_resz = mw.text.trim(resz)
if tiszta_resz ~= "" then
-- Botanikai nevek dőltetése a részleten belül
local szavak = {}
for szo in tiszta_resz:gmatch("%S+") do
if szo:match("[≡=>−,]") or szo == "var." or szo == "subsp." or szo == "f." or szo == "Type:" then
table.insert(szavak, szo)
else
table.insert(szavak, "''" .. szo .. "''")
end
end
local formazott_resz = table.concat(szavak, " "):gsub("^,%s*", "")
if elso then
res = formazott_resz
elso = false
else
-- Ha már a második elemnél járunk, listát kezdünk/folytatunk
if not res:find("<ul") then
res = res .. '<ul style="margin-left: 1.5em; list-style-type: disc;">'
end
res = res .. "<li>" .. formazott_resz .. "</li>"
end
end
end
if res:find("<ul") then res = res .. "</ul>" end
return res
end
function p.tablazat(frame)
local status, adatModul = pcall(require, 'Modul:CactaceaeTaxonokData')
if not status then return "Hiba: A 'Modul:CactaceaeTaxonokData' nem található!" end
local nyers_adat = adatModul.getAdatok()
local res = '{| class="wikitable sortable datatable-hook stripe hover compact" data-page-length="50" style="width:100%; font-size:90%;"\n'
res = res .. "! # !! Taxonnév !! Típusfaj, szinonima\n"
local sorszam = 0
for sor in nyers_adat:gmatch("[^\r\n]+") do
local taxon = ""
local szinonimak = ""
if sor:match("^ß") then
local nemzettseg, tipus = sor:match("^ß%s*([^:]+)::%s*(.+)")
if nemzettseg then
taxon = "'''" .. mw.text.trim(nemzettseg) .. "'''"
szinonimak = tipus
end
elseif sor:match("^Ł") then
local tiszta = sor:gsub("^Ł%s*", "")
local t, sz = tiszta:match("([^¤]+)¤¤¤(.*)")
if t then
taxon = "''" .. mw.text.trim(t) .. "''"
szinonimak = sz
end
end
if taxon ~= "" then
sorszam = sorszam + 1
res = res .. "|-\n"
res = res .. "| " .. sorszam .. "\n"
res = res .. '| style="white-space: nowrap;" | ' .. taxon .. "\n"
-- Itt hívjuk meg a formázót
res = res .. "| " .. formazSzinonimak(szinonimak) .. "\n"
end
end
res = res .. "|}"
return frame:preprocess(res)
end
return p