Module:String2: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content deleted Content added
updating: sometimes the string is a wiki-link, so find the first letter and capitalise that |
update from sandbox |
||
Line 13: | Line 13: | ||
p.sentence = function (frame ) |
p.sentence = function (frame ) |
||
local s = mw.text.trim( frame.args[1] or "" ) |
local s = mw.text.trim( frame.args[1] or "" ) |
||
if string.find(s, "^%[%[[^|]+|[^%]]+%]%]") then |
|||
-- this is a piped wikilink, so we capitalise the text, not the pipe |
|||
local b, c = string.find(s, "|%A*%a") -- find the first letter after the pipe |
|||
return string.sub(s, 1, c-1) .. string.upper(string.sub(s, c, c)) .. string.sub(s, c+1) |
|||
end |
|||
local letterpos = string.find(s, '%a') |
local letterpos = string.find(s, '%a') |
||
if letterpos then |
if letterpos then |