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ó
6. sor: 6. sor:
      
      
     local tiszta_szoveg = szoveg:gsub("Type:", "Típusfaj:")
     local tiszta_szoveg = szoveg:gsub("Type:", "Típusfaj:")
   
    -- Link jelző (@) kezelése
     local hasLinkMarker = tiszta_szoveg:find("@")
     local hasLinkMarker = tiszta_szoveg:find("@")
     if hasLinkMarker then
     if hasLinkMarker then tiszta_szoveg = tiszta_szoveg:gsub("@", "") end
        tiszta_szoveg = tiszta_szoveg:gsub("@", "")
    end


     local megjelenitendo = tiszta_szoveg
     local megjelenitendo = tiszta_szoveg
      
      
    -- 1. Típusfaj linkelés
     if isTypeLink then
     if isTypeLink then
         local nev_resz = tiszta_szoveg:match("Típusfaj:%s*(.*)")
         local nev_resz = tiszta_szoveg:match("Típusfaj:%s*(.*)")
24. sor: 19. sor:
             megjelenitendo = "[[" .. tiszta_szoveg .. "|''" .. tiszta_szoveg .. "'']]"
             megjelenitendo = "[[" .. tiszta_szoveg .. "|''" .. tiszta_szoveg .. "'']]"
         end
         end
    -- 2. Jelölt szinonima linkelés (@)
     elseif hasLinkMarker then
     elseif hasLinkMarker then
         local tiszta_nev = mw.text.trim(tiszta_szoveg)
         local tiszta_nev = mw.text.trim(tiszta_szoveg)
31. sor: 25. sor:
      
      
     local s = ""
     local s = ""
    -- Formázás: Nemzetségek (isGenus) félkövér-dőlt, minden más dőlt
     if isGenus and not isTypeLink then
     if isGenus and not isTypeLink then
         s = "'''''" .. megjelenitendo .. "'''''"
         s = "'''''" .. megjelenitendo .. "'''''"
40. sor: 33. sor:
     end
     end
      
      
    -- Álló betűs kulcsszavak (subsp, var stb.)
     local kulcsszavak = {"subgen%.", "subg%.", "sect%.", "subsect%.", "subsp%.", "var%.", "subvar%.", "f%.", "Típusfaj:"}
     local kulcsszavak = {
        "subgen%.", "subg%.", "sect%.", "subsect%.",  
        "subsp%.", "var%.", "subvar%.", "f%.", "Típusfaj:"
    }
   
     for _, kulcs in ipairs(kulcsszavak) do
     for _, kulcs in ipairs(kulcsszavak) do
         local tiszta_kulcs = kulcs:gsub("%%", "")
         local tiszta_kulcs = kulcs:gsub("%%", "")
51. sor: 39. sor:
     end
     end
      
      
     s = s:gsub("''''''", ""):gsub("''''", "")
     return s:gsub("''''''", ""):gsub("''''", "")
    return s
end
end


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


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


     -- 2. Blokkok
     -- Szinonimák
     local aktualis_sor = ""
     local aktualis_sor = ""
     for szint, jel, tartalom in mw.ustring.gmatch(sor, "(%d)%s*([^%d%s#]+)%s*([^#]+)%s*%d#") do
     for szint, jel, tartalom in mw.ustring.gmatch(sor, "(%d)%s*([^%d%s#]+)%s*([^#]+)%s*%d#") do
76. sor: 59. sor:
             local tiszta_jel = mw.ustring.sub(jel, 1, 1)
             local tiszta_jel = mw.ustring.sub(jel, 1, 1)
             local trimmed_tartalom = mw.text.trim(tartalom)
             local trimmed_tartalom = mw.text.trim(tartalom)
           
             local is_syn_genus = not trimmed_tartalom:find(" ")  
            -- ROBUSZTUS NEMZETSÉG-DETEKTÁLÁS:
            -- Levetjük az idézőjeleket és a @ jelet a teszt idejére
            local teszt_nev = trimmed_tartalom:gsub("['\"'\"„”@]", "")
            teszt_nev = mw.text.trim(teszt_nev)
           
            -- Ha nincs benne szóköz a tisztítás után, akkor nemzetség
             local is_syn_genus = not teszt_nev:find(" ")  
           
             local formalt_nev = taxonFormazo(trimmed_tartalom, is_syn_genus, false)
             local formalt_nev = taxonFormazo(trimmed_tartalom, is_syn_genus, false)
             local elem = tiszta_jel .. " " .. formalt_nev
             local elem = tiszta_jel .. " " .. formalt_nev
97. sor: 72. sor:
     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>")
     return #lista > 0 and '<ul style="list-style-type:disc; padding:0; margin:0 0 0 1.5em;">' .. table.concat(lista) .. "</ul>" or ""
    end
 
     if #lista == 0 then return "" end
    -- Visszaállítottam egy minimális paddingot a listának, hogy szebb legyen
    return '<ul style="list-style-type:disc; padding:0; margin:0 0 0 1.5em;">' .. table.concat(lista) .. "</ul>"
