Difference between revisions of "Module:Ruler"
Jump to navigation
Jump to search
(oops) |
(Updated version by Becasita <3) |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
-- <nowiki> | -- <nowiki> | ||
local p = {} | local p = {} | ||
| + | |||
| + | local function unlink( v ) | ||
| + | return mw.text.trim( v:match( '%[%[:?(.-)[|%]]' ) or v ) | ||
| + | end | ||
function p.ruler(frame) | function p.ruler(frame) | ||
local lines = mw.text.split(frame.args[1], '*') | local lines = mw.text.split(frame.args[1], '*') | ||
| − | local result = | + | local result = {} |
| + | |||
for k, v in ipairs(lines) do | for k, v in ipairs(lines) do | ||
v = mw.text.trim(v) | v = mw.text.trim(v) | ||
| − | if v ~= '' then | + | |
| − | result | + | if v ~= '' and not v:lower():match( '^n/?a$' ) then |
| + | table.insert( result, '[[Category:Locations ruled by ' .. unlink( v ) .. ']]' ) | ||
end | end | ||
end | end | ||
| − | return result | + | |
| + | return table.concat( result ) | ||
end | end | ||
return p | return p | ||
| + | -- </nowiki> | ||
Latest revision as of 03:43, 1 January 2019
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>