Editing Module:Sandbox/User:Microbrews/Variants

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
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('%)', '%%%)') -- it's going to be a pattern, so escape the parentheses
local main_variant = args[1]:gsub('(%()(%))', '%1%(%2%)')
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') -- 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 .. ']]')
table.insert(formatted, '[[' .. name .. '|' .. variant_name .. ']]')
end
end
Line 113: Line 110:
:tag('td')
:tag('td')
:css{ ['border-left'] = 'none' }
:css{ ['border-left'] = 'none' }
:wikitext('[['..entry['page']..']]')
:wikitext(entry[1])
:done()
:done()
:tag('td')
:tag('td')
Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see Brighter Shores:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template