Difference between revisions of "Module:Common"

Jump to navigation Jump to search
187 bytes removed ,  18:59, 7 February 2024
no edit summary
 
(3 intermediate revisions by the same user not shown)
Line 32: Line 32:
mw.log(title)
mw.log(title)
local disambig = string.find(title, '%(')
local disambig = string.find(title, '%(')
if string.sub(title, string.len(title)) == '%)' then
if disambig then
local check = disambig
title = title:gsub('(.*)%s%(.-%)', '%1')
while check do
local check = string.find(title, '%(', check + 1)
if check ~= 0 then
disambig = check
end
end
end
end
title = string.sub(title, 1, disambig)
return title
return title
end
end
Line 48: Line 41:
function com.pagename(frame)
function com.pagename(frame)
local args = a.getArgs(frame)
local args = a.getArgs(frame)
return trim(com.modulePagename(args['title']))
return com.trim(com.modulePagename(args['title']))
end
end


Line 54: Line 47:
local words = mw.text.split(text, '%s')
local words = mw.text.split(text, '%s')
for k, v in ipairs(words) do
for k, v in ipairs(words) do
words[k] = v:gsub('(.)(.*)', string.upper('%1') .. '%2')
words[k] = v:sub(1,1):upper() .. (v:sub(2) or '')
end
end

Navigation menu