Module:Sandbox/User:Microbrews/Variants: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
Microbrews (talk | contribs) No edit summary |
Microbrews (talk | contribs) No edit summary |
||
Line 33: | Line 33: | ||
function p.variants_header(args) |
function p.variants_header(args) |
||
local smw_data = get_table_info(args) |
local smw_data = get_table_info(args) |
||
local main_variant = args[1]:gsub('%(', '%%%('):gsub('%)', '%%%)') |
local main_variant = args[1]:gsub('%(', '%%%('):gsub('%)', '%%%)') -- it's going to be a pattern, so escape the parentheses |
||
local contents |
local contents |
||
if smw_data then |
if smw_data then |
||
Line 40: | Line 40: | ||
local name = entry['page'] |
local name = entry['page'] |
||
local variant_name = name:gsub(main_variant, '', 1) |
local variant_name = name:gsub(main_variant, '', 1) |
||
variant_name = variant_name:gsub('^%s*(.-)%s*$', '%1') |
|||
table.insert(formatted, '[[' .. name .. '|' .. variant_name .. ']]') |
table.insert(formatted, '[[' .. name .. '|' .. variant_name .. ']]') |
||
end |
end |