Ugrás a tartalomhoz

„Modul:CactaceaeTaxonok” változatai közötti eltérés

Innen: MKOE wiki
Nincs szerkesztési összefoglaló
Nincs szerkesztési összefoglaló
 
(49 közbenső módosítás ugyanattól a felhasználótól nincs mutatva)
1. sor: 1. sor:
local p = {}
local p = {}


local nyers_adat = [[
-- Speciális formázó a taxonómiai nevekhez
ß Acanthocalycium :: Type: Acanthocalycium spiniflorum ¤¤¤¤
local function taxonFormazo(szoveg, isGenusLevel, isTypeLink)
Ł Acanthocalycium glaucum ¤¤¤ ÷  ≡≡ Lobivia thionantha var. glauca đ >≡ Echinopsis thionantha subsp. glauca ¤ >≡ Acanthocalycium thionanthum subsp. glaucum ¤¤ ÷  == Echinopsis glaucina đ
Ł Acanthocalycium leucanthum ¤¤¤ ÷  == Melocactus ambiguus đ ÷  == Cereus incurvispinus đ ÷  == Melocactus elegans đ ÷  == Echinonyctanthus leucanthus đ ÷  == Echinocactus salpigophorus đ ÷  == Echinopsis campylacantha var. leucantha đ ÷  == Echinopsis campylacantha var. stylodes đ ÷  == Echinopsis simplex đ ÷  == Cereus campylacanthus đ >≡ Echinopsis campylacantha ¤¤ ÷  == Echinopsis baldiana đ ÷  == Echinopsis cordobensis đ ÷  == Echinopsis intricatissima đ ÷  == Echinopsis melanopotamica đ ÷  == Echinopsis molesta đ ÷  == Echinopsis shaferi đ ÷  == Echinopsis spegazziniana đ ÷  == Echinopsis leucantha var. brasiliensis đ ÷  == Echinopsis gladispina đ ÷  == Echinopsis leucantha var. volliana đ
Ł Acanthocalycium rhodotrichum ¤¤¤ ÷  ≡≡ Echinopsis rhodotricha đ >− Acanthocalycium rhodotricum ¤¤ ÷  == Echinocactus forbesii đ ÷  == Echinopsis forbesii đ >≡ Echinopsis pentlandii var. forbesii ¤ >≡ Echinopsis pentlandii var. forbesii ¤ >≡ Lobivia pentlandii var. forbesii ¤¤ ÷  == Echinopsis valida var. forbesii đ ÷  == Cereus validissimus đ ÷  == Echinopsis rhodotricha var. roseiflora đ ÷  == Echinopsis spegazzinii đ ÷  == Echinopsis rhodotricha var. argentinensis đ ÷  == Echinopsis rhodotricha var. robusta đ ÷  == Echinopsis robinsoniana đ ÷  == Echinopsis chacoana var. spinosior đ >≡ Echinopsis rhodotricha var. spinosior ¤¤ ÷  == Echinopsis rhodotricha var. brevispina đ
Ł Acanthocalycium rhodotrichum subsp. chacoanum ¤¤¤ ÷  ≡≡ Echinopsis chacoana đ >≡ Echinopsis rhodotricha var. chacoana ¤ >≡ Echinopsis rhodotricha subsp. chacoana ¤¤ ÷  == Echinopsis klingleriana đ
Ł Acanthocalycium rhodotrichum subsp. rhodotrichum ¤¤¤ ÷  == Echinopsis minuana đ ÷  == Echinopsis meyeri đ
Ł Acanthocalycium spiniflorum ¤¤¤ ÷  ≡≡ Echinocactus spiniflorus đ >≡ Echinopsis spiniflora ¤ >≡ Lobivia spiniflora ¤¤ ÷  == Echinopsis klimpeliana đ >≡ Lobivia klimpeliana ¤ >≡ Acanthocalycium klimpelianum ¤ >≡ Lobivia spiniflora var. klimpeliana ¤¤ ÷  == Echinopsis violacea đ >≡ Acanthocalycium violaceum ¤ >≡ Lobivia spiniflora var. violacea ¤ >− Acanthocalycium spiniflorum f. violaceum ¤¤ ÷  == Acanthocalycium peitscherianum đ >≡ Echinopsis peitscherana ¤ >≡ Lobivia spiniflora var. peitscheriana ¤ >− Acanthocalycium spiniflorum f. peitscherianum ¤¤ ÷  == Acanthocalycium variiflorum đ ÷  == Lobivia spiniflora var. macrantha đ >≡ Acanthocalycium klimpelianum var. macranthum ¤¤
Ł Acanthocalycium thionanthum ¤¤¤ ÷  ≡≡ Echinocactus thionanthus đ >≡ Lobivia thionantha ¤ >≡ Echinopsis thionantha ¤ >≡ Echinopsis thionantha ¤ >− Lobivia thionanthus ¤¤ ÷  == Echinocactus chionanthus đ >≡ Lobivia chionanthus ¤ >≡ Echinopsis chionantha ¤ >≡ Acanthocalycium chionanthum ¤ >≡ Lobivia thionantha var. chionantha ¤¤ ÷  == Acanthocalycium griseum đ ÷  == Acanthocalycium brevispinum đ >≡ Echinopsis brevispina ¤ >≡ Lobivia thionantha var. brevispina ¤¤ ÷  == Acanthocalycium aurantiacum đ >≡ Echinopsis aurantiaca ¤ >≡ Lobivia thionantha var. aurantiaca ¤¤ ÷  == Acanthocalycium catamarcense đ >≡ Lobivia thionantha var. catamarcensis ¤¤ ÷  == Lobivia thionantha var. erythrantha đ
Ł Acanthocalycium thionanthum subsp. ferrarii ¤¤¤ ÷  ≡≡ Acanthocalycium ferrarii đ >≡ Lobivia thionantha var. ferrarii ¤ >≡ Echinopsis thionantha subsp. ferrarii ¤¤ ÷  == Lobivia thionantha var. munita đ >≡ Acanthocalycium thionanthum var. munitum ¤¤ ÷  == Lobivia thionantha var. variiflora đ
Ł Acanthocalycium thionanthum subsp. thionanthum ¤¤¤
]]
 
