Jump to content

Module:CategoryLinks: Difference between revisions

From Drifters Almanac
m Protected "Module:CategoryLinks" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
No edit summary
 
Line 10: Line 10:
         local trimmed = mw.text.trim(entry)
         local trimmed = mw.text.trim(entry)
         if trimmed ~= "" then
         if trimmed ~= "" then
             table.insert(result, string.format("[[:Category:%s|%s]]", trimmed, trimmed))
             table.insert(result, string.format("'''[[%s]]'''", trimmed, trimmed))
         end
         end
     end
     end

Latest revision as of 19:59, 24 June 2025

Documentation for this module may be created at Module:CategoryLinks/doc

local p = {}

function p.fromDelimited(frame)
    local input = frame.args[1] or ""
    local delimiter = frame.args.delimiter or ","
    local entries = mw.text.split(input, delimiter)
    local result = {}

    for _, entry in ipairs(entries) do
        local trimmed = mw.text.trim(entry)
        if trimmed ~= "" then
            table.insert(result, string.format("'''[[%s]]'''", trimmed, trimmed))
        end
    end

    return table.concat(result, " • ")
end

return p