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ó
 
(15 közbenső módosítás ugyanattól a felhasználótól nincs mutatva)
2. sor: 2. sor:


-- Speciális formázó a taxonómiai nevekhez
-- Speciális formázó a taxonómiai nevekhez
-- isGenus: ha igaz, félkövér-dőlt ('''/'''), ha hamis, csak dőlt (/'')
local function taxonFormazo(szoveg, isGenusLevel, isTypeLink)
local function taxonFormazo(szoveg, isGenus)
     if not szoveg or szoveg == "" then return "" end
     if not szoveg or szoveg == "" then return "" end
      
      
     local s = ""
     local tiszta_szoveg = szoveg:gsub("Type:", "Típusfaj:")
     if isGenus then
    -- Idézőjelek és link jelölő takarítása
         s = "'''''" .. szoveg .. "'''''" -- Félkövér-dőlt
    local nyers = tiszta_szoveg:gsub("@", ""):gsub("'", ""):gsub("\"", "")
     else
    nyers = mw.text.trim(nyers)
         s = "''" .. szoveg .. "''" -- Csak dőlt
 
    -- 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
     end
   
 
     -- Botanikai kulcsszavak állóvá tétele
     -- 3. Normál formázás szavanként
     local kulcsszavak = {
     local szavak = mw.text.split(nyers, " ")
         "subgen%.", "subg%.", "sect%.", "subsect%.",  
    local formalt_szavak = {}
        "subsp%.", "var%.", "subvar%.", "f%."
    local allo_kulcsszavak = {
         ["subgen."] = true, ["subg."] = true, ["sect."] = true,  
        ["subsect."] = true, ["subsp."] = true, ["var."] = true,  
        ["f."] = true
     }
     }
   
 
     for _, kulcs in ipairs(kulcsszavak) do
     for _, szo in ipairs(szavak) do
         local tiszta_kulcs = kulcs:gsub("%%", "")
         if allo_kulcsszavak[szo] then
        -- Kiszállunk a dőltetésből a kulcsszóra, majd vissza
            -- A rövidítés ÁLLÓ betűs (nincs körülötte semmilyen jelölő)
        s = s:gsub(kulcs, "''" .. tiszta_kulcs .. "''")
            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
     end
   
 
     -- Takarítás (felesleges formázójelek törlése)
     return table.concat(formalt_szavak, " ")
    s = s:gsub("''''''", ""):gsub("''''", "")
    return s
end
end


-- Szinonimák feldolgozása: 3-as szint = új sor, 4-es szint = hozzáfűzés
-- Szinonimák feldolgozása
local function formazSzinonimak(sor)
local function formazSzinonimak(sor, isParentGenus)
     if not sor or sor == "" then return "" end
     if not sor or sor == "" then return "" end
    local lista = {}


     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 = ""
     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


    for szint, jel, tartalom in sor:gmatch("(%d)%s*([^%d%s#]+)%s*([^#]+)%s*%d#") do
            if szint == "3" then
        -- Jel szimplázása (≡≡ -> ≡, == -> =, −− -> −)
                if aktualis_sor ~= "" then table.insert(lista, "<li>" .. aktualis_sor .. "</li>") end
        local tiszta_jel = mw.ustring.sub(jel, 1, 1)
                aktualis_sor = elem
       
            else
        -- Meghatározzuk, hogy nemzetségről van-e szó (szinonima nemzetségnél nincs fajnév, csak egy szó)
                aktualis_sor = aktualis_sor .. " " .. elem
        local trimmed_tartalom = mw.text.trim(tartalom)
        local is_syn_genus = not trimmed_tartalom:find(" ")
       
        local formalt_nev = taxonFormazo(trimmed_tartalom, is_syn_genus)
        local elem = tiszta_jel .. " " .. formalt_nev
 
        if szint == "3" then
            if aktualis_sor ~= "" then
                table.insert(lista, "<li>" .. aktualis_sor .. "</li>")
             end
             end
            aktualis_sor = elem
        elseif szint == "4" then
            aktualis_sor = aktualis_sor .. " " .. elem
         end
         end
     end
     end


     if aktualis_sor ~= "" then
     if aktualis_sor ~= "" then table.insert(lista, "<li>" .. aktualis_sor .. "</li>") end
        table.insert(lista, "<li>" .. aktualis_sor .. "</li>")
      
     end
 
     if #lista == 0 then return "" end
     if #lista == 0 then return "" end
     return '<ul style="margin-left:1.1em; list-style-type:disc; padding:0; margin:0;">' .. table.concat(lista) .. "</ul>"
     return '<ul style="list-style-type:disc; padding:0; margin:0 0 0 1.5em;">' .. table.concat(lista) .. "</ul>"
