Module:Remove parentheses: Difference between revisions
From Amaranth Legacy, available at amaranth-legacy.community
More actions
Content deleted Content added
Tesinormed (talk | contribs) No edit summary |
Tesinormed (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local libraryUtil = require('libraryUtil') |
|||
local checkType = libraryUtil.checkType |
|||
local p = {} |
local p = {} |
||
function p. |
function p.getDisplayTitle(scope, title) |
||
-- input validation |
|||
| ⚫ | |||
checkType('Module:Remove parentheses.getDisplayTitle', 1, scope, 'string') |
|||
| ⚫ | |||
checkType('Module:Remove parentheses.getDisplayTitle', 2, title, 'string') |
|||
local scope = args['scope']:gsub(' ', '_') |
|||
| ⚫ | |||
if displaytitle:find('(' .. scope .. ')') then |
if displaytitle:find('(' .. scope .. ')') then |
||
return title:gsub('%(' .. scope .. '%)', '') |
|||
elseif displaytitle:find('(' .. scope .. ',') then |
elseif displaytitle:find('(' .. scope .. ',') then |
||
return title:gsub('%(' .. scope, '(') |
|||
else |
|||
return title |
|||
end |
end |
||
end |
|||
function p.main(frame) |
|||
| ⚫ | |||
-- input validation |
|||
| ⚫ | |||
return frame:callParserFunction( |
return frame:callParserFunction( |
||
'DISPLAYTITLE', |
|||
| ⚫ | |||
) |
|||
end |
end |
||
Revision as of 17:48, January 28, 2025
Removes parentheses in a page title; used by Template:Remove parentheses
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}
function p.getDisplayTitle(scope, title)
-- input validation
checkType('Module:Remove parentheses.getDisplayTitle', 1, scope, 'string')
checkType('Module:Remove parentheses.getDisplayTitle', 2, title, 'string')
if displaytitle:find('(' .. scope .. ')') then
return title:gsub('%(' .. scope .. '%)', '')
elseif displaytitle:find('(' .. scope .. ',') then
return title:gsub('%(' .. scope, '(')
else
return title
end
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
-- input validation
if not args['scope'] then error('"scope" argument is required') end
return frame:callParserFunction(
'DISPLAYTITLE',
getDisplayTitle(scope:gsub(' ', '_'), mw.title.getCurrentTitle().fullText)
)
end
return p