Module:Native name/sandbox: Difference between revisions

Content deleted Content added
Create sandbox version of Module:Native name
 
accept any pattern of tag# and name# parameters
Line 167:
end
 
local active_param = {}
local max_enum = 0; -- accumulate the value to the enumerator with the greatest value
 
for param, _ in pairs (args_t) do
-- loop through all parameters
local ntag_match = tonumber (param:mw.ustring.match ('"^tag(%d+)$'")); -- extract the required enumerator
local name_match = mw.ustring.match("^name(%d+)$")
max_enum = ((n and (n > max_enum)) and n) or max_enum; -- bump <max_enum> if <n> is greater
if tag_match then
active_param[tonumber(tag_match)] = true
elseif name_match then
active_param[tonumber(name_match)] = true
end
end
 
local param_list = {}
for n, _ in pairs(active_param) do
param_list.insert(n)
end
param_list.sort()
 
local list_t = {}; -- list of formatted native names goes here
local n = 1; -- initialize an enumerator
 
whilefor _, n <=in max_enumipairs(param_list) do
table.insert (list_t, table.concat ({
'<li>', -- open the list item
Line 196 ⟶ 207:
'</li>' -- close the list item
}));
n = n + 1; -- bump the enumerator
end