Module:Ruler

From The Kingkiller Chronicle Wiki
Jump to navigation Jump to search

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

-- <nowiki>
local p = {}

local function unlink( v )
    return mw.text.trim( v:match( '%[%[:?(.-)[|%]]' ) or v )
end

function p.ruler(frame)
    local lines = mw.text.split(frame.args[1], '*')
    local result = {}

    for k, v in ipairs(lines) do
        v = mw.text.trim(v)

        if v ~= '' and not v:lower():match( '^n/?a$' ) then
            table.insert( result, '[[Category:Locations ruled by ' .. unlink( v ) .. ']]' )
        end
    end

    return table.concat( result )
end

return p
-- </nowiki>