Module:Featured: Difference between revisions
Weekly featured soldier rotation module |
Skip non-letter pool lines |
||
| (One intermediate revision by the same user not shown) | |||
| Line 72: | Line 72: | ||
if title == '' then | if title == '' then | ||
return nil | |||
end | |||
-- Skip leftovers from comments / markup | |||
if mw.ustring.find(title, '^[%s%p]*$') or mw.ustring.find(title, '^%<') then | |||
return nil | |||
end | |||
if not mw.ustring.find(title, '%a') then | |||
return nil | return nil | ||
end | end | ||
| Line 92: | Line 99: | ||
local content = titleObj:getContent() | local content = titleObj:getContent() | ||
if not content or content == '' then | if not content or content == '' then | ||
return {} | |||
end | |||
-- Only read bullets under == Pool == (ignore examples elsewhere on the page) | |||
local section = mw.ustring.match(content, '\n==%s*Pool%s*==\n(.-)\n==%s*') | |||
if not section then | |||
section = mw.ustring.match(content, '^==%s*Pool%s*==\n(.-)\n==%s*') | |||
end | |||
if not section then | |||
section = mw.ustring.match(content, '\n==%s*Pool%s*==\n(.*)$') | |||
or mw.ustring.match(content, '^==%s*Pool%s*==\n(.*)$') | |||
end | |||
if not section then | |||
return {} | return {} | ||
end | end | ||
local entries = {} | local entries = {} | ||
for line in mw.text.gsplit( | for line in mw.text.gsplit(section, '\n', true) do | ||
local entry = parseLine(line) | local entry = parseLine(line) | ||
if entry then | if entry then | ||