end
end


109. sor: 79. 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 nem található." 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)
         if szint == "1" then
         if szint == "1" then
             local nemz = sor:match("^1%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 nemz_display = "'''''" .. nemz .. "'''''"
                local maradek = sor:match("^1%s+[^%s:]+%s*(.*)$") or ""
                    local nemz_link = "[[:Kategória:" .. nemz .. "|" .. nemz_display .. "]]"
                table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | " .. nemz_link .. "\n| " .. formazSzinonimak(maradek))
                    local maradek = sor:match("^1%s+[^%s:]+%s*(.*)$") or ""
                    table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | " .. nemz_link .. "\n| " .. formazSzinonimak(maradek))
                else
                    isVisible = false
                end
             end
             end
         elseif szint == "2" and isVisible then
         elseif szint == "2" and isVisible then
139. sor: 99. sor:
             if fajnev then
             if fajnev then
                 counter = counter + 1
                 counter = counter + 1
                 local tiszta_fajnev = mw.text.trim(fajnev)
                 local tiszta = mw.text.trim(fajnev)
                 table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | [[" .. tiszta_fajnev .. "|''" .. tiszta_fajnev .. "'']]\n| " .. formazSzinonimak(maradek))
                 table.insert(rows, "|-\n| " .. counter .. "\n| style=\"white-space:nowrap\" | [[" .. tiszta .. "|''" .. tiszta .. "'']]\n| " .. formazSzinonimak(maradek))
             end
             end
         end
         end
     end
     end
 
     return #rows > 0 and frame:preprocess('{| class="wikitable sortable datatable-hook stripe hover compact" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, szinonimák\n' .. table.concat(rows, "\n") .. "\n|}") or "Nincs találat."
     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'
    return frame:preprocess(head .. table.concat(rows, "\n") .. "\n|}")
end
end


return p
return p

A lap 2026. január 10., 07:44-kori változata

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

local p = {}

-- Speciális formázó a taxonómiai nevekhez + Linkelés
local function taxonFormazo(szoveg, isGenus, isTypeLink)
    if not szoveg or szoveg == "" then return "" end
    
    local tiszta_szoveg = szoveg:gsub("Type:", "Típusfaj:")
    local hasLinkMarker = tiszta_szoveg:find("@")
    if hasLinkMarker then tiszta_szoveg = tiszta_szoveg:gsub("@", "") end

    local megjelenitendo = tiszta_szoveg
    
    if isTypeLink then
        local nev_resz = tiszta_szoveg:match("Típusfaj:%s*(.*)")
        if nev_resz then
            local tiszta_nev = mw.text.trim(nev_resz)
            megjelenitendo = "Típusfaj: [[" .. tiszta_nev .. "|''" .. tiszta_nev .. "'']]"
        else
            megjelenitendo = "[[" .. tiszta_szoveg .. "|''" .. tiszta_szoveg .. "'']]"
        end
    elseif hasLinkMarker then
        local tiszta_nev = mw.text.trim(tiszta_szoveg)
        megjelenitendo = "[[" .. tiszta_nev .. "|''" .. tiszta_nev .. "'']]"
    end
    
    local s = ""
    if isGenus and not isTypeLink then
        s = "'''''" .. megjelenitendo .. "'''''"
    elseif not isTypeLink and not hasLinkMarker then
        s = "''" .. megjelenitendo .. "''"
    else
        s = megjelenitendo
    end
    
    local kulcsszavak = {"subgen%.", "subg%.", "sect%.", "subsect%.", "subsp%.", "var%.", "subvar%.", "f%.", "Típusfaj:"}
    for _, kulcs in ipairs(kulcsszavak) do
        local tiszta_kulcs = kulcs:gsub("%%", "")
        s = s:gsub(kulcs, "''" .. tiszta_kulcs .. "''")
    end
    
    return s:gsub("''''''", ""):gsub("''''", "")
end

local function formazSzinonimak(sor)
    if not sor or sor == "" then return "" end
    local lista = {}

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

    -- Szinonimák
    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_tartalom = mw.text.trim(tartalom)
            local is_syn_genus = not trimmed_tartalom:find(" ") 
            local formalt_nev = taxonFormazo(trimmed_tartalom, is_syn_genus, false)
            local elem = tiszta_jel .. " " .. formalt_nev

            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
    return #lista > 0 and '<ul style="list-style-type:disc; padding:0; margin:0 0 0 1.5em;">' .. table.concat(lista) .. "</ul>" or ""
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 nem található." 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))
            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))
            end
        end
    end
    return #rows > 0 and frame:preprocess('{| class="wikitable sortable datatable-hook stripe hover compact" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, szinonimák\n' .. table.concat(rows, "\n") .. "\n|}") or "Nincs találat."
end

return p