-- Segédfüggvény a nevek formázásához
local function formalNev(szoveg)
     if not szoveg or szoveg == "" then return "" end
     if not szoveg or szoveg == "" then return "" end
      
      
     local szavak = {}
     local tiszta_szoveg = szoveg:gsub("Type:", "Típusfaj:")
     -- Szétbontjuk szavakra, de megtartjuk a relációs jeleket
     -- Idézőjelek és link jelölő takarítása
     for szo in szoveg:gmatch("%S+") do
     local nyers = tiszta_szoveg:gsub("@", ""):gsub("'", ""):gsub("\"", "")
        if szo == "" or szo == "=" or szo == "" then
    nyers = mw.text.trim(nyers)
            table.insert(szavak, szo)
 
         elseif szo:match("^[A-Z][a-z]+$") then
    -- 1. Típusfaj linkelés
             -- Ha egyetlen nagybetűvel kezdődő szó (Nemzetség)
    if isTypeLink then
             table.insert(szavak, "'''''" .. szo .. "'''''")
         local nev_resz = nyers:match("Típusfaj:%s*(.*)")
        if nev_resz then
             local t = mw.text.trim(nev_resz)
             return "''Típusfaj:'' [[" .. t .. "|''" .. t .. "'']]"
         else
         else
             -- Minden más (fajnév, var., subsp. stb.) dőlt
             return "[[" .. nyers .. "|''" .. nyers .. "'']]"
            -- A 'var.' és 'subsp.' szavakat általában nem dőltetik, de a kérésed szerint mindent dőltetünk
            table.insert(szavak, "''" .. szo .. "''")
         end
         end
     end
     end
     return table.concat(szavak, " ")
 
    -- 2. Link jelölt szinonima (@)
    if tiszta_szoveg:find("@") then
        return "[[" .. nyers .. "|''" .. nyers .. "'']]"
    end
 
    -- 3. Normál formázás szavanként
    local szavak = mw.text.split(nyers, " ")
    local formalt_szavak = {}
    local allo_kulcsszavak = {
        ["subgen."] = true, ["subg."] = true, ["sect."] = true,
        ["subsect."] = true, ["subsp."] = true, ["var."] = true,
        ["f."] = true
    }
 
    for _, szo in ipairs(szavak) do
        if allo_kulcsszavak[szo] then
            -- A rövidítés ÁLLÓ betűs (nincs körülötte semmilyen jelölő)
            table.insert(formalt_szavak, szo)
        else
            -- A latin név részei
            if isGenusLevel then
                -- 1-es szintű sorban: VASTAG-DŐLT
                table.insert(formalt_szavak, "'''''" .. szo .. "'''''")
            else
                -- 2-es szintű (faj) sorban: SIMA DŐLT
                table.insert(formalt_szavak, "''" .. szo .. "''")
            end
        end
    end
 
     return table.concat(formalt_szavak, " ")
end
end


function p.tablazat(frame)
-- Szinonimák feldolgozása
     -- Próbáld meg az osztályokat szűkíteni az alapra, ami a másik oldalon működik
