Soft launch: Soldier biographies and research notes vary in completeness. Prefer class-roster, NARA, newspapers, and other cited sources for contested facts — treat Research notes as leads, not settled history. Anyone can correct a page; contact us with questions.
Module:SplitCats: Difference between revisions
Jump to navigation
Jump to search
Import Lua helper |
Split semicolon team/class values into separate categories |
||
| Line 4: | Line 4: | ||
local raw = frame.args[1] or '' | local raw = frame.args[1] or '' | ||
local prefix = frame.args[2] or 'Class ' | local prefix = frame.args[2] or 'Class ' | ||
raw = mw.ustring.gsub(raw, ';', ';') | |||
local out = {} | local out = {} | ||
for part in mw.text.gsplit(raw, ';', true) do | for part in mw.text.gsplit(raw, ';', true) do | ||
part = mw.text.trim(part) | part = mw.text.trim(part) | ||
if part ~= '' then | if part ~= '' and not mw.ustring.find(part, ';', 1, true) then | ||
table.insert(out, '[[Category:' .. prefix .. part .. ']]') | table.insert(out, '[[Category:' .. prefix .. part .. ']]') | ||
end | end | ||
| Line 24: | Line 25: | ||
return p | return p | ||
Revision as of 02:14, 19 August 2026
Documentation for this module may be created at Module:SplitCats/doc
local p = {}
function p.categories(frame)
local raw = frame.args[1] or ''
local prefix = frame.args[2] or 'Class '
raw = mw.ustring.gsub(raw, ';', ';')
local out = {}
for part in mw.text.gsplit(raw, ';', true) do
part = mw.text.trim(part)
if part ~= '' and not mw.ustring.find(part, ';', 1, true) then
table.insert(out, '[[Category:' .. prefix .. part .. ']]')
end
end
return table.concat(out)
end
function p.letterCategory(frame)
local title = mw.title.getCurrentTitle()
local first = mw.ustring.upper(mw.ustring.sub(title.text, 1, 1))
if mw.ustring.match(first, '[A-Z]') then
return '[[Category:Soldiers ' .. first .. ']]'
end
return '[[Category:Soldiers other]]'
end
return p