Module:Variants: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(For equiptment with grades, show "Grade N" as the variant name)
(Fix link output)
Line 20: Line 20:
'?Profession Level B High',
'?Profession Level B High',
'?Variant name',
'?Variant name',
'?Version anchor',
'?#-',
get_images and '?Image#64px;x64px = Image' or nil,
get_images and '?Image#64px;x64px = Image' or nil,
limit = args.limit or 500,
limit = args.limit or 500,
Line 40: Line 42:
if variant_name then
if variant_name then
local page = entry[1]
local page = entry[1]
local pipe = page:find('|')
if pipe then
page = page:sub(3, pipe-1)
else
page = page:sub(3, -3)
end

if page:sub(1, 1 + #variant_name + #' (grade ') == ':' .. variant_name .. ' (grade ' and page:sub(-1) == ')' then
if page:sub(1, 1 + #variant_name + #' (grade ') == ':' .. variant_name .. ' (grade ' and page:sub(-1) == ')' then
local grade_number = page:sub(2 + #variant_name + #' (grade ', -2)
local grade_number = page:sub(2 + #variant_name + #' (grade ', -2)
Line 52: Line 47:
variant_name = 'Grade ' .. grade_number
variant_name = 'Grade ' .. grade_number
end
end
local anchor = entry['Version anchor'] and ' § ' .. entry['Version anchor'] or ''


table.insert(formatted, ('[[%s|%s]]'):format(page, variant_name))
table.insert(formatted, ('[[%s|%s%s]]'):format(page, variant_name, anchor))
else
else
table.insert(formatted, entry[1])
table.insert(formatted, ('[[%s]]'):format(entry[1]))
end
end
end
end
contents = table.concat(formatted, ' • ')
contents = table.concat(formatted, ' • ')
else
else
contents = '[[Category:Empty variant list]]'
contents = '[[Category:Empty variant list]]'
Line 126: Line 122:
:tag('td')
:tag('td')
:css{ ['border-left'] = 'none' }
:css{ ['border-left'] = 'none' }
:wikitext(entry[1])
:wikitext(('[[%s]]'):format(entry[1]))
:done()
:done()
:tag('td')
:tag('td')