Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
You must create an account or log in to edit.

Module:Remove parentheses: Difference between revisions

From Amaranth Legacy, available at amaranth-legacy.community
Content deleted Content added
No edit summary
No edit summary
Line 4: Line 4:
local args = require('Module:Arguments').getArgs(frame)
local args = require('Module:Arguments').getArgs(frame)
if not args['scope'] then error('"scope" argument is required') end
if not args['scope'] then error('"scope" argument is required') end
local scope = args['scope']
local scope = args['scope']:gsub(' ', '_')
local displaytitle = mw.title.getCurrentTitle().fullText
local displaytitle = mw.title.getCurrentTitle().fullText



Revision as of 17:45, January 28, 2025

Removes parentheses in a page title; used by Template:Remove parentheses


local p = {}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame)
	if not args['scope'] then error('"scope" argument is required') end
	local scope = args['scope']:gsub(' ', '_')
	local displaytitle = mw.title.getCurrentTitle().fullText

	if displaytitle:find('(' .. scope .. ')') then
		displaytitle = displaytitle:gsub('%(' .. scope .. '%)', '')
	elseif displaytitle:find('(' .. scope .. ',') then
		displaytitle = displaytitle:gsub('%(' .. scope, '(')
	end

	return frame:callParserFunction('DISPLAYTITLE', displaytitle)
end

return p