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ó
(37 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 = [[
-- Szupergyors tisztító: csak sima string műveleteket használ
ß Acanthocalycium :: Type: Acanthocalycium spiniflorum ¤¤¤¤
local function gyorsTisztitas(szoveg)
Ł Acanthocalycium glaucum ¤¤¤ ÷  ≡≡ Lobivia thionantha var. glauca đ >≡ Echinopsis thionantha subsp. glauca ¤ >≡ Acanthocalycium thionanthum subsp. glaucum ¤¤ ÷  == Echinopsis glaucina đ
    if not szoveg or szoveg == "" then return "" end
Ł 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 đ
    -- Eltávolítjuk a speciális bájtokat, amik a đ, ÷, ¤ jeleket alkotják
Ł 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 đ
    -- đ = \196\145, ÷ = \195\183, ¤ = \194\164
Ł Acanthocalycium rhodotrichum subsp. chacoanum ¤¤¤ ÷  ≡≡ Echinopsis chacoana đ >≡ Echinopsis rhodotricha var. chacoana ¤ >≡ Echinopsis rhodotricha subsp. chacoana ¤¤ ÷  == Echinopsis klingleriana đ
    local tiszta = szoveg:gsub("\196\145", ""):gsub("\195\183", ""):gsub("\194\164", "")
Ł Acanthocalycium rhodotrichum subsp. rhodotrichum ¤¤¤ ÷  == Echinopsis minuana đ ÷  == Echinopsis meyeri đ
    tiszta = tiszta:gsub(">%-", ""):gsub(">≡", ""):gsub(">=", "=")
Ł 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 ¤¤
    return tiszta
Ł 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 đ
end
Ł 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 ¤¤¤
]]


function p.tablazat(frame)
function p.tablazat(frame)
     local result = '{| class="wikitable sortable datatable" style="width:100%;"\n'
     local args = frame:getParent().args
     result = result .. "! Taxonnév !! Szinonima\n"
    local szuro = args[1] and mw.text.trim(args[1]) or ""
   
    if szuro == "" then
        return "<div style='color:red;'>Hiba: Adj meg egy nemzetséget!</div>"
     end


     for sor in nyers_adat:gmatch("[^\r\n]+") do
     local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData')
        local taxon = ""
    if not status then return "Hiba: Adatmodul hiányzik." end
        local szinonimak = ""
    local nyers = dataModul.getAdatok()


        if sor:match("^ß") then
    local rows = {}
            -- ß törlése, :: törlése, ¤¤¤¤ törlése
    local counter = 0
            taxon = sor:gsub("^ß%s*", ""):gsub("%s*::%s*", " "):gsub("¤+", "")
    local isVisible = false
             szinonimak = ""
   
         elseif sor:match("^Ł") then
    -- Soronkénti feldolgozás bájtszinten (ez a leggyorsabb)
             -- Ł és ¤¤¤ közötti rész a taxon, a többi a szinonima
    for sor in nyers:gmatch("[^\r\n]+") do
            local tiszta = sor:gsub("^Ł%s*", "")
        local b1 = sor:byte(1)
            taxon, szinonimak = tiszta:match("([^¤]+)¤¤¤(.*)")
       
        -- ß karakter (195 159)
        if b1 == 195 and sor:byte(2) == 159 then
            if sor:find(szuro, 1, true) then
                local nemz = sor:match("ß%s*([^:]+)")
                if nemz and mw.text.trim(nemz):gsub("\194\164", "") == szuro then
                    isVisible = true
                    counter = counter + 1
                    local tip = sor:match("::%s*(.+)") or ""
                    table.insert(rows, {counter, "'''[[:Kategória:"..szuro.."|"..szuro.."]]'''", tip})
                else isVisible = false end
             else isVisible = false end
           
        -- Ł karakter (197 129)
         elseif isVisible and b1 == 197 and sor:byte(2) == 129 then
             local t, sz = sor:match("Ł%s*([^¤]+)¤¤¤(.*)")
            if t then
                counter = counter + 1
                table.insert(rows, {counter, "''[["..mw.text.trim(t).."]]''", sz})
            end
         end
         end
        if counter >= 1000 then break end
    end


        if taxon and taxon ~= "" then
    if #rows == 0 then return "Nincs találat: " .. szuro end
            taxon = mw.text.trim(taxon)
            szinonimak = szinonimak or ""


            -- SZINONIMA TISZTÍTÁS (a kért karakterek törlése)
    -- TÁBLÁZAT ÖSSZEÁLLÍTÁSA (Csak itt formázunk, hogy spóroljunk a CPU-val)
            -- Töröljük: ¤, đ, >, ÷, Ł
    local finalRows = {}
            szinonimak = szinonimak:gsub("[¤đ>÷Ł]", "")
    for i, data in ipairs(rows) do
              
        local szinonimak = ""
            -- Szinonimák tagolása (mivel a ÷-t töröltük, a helyén sortörés lehet, ha szükséges)
        if data[3] ~= "" then
             -- Ha mégis szeretnél sortörést a nevek közé, akkor a ÷ törlése előtt érdemes <br>-re cserélni.
             local t = gyorsTisztitas(data[3])
           
             local lista = {}
             -- Felesleges szóközök takarítása
             -- Egyszerű darabolás
             szinonimak = szinonimak:gsub("%s%s+", " ")
             for r in t:gmatch("[^|≡=−]+") do
            taxon = taxon:gsub("%s%s+", " ")
                local tr = mw.text.trim(r)
 
                if tr ~= "" and tr ~= "''" then
            result = result .. "|-\n| " .. taxon .. " || " .. mw.text.trim(szinonimak) .. "\n"
                    table.insert(lista, "<li>''" .. tr .. "''</li>")
                end
            end
            if #lista > 0 then
                szinonimak = '<ul style="margin-left:1.1em; list-style-type:disc; padding:0; margin:0;">' .. table.concat(lista) .. "</ul>"
            end
         end
         end
        table.insert(finalRows, "|-\n| " .. data[1] .. "\n| " .. data[2] .. "\n| " .. szinonimak)
     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, szinonima\n'
    return result
    return frame:preprocess(head .. table.concat(finalRows, "\n") .. "\n|}")
end
end


return p
return p

A lap 2026. január 7., 10:36-kori változata

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

local p = {}

-- Szupergyors tisztító: csak sima string műveleteket használ
local function gyorsTisztitas(szoveg)
    if not szoveg or szoveg == "" then return "" end
    -- Eltávolítjuk a speciális bájtokat, amik a đ, ÷, ¤ jeleket alkotják
    -- đ = \196\145, ÷ = \195\183, ¤ = \194\164
    local tiszta = szoveg:gsub("\196\145", ""):gsub("\195\183", ""):gsub("\194\164", "")
    tiszta = tiszta:gsub(">%-", "−"):gsub(">≡", "≡"):gsub(">=", "=")
    return tiszta
end

function p.tablazat(frame)
    local args = frame:getParent().args
    local szuro = args[1] and mw.text.trim(args[1]) or ""
    
    if szuro == "" then
        return "<div style='color:red;'>Hiba: Adj meg egy nemzetséget!</div>"
    end

    local status, dataModul = pcall(require, 'Modul:CactaceaeTaxonokData')
    if not status then return "Hiba: Adatmodul hiányzik." end
    local nyers = dataModul.getAdatok()

    local rows = {}
    local counter = 0
    local isVisible = false
    
    -- Soronkénti feldolgozás bájtszinten (ez a leggyorsabb)
    for sor in nyers:gmatch("[^\r\n]+") do
        local b1 = sor:byte(1)
        
        -- ß karakter (195 159)
        if b1 == 195 and sor:byte(2) == 159 then
            if sor:find(szuro, 1, true) then
                local nemz = sor:match("ß%s*([^:]+)")
                if nemz and mw.text.trim(nemz):gsub("\194\164", "") == szuro then
                    isVisible = true
                    counter = counter + 1
                    local tip = sor:match("::%s*(.+)") or ""
                    table.insert(rows, {counter, "'''[[:Kategória:"..szuro.."|"..szuro.."]]'''", tip})
                else isVisible = false end
            else isVisible = false end
            
        -- Ł karakter (197 129)
        elseif isVisible and b1 == 197 and sor:byte(2) == 129 then
            local t, sz = sor:match("Ł%s*([^¤]+)¤¤¤(.*)")
            if t then
                counter = counter + 1
                table.insert(rows, {counter, "''[["..mw.text.trim(t).."]]''", sz})
            end
        end
        if counter >= 1000 then break end
    end

    if #rows == 0 then return "Nincs találat: " .. szuro end

    -- TÁBLÁZAT ÖSSZEÁLLÍTÁSA (Csak itt formázunk, hogy spóroljunk a CPU-val)
    local finalRows = {}
    for i, data in ipairs(rows) do
        local szinonimak = ""
        if data[3] ~= "" then
            local t = gyorsTisztitas(data[3])
            local lista = {}
            -- Egyszerű darabolás
            for r in t:gmatch("[^|≡=−]+") do
                local tr = mw.text.trim(r)
                if tr ~= "" and tr ~= "''" then
                    table.insert(lista, "<li>''" .. tr .. "''</li>")
                end
            end
            if #lista > 0 then
                szinonimak = '<ul style="margin-left:1.1em; list-style-type:disc; padding:0; margin:0;">' .. table.concat(lista) .. "</ul>"
            end
        end
        table.insert(finalRows, "|-\n| " .. data[1] .. "\n| " .. data[2] .. "\n| " .. szinonimak)
    end

    local head = '{| class="wikitable sortable datatable-hook stripe hover compact" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, szinonima\n'
    return frame:preprocess(head .. table.concat(finalRows, "\n") .. "\n|}")
end

return p