FANDOM


local m = {}
 
function m.wikilink(title, text)
    if title:inNamespace('Category') or title:inNamespace('File') then
        -- Link to the category or file page instead of categorizing or including the file.
        -- To categorize, use utils.categorize.
        return "[[:" .. title.fullText .. "|" .. text .. "]]"
    else
        return "[[" .. title.fullText .. "|" .. text .. "]]"
    end
end
 
function m.external_link(uri, text)
    return "[" .. tostring(uri) .. " " .. text .. "]"
end
 
-- This function wraps the link in a span with class plainlinks.
-- See https://www.mediawiki.org/wiki/Manual:Plainlinks for more information.
function m.plain_external_link(...)
    return tostring(mw.html.create('span')
            :addClass('plainlinks')
            :wikitext(m.external_link(...))
        )
end
 
return m
Community content is available under CC-BY-SA unless otherwise noted.