このモジュールについての説明文ページを モジュール:Noredirect/doc に作成できます

local p = {}

-- Return a blue noredirect wikilink for an existing page, a red wikilink for a non-existing page
function p.noredirect(pagetitle, label)

    -- Evaluate pagetitle
    if pagetitle == nil or pagetitle == '' then
        return error('ページ名が指定されていません')
    end
    pagetitle = pagetitle:gsub('^%[*', ''):gsub('%]*$', '') -- Remove leading/trailing brackets to prevent errors
    pagetitle = pagetitle:gsub('_', ' ') -- Replace underscores with spaces because this variable will be used for the link's label
    pagetitle = pagetitle:gsub('^%s*', ''):gsub('%s*$', '') -- trim
    if pagetitle == '' then
        return error('ページ名が不正です')
    elseif pagetitle:find('[<>[%]{}|]') then
        return error('ページ名に使用できない記号が含まれています( < > [ ] { } | )')
    end

    -- Create link
    local title = mw.title.new(pagetitle)
    if label == nil or label == '' then
        label = pagetitle -- Don't use title.prefixedText here because the namespace alias (if the title contains any) is replaced by its canonical one
    end
    if title.exists then
        local link = '[' .. tostring(mw.uri.fullUrl(title.prefixedText, {redirect = 'no'})) .. ' ' .. label .. ']'
        link = '<span class="plainlinks">' .. link .. '</span>'
        return link
    else
        return '[[:' .. title.prefixedText .. '|' .. label .. ']]'
    end

end

-- Main package function
function p.Main(frame)
    return p.noredirect(frame.args['1'], frame.args['2'])
end

return p