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ó
 
(26 közbenső módosítás ugyanattól a felhasználótól nincs mutatva)
1. sor: 1. sor:
local p = {}
local p = {}


-- Unicode-biztos formázó
-- Speciális formázó a taxonómiai nevekhez
local function formazSzinonimak(szoveg)
local function taxonFormazo(szoveg, isGenusLevel, isTypeLink)
     if not szoveg or szoveg == "" then return "" end
     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


     -- Felesleges karakterek takarítása Unicode-biztosan
     -- 2. Link jelölt szinonima (@)
     local tiszta = mw.ustring.gsub(szoveg, "[đ÷]", "")
     if tiszta_szoveg:find("@") then
    tiszta = mw.ustring.gsub(tiszta, "¤+", "")
        return "[[" .. nyers .. "|''" .. nyers .. "'']]"
      
     end
     tiszta = mw.ustring.gsub(tiszta, ">−", "−")
 
     tiszta = mw.ustring.gsub(tiszta, ">≡", "≡")
     -- 3. Normál formázás szavanként
     tiszta = mw.ustring.gsub(tiszta, ">=", "=")
    local szavak = mw.text.split(nyers, " ")
    tiszta = mw.ustring.gsub(tiszta, "≡≡", "|≡")
     local formalt_szavak = {}
    tiszta = mw.ustring.gsub(tiszta, "==", "|=")
     local allo_kulcsszavak = {
    tiszta = mw.ustring.gsub(tiszta, "−−", "|−")
        ["subgen."] = true, ["subg."] = true, ["sect."] = true,  
     tiszta = mw.ustring.gsub(tiszta, "%%-%%-", "|−")
        ["subsect."] = true, ["subsp."] = true, ["var."] = true,  
        ["f."] = true
     }


     local lista_elemek = {}
     for _, szo in ipairs(szavak) do
    local reszek = mw.text.split(tiszta, "|", true)
         if allo_kulcsszavak[szo] then
   
             -- A rövidítés ÁLLÓ betűs (nincs körülötte semmilyen jelölő)
    for i=1, #reszek do
             table.insert(formalt_szavak, szo)
         local tiszta_resz = mw.text.trim(reszek[i])
        else
        if tiszta_resz ~= "" then
             -- A latin név részei
             -- Formázás: az egész dőlt, a jelek visszaállítva
             if isGenusLevel then
            local formazott = "''" .. tiszta_resz .. "''"
                -- 1-es szintű sorban: VASTAG-DŐLT
            formazott = mw.ustring.gsub(formazott, "≡", "''≡''")
                table.insert(formalt_szavak, "'''''" .. szo .. "'''''")
             formazott = mw.ustring.gsub(formazott, "=", "''=''")
             else
             formazott = mw.ustring.gsub(formazott, "−", "''−''")
                -- 2-es szintű (faj) sorban: SIMA DŐLT
             formazott = mw.ustring.gsub(formazott, "Type:", "''Type:''")
                table.insert(formalt_szavak, "''" .. szo .. "''")
            formazott = mw.ustring.gsub(formazott, "var%.", "''var.''")
            end
            formazott = mw.ustring.gsub(formazott, "subsp%.", "''subsp.''")
             formazott = mw.ustring.gsub(formazott, "f%.", "''f.''")
            formazott = mw.ustring.gsub(formazott, "''''", "")
            table.insert(lista_elemek, "<li>" .. formazott .. "</li>")
         end
         end
     end
     end
   
 
    if #lista_elemek == 0 then return "" end
     return table.concat(formalt_szavak, " ")
     return '<ul style="margin-left: 1.1em; list-style-type: disc; padding: 0; margin: 0;">' .. table.concat(lista_elemek) .. "</ul>"
end
end


function p.tablazat(frame)
-- Szinonimák feldolgozása
     local args = frame.args[1] and frame.args or frame:getParent().args
