1,124
edits
| (11 intermediate revisions by the same user not shown) | |||
| Line 26: | Line 26: | ||
function com.modulePagename(title) | function com.modulePagename(title) | ||
if not title then | if not title then | ||
title = mw.title.getCurrentTitle() | title = mw.title.getCurrentTitle().text | ||
end | end | ||
mw.log(title) | |||
local disambig = string.find(title, '%(') | local disambig = string.find(title, '%(') | ||
if | if disambig then | ||
title = title:gsub('(.*)%s%(.-%)', '%1') | |||
end | end | ||
return title | return title | ||
end | end | ||
| Line 47: | Line 41: | ||
function com.pagename(frame) | function com.pagename(frame) | ||
local args = a.getArgs(frame) | local args = a.getArgs(frame) | ||
return com.modulePagename(args['title']) | return com.trim(com.modulePagename(args['title'])) | ||
end | |||
function com.fUpper(text) | |||
local words = mw.text.split(text, '%s') | |||
for k, v in ipairs(words) do | |||
words[k] = v:sub(1,1):upper() .. (v:sub(2) or '') | |||
end | |||
return table.concat(words, ' ') | |||
end | |||
function com.firstUpper(frame) | |||
local args = a.getArgs(frame) | |||
return string.gsub(args[1], string.sub(args[1],1,1), string.upper( | |||
string.sub(args[1],1,1))) | |||
end | end | ||
return com | return com | ||