Module:Sandbox/User:Microbrews/Variants: Difference between revisions
no edit summary
Microbrews (talk | contribs) No edit summary |
Microbrews (talk | contribs) No edit summary |
||
(20 intermediate revisions by the same user not shown) | |||
Line 13:
local query = {
'[[Variant of::'..variant_name..']]',
'?
'?Profession A #', -- Adding a # to this query makes it return plaintext instead of a link
'?Profession B #',
Line 33:
function p.variants_header(args)
local smw_data = get_table_info(args)
local main_variant = args[1]:gsub('%(', '%%%('):gsub('%)', '%%%)') -- it's going to be a pattern, so escape the parentheses
local contents
if smw_data then
local formatted = {}
for _, entry in ipairs(smw_data) do
local name = entry['
local variant_name = name:gsub(
variant_name = variant_name:gsub('^%s*(.-)%s*$', '%1') -- trim whitespace
variant_name = variant_name:gsub('%((.-)%)$', '%1') -- trim parentheses
variant_name = variant_name:gsub("^%l", string.upper) -- capitalize first letter
table.insert(formatted, '[[' .. name .. '|' .. variant_name .. ']]')
end
Line 110 ⟶ 113:
:tag('td')
:css{ ['border-left'] = 'none' }
:wikitext('[['..entry[
:done()
:tag('td')
|