local function formazSzinonimak(sor, isParentGenus)
     local result = '{| class="wikitable datatable_hook"\n'
    if not sor or sor == "" then return "" end
     result = result .. "! scope=\"col\" | Taxonnév\n"
    local lista = {}
    result = result .. "! scope=\"col\" | Szinonima\n"
 
     -- Típusfaj
     local tipus_resz = sor:match("^([^%d]+)1#")
     if tipus_resz then
        local t = mw.text.trim(tipus_resz:gsub("^::%s*", ""))
        if t ~= "" then
            table.insert(lista, "<li>" .. taxonFormazo(t, false, true) .. "</li>")
        end
    end


     for sor in nyers_adat:gmatch("[^\r\n]+") do
    -- Szinonimák (3# és 4#)
         local taxon = ""
    local aktualis_sor = ""
        local szinonimak = ""
     for szint, jel, tartalom in mw.ustring.gmatch(sor, "(%d)%s*([^%d%s#]+)%s*([^#]+)%s*%d#") do
         if szint == "3" or szint == "4" then
            local tiszta_jel = mw.ustring.sub(jel, 1, 1)
            local trimmed = mw.text.trim(tartalom)
           
            -- Meghatározzuk a formázási szintet
            local subGen = trimmed:find("subg%.") or trimmed:find("sect%.") or trimmed:find("subsect%.")
            local isGenusLevel = isParentGenus or subGen
           
            local formalt = taxonFormazo(trimmed, isGenusLevel, false)
            local elem = tiszta_jel .. " " .. formalt


        if sor:match("") then
            if szint == "3" then
            taxon = sor:gsub("^ß%s*", ""):gsub("%s*::%s*", " "):gsub("¤+", "")
                if aktualis_sor ~= "" then table.insert(lista, "<li>" .. aktualis_sor .. "</li>") end
            szinonimak = ""
                aktualis_sor = elem
        elseif sor:match("^Ł") then
            else
            local tiszta = sor:gsub("^Ł%s*", "")
                aktualis_sor = aktualis_sor .. " " .. elem
             taxon, szinonimak = tiszta:match("([^¤]+)¤¤¤(.*)")
             end
         end
         end
    end
    if aktualis_sor ~= "" then table.insert(lista, "<li>" .. aktualis_sor .. "</li>") end
   
    if #lista == 0 then return "" end
    return '<ul style="list-style-type:disc; padding:0; margin:0 0 0 1.5em;">' .. table.concat(lista) .. "</ul>"
end


        if taxon and taxon ~= "" then
function p.tablazat(frame)
            -- Ügyeljünk rá, hogy ne legyen sortörés a cellán belül,
    local args = frame:getParent().args
            -- mert az megzavarja a scriptet
    local szuro = args[1] and mw.text.trim(args[1]) or ""
            taxon = mw.text.trim(taxon)
    local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData')
            szinonimak = mw.text.trim(szinonimak)
    if not status then return "Hiba: Adatmodul hiányzik." end
    local nyers = dataModul.getAdatok()


             result = result .. "|-\n| " .. taxon .. " || " .. szinonimak .. "\n"
    local rows, counter, isVisible = {}, 0, false
    for sor in nyers:gmatch("[^\r\n]+") do
        local szint = sor:sub(1, 1)
        if szint == "1" then
             local nemz = sor:match("^1%s+([^%s:]+)")
            isVisible = (szuro == "" or nemz == szuro)
            if nemz and isVisible then
                counter = counter + 1
                local nemz_link = "[[:Kategória:" .. nemz .. "|'''''" .. nemz .. "''''']]"
                local maradek = sor:match("^1%s+[^%s:]+%s*(.*)$") or ""
                table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | " .. nemz_link .. "\n| " .. formazSzinonimak(maradek, true))
            end
        elseif szint == "2" and isVisible then
            local fajnev, maradek = sor:match("^2%s+([^2#]+)2#%s*(.*)")
            if fajnev then
                counter = counter + 1
                local tiszta = mw.text.trim(fajnev)
                table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | [[" .. tiszta .. "|''" .. tiszta .. "'']]\n| " .. formazSzinonimak(maradek, false))
            end
         end
         end
     end
     end
 
   
     result = result .. "|}"
     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 result
    return frame:preprocess(head .. table.concat(rows, "\n") .. "\n|}")
end
end


return p
return p

A lap jelenlegi, 2026. január 10., 08:06-kori változata

A modult a Modul:CactaceaeTaxonok/doc lapon tudod dokumentálni

local p = {}

-- Speciális formázó a taxonómiai nevekhez
local function taxonFormazo(szoveg, isGenusLevel, isTypeLink)
    if not szoveg or szoveg == "" then return "" end
    
    local tiszta_szoveg = szoveg:gsub("Type:", "Típusfaj:")
    -- Idézőjelek és link jelölő takarítása
    local nyers = tiszta_szoveg:gsub("@", ""):gsub("'", ""):gsub("\"", "")
    nyers = mw.text.trim(nyers)

    -- 1. Típusfaj linkelés
    if isTypeLink then
        local nev_resz = nyers:match("Típusfaj:%s*(.*)")
        if nev_resz then
            local t = mw.text.trim(nev_resz)
            return "''Típusfaj:'' [[" .. t .. "|''" .. t .. "'']]"
        else
            return "[[" .. nyers .. "|''" .. nyers .. "'']]"
        end
    end

    -- 2. Link jelölt szinonima (@)
    if tiszta_szoveg:find("@") then
        return "[[" .. nyers .. "|''" .. nyers .. "'']]"
    end

    -- 3. Normál formázás szavanként
    local szavak = mw.text.split(nyers, " ")
    local formalt_szavak = {}
    local allo_kulcsszavak = {
        ["subgen."] = true, ["subg."] = true, ["sect."] = true, 
        ["subsect."] = true, ["subsp."] = true, ["var."] = true, 
        ["f."] = true
    }

    for _, szo in ipairs(szavak) do
        if allo_kulcsszavak[szo] then
            -- A rövidítés ÁLLÓ betűs (nincs körülötte semmilyen jelölő)
            table.insert(formalt_szavak, szo)
        else
            -- A latin név részei
            if isGenusLevel then
                -- 1-es szintű sorban: VASTAG-DŐLT
                table.insert(formalt_szavak, "'''''" .. szo .. "'''''")
            else
                -- 2-es szintű (faj) sorban: SIMA DŐLT
                table.insert(formalt_szavak, "''" .. szo .. "''")
            end
        end
    end

    return table.concat(formalt_szavak, " ")
end

-- Szinonimák feldolgozása
local function formazSzinonimak(sor, isParentGenus)
    if not sor or sor == "" then return "" end
    local lista = {}

    -- Típusfaj
    local tipus_resz = sor:match("^([^%d]+)1#")
    if tipus_resz then
        local t = mw.text.trim(tipus_resz:gsub("^::%s*", ""))
        if t ~= "" then
            table.insert(lista, "<li>" .. taxonFormazo(t, false, true) .. "</li>")
        end
    end

    -- Szinonimák (3# és 4#)
    local aktualis_sor = ""
    for szint, jel, tartalom in mw.ustring.gmatch(sor, "(%d)%s*([^%d%s#]+)%s*([^#]+)%s*%d#") do
        if szint == "3" or szint == "4" then
            local tiszta_jel = mw.ustring.sub(jel, 1, 1)
            local trimmed = mw.text.trim(tartalom)
            
            -- Meghatározzuk a formázási szintet
            local subGen = trimmed:find("subg%.") or trimmed:find("sect%.") or trimmed:find("subsect%.")
            local isGenusLevel = isParentGenus or subGen
            
            local formalt = taxonFormazo(trimmed, isGenusLevel, false)
            local elem = tiszta_jel .. " " .. formalt

            if szint == "3" then
                if aktualis_sor ~= "" then table.insert(lista, "<li>" .. aktualis_sor .. "</li>") end
                aktualis_sor = elem
            else
                aktualis_sor = aktualis_sor .. " " .. elem
            end
        end
    end

    if aktualis_sor ~= "" then table.insert(lista, "<li>" .. aktualis_sor .. "</li>") end
    
    if #lista == 0 then return "" end
    return '<ul style="list-style-type:disc; padding:0; margin:0 0 0 1.5em;">' .. 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: Adatmodul hiányzik." end
    local nyers = dataModul.getAdatok()

    local rows, counter, isVisible = {}, 0, false
    for sor in nyers:gmatch("[^\r\n]+") do
        local szint = sor:sub(1, 1)
        if szint == "1" then
            local nemz = sor:match("^1%s+([^%s:]+)")
            isVisible = (szuro == "" or nemz == szuro)
            if nemz and isVisible then
                counter = counter + 1
                local nemz_link = "[[:Kategória:" .. nemz .. "|'''''" .. nemz .. "''''']]"
                local maradek = sor:match("^1%s+[^%s:]+%s*(.*)$") or ""
                table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | " .. nemz_link .. "\n| " .. formazSzinonimak(maradek, true))
            end
        elseif szint == "2" and isVisible then
            local fajnev, maradek = sor:match("^2%s+([^2#]+)2#%s*(.*)")
            if fajnev then
                counter = counter + 1
                local tiszta = mw.text.trim(fajnev)
                table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | [[" .. tiszta .. "|''" .. tiszta .. "'']]\n| " .. formazSzinonimak(maradek, false))
            end
        end
    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