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ó
(24 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 res = '{| class="wikitable sortable datatable-hook stripe hover compact" data-page-length="50" style="width:100%; font-size:90%;"\n'
     local args = frame:getParent().args
    -- Fejléc három oszloppal
    local szuro = args[1] and mw.text.trim(args[1]) or ""
     res = res .. "! # !! Taxonnév !! Típusfaj, szinonima\n"
   
    if szuro == "" then
        return "<div style='color:red;'>Hiba: Adj meg egy nemzetséget!</div>"
     end


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


        if sor:match("^ß") then
    local rows = {}
            -- Szétbontjuk a "ß Nemzetség :: Type: ..." formátumot
    local counter = 0
            local nemzettseg, tipus = sor:match("^ß%s*([^:]+)::%s*(.+)")
    local isVisible = false
            if nemzettseg then
   
                taxon = mw.text.trim(nemzettseg):gsub("¤+", "")
    -- Soronkénti feldolgozás bájtszinten (ez a leggyorsabb)
                szinonimak = mw.text.trim(tipus):gsub("¤+", "")
    for sor in nyers:gmatch("[^\r\n]+") do
                 tipus_sor = true
        local b1 = sor:byte(1)
             end
       
         elseif sor:match("^Ł") then
        -- ß karakter (195 159)
            local tiszta = sor:gsub("^Ł%s*", "")
        if b1 == 195 and sor:byte(2) == 159 then
             local t, sz = tiszta:match("([^¤]+)¤¤¤(.*)")
            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
             if t then
                 taxon = t
                 counter = counter + 1
                 szinonimak = sz:gsub("[¤đ÷]", ""):gsub("≡≡", "≡"):gsub("==", "=")
                 table.insert(rows, {counter, "''[["..mw.text.trim(t).."]]''", sz})
             end
             end
         end
         end
        if counter >= 1000 then break end
    end
    if #rows == 0 then return "Nincs találat: " .. szuro end


         if taxon ~= "" then
    -- TÁBLÁZAT ÖSSZEÁLLÍTÁSA (Csak itt formázunk, hogy spóroljunk a CPU-val)
             sorszam = sorszam + 1
    local finalRows = {}
             res = res .. "|-\n"
    for i, data in ipairs(rows) do
             -- Sorszám oszlop
        local szinonimak = ""
             res = res .. "| " .. sorszam .. "\n"
         if data[3] ~= "" then
            -- Taxonnév oszlop
             local t = gyorsTisztitas(data[3])
            res = res .. "| " .. mw.text.trim(taxon) .. "\n"
             local lista = {}
             -- Típusfaj / Szinonima oszlop
             -- Egyszerű darabolás
             res = res .. "| " .. mw.text.trim(szinonimak or "") .. "\n"
             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
         end
        table.insert(finalRows, "|-\n| " .. data[1] .. "\n| " .. data[2] .. "\n| " .. szinonimak)
     end
     end


     res = res .. "|}"
     local head = '{| class="wikitable sortable datatable-hook stripe hover compact" style="width:100%; font-size:90%;"\n! # !! Taxonnév !! Típusfaj, szinonima\n'
    return res
    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