Module:FormatExternalLinks

From The TF2 Sourcemod Wiki
Jump to navigation Jump to search

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

local FormatExternalLinks = {}

function FormatExternalLinks.Format(frame)
    local Input = frame.args[1] or ""
    local Parts = {}
    for Word in string.gmatch(Input, '([^,]+)') do
        table.insert(Parts, Word)
    end
    
    local Result = {}
    for i, Part in ipairs(Parts) do
        local DisplayLink, DisplayTitle = string.match(Part, "([^%s]+)%s+(.*)")
        
        if DisplayLink and DisplayTitle then
            table.insert(Result, string.format("[[%s %s]]", DisplayLink, DisplayTitle))
        end
    end
    
    return table.concat(Result, "<br>")
end

return FormatExternalLinks