Modul:CactaceaeTaxonok
Megjelenés
A modult a Modul:CactaceaeTaxonok/doc lapon tudod dokumentálni
local p = {}
-- Unicode-biztos formázó a szinonimákhoz
local function formazSzinonimak(szoveg)
if not szoveg or szoveg == "" then return "" end
local tiszta = mw.ustring.gsub(szoveg, "[đ÷]", "")
tiszta = mw.ustring.gsub(tiszta, "¤+", "")
-- Jelölők egyszerűsítése
tiszta = mw.ustring.gsub(tiszta, ">−", "−")
tiszta = mw.ustring.gsub(tiszta, ">≡", "≡")
tiszta = mw.ustring.gsub(tiszta, ">=", "=")
-- Dupla jeleknél darabolunk új listapontba
tiszta = mw.ustring.gsub(tiszta, "≡≡", "|≡")
tiszta = mw.ustring.gsub(tiszta, "==", "|=")
tiszta = mw.ustring.gsub(tiszta, "−−", "|−")
tiszta = mw.ustring.gsub(tiszta, "%%-%%-", "|−")
local lista_elemek = {}
for resz in mw.text.gsplit(tiszta, "|", true) do
local tiszta_resz = mw.text.trim(resz)
if tiszta_resz ~= "" then
local szavak = {}
for szo in mw.ustring.gmatch(tiszta_resz, "%S+") do
if mw.ustring.find(szo, "[≡=−,]") or szo == "var." or szo == "subsp." or szo == "f." or szo == "Type:" then
table.insert(szavak, szo)
else
table.insert(szavak, "''" .. szo .. "''")
end
end
table.insert(lista_elemek, "<li>" .. table.concat(szavak, " ") .. "</li>")
end
end
if #lista_elemek > 0 then
return '<ul style="margin-left: 1.1em; list-style-type: disc; padding: 0; margin: 0;">' .. table.concat(lista_elemek) .. "</ul>"
end
return ""
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 mw.ustring.gmatch(nyers_adat, "[^\r\n]+") do
local taxon_nyers, szinonimak = "", ""
local tipus = ""
if mw.ustring.match(sor, "^ß") then
-- Nemzetség (ß)
local nemzettseg, szo = mw.ustring.match(sor, "^ß%s*([^:]+)::%s*(.+)")
if nemzettseg then
taxon_nyers = mw.text.trim(nemzettseg):gsub("¤+", "")
szinonimak = szo
tipus = "nemzettseg"
end
elseif mw.ustring.match(sor, "^Ł") then
-- Faj vagy egyéb (Ł)
local tiszta_sor = mw.ustring.gsub(sor, "^Ł%s*", "")
local t, sz = mw.ustring.match(tiszta_sor, "([^¤]+)¤¤¤(.*)")
if t then
taxon_nyers = mw.text.trim(t)
szinonimak = sz
tipus = "faj"
end
end
if taxon_nyers ~= "" then
sorszam = sorszam + 1
local taxon_link = ""
if tipus == "nemzettseg" then
-- Nemzetség: Kategória link + Vastagítás
taxon_link = "[[:Kategória:" .. taxon_nyers .. "|" .. taxon_nyers .. "]]"
taxon_link = "'''" .. taxon_link .. "'''"
else
-- Faj: Sima belső link + Dőltetés
taxon_link = "[[" .. taxon_nyers .. "]]"
taxon_link = "''" .. taxon_link .. "''"
end
res = res .. "|-\n"
res = res .. "| " .. sorszam .. "\n"
res = res .. '| style="white-space: nowrap;" | ' .. taxon_link .. "\n"
res = res .. "| " .. formazSzinonimak(szinonimak) .. "\n"
end
end
res = res .. "|}"
return frame:preprocess(res)
end
return p