De Muysc cubun - Lengua Muisca

m
m
Línea 44: Línea 44:
 
         target = prefix .. target .. suffix
 
         target = prefix .. target .. suffix
 
         local full = (lead ~= '' and ':' or '') .. ns .. target
 
         local full = (lead ~= '' and ':' or '') .. ns .. target
         table.insert(out, string.format('[https://es.wikipedia.org/wiki/%s|%s]', full, label))
+
         table.insert(out, string.format('[https://es.wikipedia.org/wiki/%s %s]', full, label))
 
     end
 
     end
  

Revisión del 15:02 12 sep 2025

La documentación para este módulo puede ser creada en Módulo:LinkList/doc

-- Módulo:LinkList
local p = {}

local function getArg(frame, name, default)
    -- Lee primero del #invoke, luego del padre (si existe)
    local v = (frame.args and frame.args[name]) or ''
    if v == '' and frame.getParent then
        local parent = frame:getParent()
        if parent and parent.args then v = parent.args[name] or '' end
    end
    if v == '' then v = default or '' end
    return v
end

function p.links(frame)
    local valores = getArg(frame, 'valores', '')
    local outsep  = getArg(frame, 'sep', ', ')
    local ns      = getArg(frame, 'ns', '')
    local lead    = getArg(frame, 'leadcolon', '')
    local prefix  = getArg(frame, 'prefix', '')
    local suffix  = getArg(frame, 'suffix', '')
    local doSort  = getArg(frame, 'sort', '') ~= ''

    if valores == '' then
        return '⚠️ LinkList: sin "valores".'
    end

    local items = {}
    for tok in mw.text.gsplit(valores, ',', true) do
        tok = mw.text.trim(tok)
        if tok ~= '' then table.insert(items, tok) end
    end

    if doSort then
        table.sort(items, function(a,b)
            return mw.ustring.lower(a) < mw.ustring.lower(b)
        end)
    end

    local out = {}
    for _, it in ipairs(items) do
        local target, label = it:match('^(.-)|(.+)$')
        if not target then target, label = it, it end
        target = prefix .. target .. suffix
        local full = (lead ~= '' and ':' or '') .. ns .. target
        table.insert(out, string.format('[https://es.wikipedia.org/wiki/%s %s]', full, label))
    end

    if #out == 0 then
        return '⚠️ LinkList: no hay elementos tras procesar.'
    end
    return table.concat(out, outsep)
end

return p