end
end


69. sor: 100. sor:
     local args = frame:getParent().args
     local args = frame:getParent().args
     local szuro = args[1] and mw.text.trim(args[1]) or ""
     local szuro = args[1] and mw.text.trim(args[1]) or ""
   
     local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData')
     local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData')
     if not status then return "Hiba: Modul:CactaceaeTaxonokData nem található." end
     if not status then return "Hiba: Adatmodul hiányzik." end
     local nyers = dataModul.getAdatok()
     local nyers = dataModul.getAdatok()


     local rows = {}
     local rows, counter, isVisible = {}, 0, false
    local counter = 0
    local isVisible = false
 
     for sor in nyers:gmatch("[^\r\n]+") do
     for sor in nyers:gmatch("[^\r\n]+") do
         local szint = sor:sub(1, 1)
         local szint = sor:sub(1, 1)
        -- 1-es szint: Nemzetség
         if szint == "1" then
         if szint == "1" then
             local nemz, extra = sor:match("^1%s+([^%s:]+)%s*(.*)")
             local nemz = sor:match("^1%s+([^%s:]+)")
             if nemz then
             isVisible = (szuro == "" or nemz == szuro)
                if szuro == "" or nemz == szuro then
            if nemz and isVisible then
                    isVisible = true
                counter = counter + 1
                    counter = counter + 1
                local nemz_link = "[[:Kategória:" .. nemz .. "|'''''" .. nemz .. "''''']]"
                   
                local maradek = sor:match("^1%s+[^%s:]+%s*(.*)$") or ""
                    -- Nemzetségnév linkkel, félkövér-dőlten
                table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | " .. nemz_link .. "\n| " .. formazSzinonimak(maradek, true))
                    local nemz_link = "[[Kategória:" .. nemz .. "|'''''" .. nemz .. "''''']]"
                   
                    -- A típusfaj/szinonima részt a :: után keressük az 1# jelzésig
                    local maradek = extra:match("::%s*(.*)") or ""
                    table.insert(rows, "|-\n| " .. counter .. "\n| " .. nemz_link .. "\n| " .. formazSzinonimak(maradek))
                else
                    isVisible = false
                end
             end
             end
        -- 2-es szint: Faj
         elseif szint == "2" and isVisible then
         elseif szint == "2" and isVisible then
             local fajnev, maradek = sor:match("^2%s+([^2#]+)2#%s*(.*)")
             local fajnev, maradek = sor:match("^2%s+([^2#]+)2#%s*(.*)")
             if fajnev then
             if fajnev then
                 counter = counter + 1
                 counter = counter + 1
                -- Fajnév linkkel, csak dőlten
                 local tiszta = mw.text.trim(fajnev)
                 local tiszta_fajnev = mw.text.trim(fajnev)
                 table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | [[" .. tiszta .. "|''" .. tiszta .. "'']]\n| " .. formazSzinonimak(maradek, false))
                local faj_link = "[[" .. tiszta_fajnev .. "|''" .. tiszta_fajnev .. "'']]"
                 table.insert(rows, "|-\n| " .. counter .. "\n| " .. faj_link .. "\n| " .. formazSzinonimak(maradek))
             end
             end
         end
         end
     end
     end
 
      
     if #rows == 0 then return "Nincs találat." 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'
     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|}")
     return frame:preprocess(head .. table.concat(rows, "\n") .. "\n|}")

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