local function formazSzinonimak(sor, isParentGenus)
     local szuroNemzettseg = args[1] and mw.text.trim(args[1]) or nil
    if not sor or sor == "" then return "" end
    if szuroNemzettseg == "" then szuroNemzettseg = nil 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


    local status, adatModul = pcall(require, 'Modul:CactaceaeTaxonokData')
            if szint == "3" then
    if not status then return "Hiba: Adatmodul nem található!" end
                if aktualis_sor ~= "" then table.insert(lista, "<li>" .. aktualis_sor .. "</li>") end
     local nyers_adat = adatModul.getAdatok()
                aktualis_sor = elem
            else
                aktualis_sor = aktualis_sor .. " " .. elem
            end
        end
     end


     local rows = {}
     if aktualis_sor ~= "" then table.insert(lista, "<li>" .. aktualis_sor .. "</li>") end
     local sorszam = 0
      
     local jelenlegiNemzettseg = ""
    if #lista == 0 then return "" end
    local megjelenit = true
     return '<ul style="list-style-type:disc; padding:0; margin:0 0 0 1.5em;">' .. table.concat(lista) .. "</ul>"
end


     -- mw.ustring.gmatch használata a UTF-8 karakterek (ß, Ł) miatt
function p.tablazat(frame)
     for sor in mw.ustring.gmatch(nyers_adat, "[^\r\n]+") do
     local args = frame:getParent().args
        local taxon_link = ""
     local szuro = args[1] and mw.text.trim(args[1]) or ""
        local szinonimak_nyers = ""
    local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData')
    if not status then return "Hiba: Adatmodul hiányzik." end
    local nyers = dataModul.getAdatok()


         if mw.ustring.sub(sor, 1, 1) == "ß" then
    local rows, counter, isVisible = {}, 0, false
             local nemz, tip = mw.ustring.match(sor, "^ß%s*([^:]+)::%s*(.+)")
    for sor in nyers:gmatch("[^\r\n]+") do
             if nemz then
         local szint = sor:sub(1, 1)
                 jelenlegiNemzettseg = mw.text.trim(nemz):gsub("¤+", "")
        if szint == "1" then
                 if not szuroNemzettseg or szuroNemzettseg == jelenlegiNemzettseg then
             local nemz = sor:match("^1%s+([^%s:]+)")
                    taxon_link = "'''[[:Kategória:" .. jelenlegiNemzettseg .. "|" .. jelenlegiNemzettseg .. "]]'''"
            isVisible = (szuro == "" or nemz == szuro)
                    szinonimak_nyers = tip
             if nemz and isVisible then
                    megjelenit = true
                 counter = counter + 1
                else
                 local nemz_link = "[[:Kategória:" .. nemz .. "|'''''" .. nemz .. "''''']]"
                    megjelenit = false
                local maradek = sor:match("^1%s+[^%s:]+%s*(.*)$") or ""
                end
                table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | " .. nemz_link .. "\n| " .. formazSzinonimak(maradek, true))
             end
             end
         elseif mw.ustring.sub(sor, 1, 1) == "Ł" and megjelenit then
         elseif szint == "2" and isVisible then
             local tiszta_sor = mw.ustring.gsub(sor, "^Ł%s*", "")
             local fajnev, maradek = sor:match("^2%s+([^2#]+)2#%s*(.*)")
            local t, sz = mw.ustring.match(tiszta_sor, "([^¤]+)¤¤¤(.*)")
             if fajnev then
             if t then
                counter = counter + 1
                 local tiszta_nev = mw.text.trim(t)
                 local tiszta = mw.text.trim(fajnev)
                 taxon_link = "''[[" .. tiszta_nev .. "]]''"
                 table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | [[" .. tiszta .. "|''" .. tiszta .. "'']]\n| " .. formazSzinonimak(maradek, false))
                szinonimak_nyers = sz
             end
             end
        end
        -- Csak akkor adjuk hozzá, ha a szűrő engedi
        if taxon_link ~= "" then
            sorszam = sorszam + 1
            table.insert(rows, "|-\n| " .. sorszam .. "\n| " .. taxon_link .. "\n| " .. formazSzinonimak(szinonimak_nyers))
         end
         end
     end
     end
 
   
     local header = '{| 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'
     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(header .. table.concat(rows, "\n") .. "\n|}")
     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