Modul:X
Die Dokumentation für dieses Modul kann unter Modul:X/Doku erstellt werden
local p = {} --local p = {} -- p steht für Paket (engl. package)
function split (inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
function p.cut( frame )
i = 2;
limit = tonumber(frame.args[1])
text = frame.args[2]
stext = split(text, " ")
cuttext = stext[1]
nextwo = stext[2]
nextlen = string.len(nextwo)
textlen = string.len(text)
cuttextlen = string.len(cuttext)
set = false;
mw.log("ouh")
if(limit>=textlen)then
return text.."%@%"
elseif(cuttextlen>limit) then
return "%@%"..text
else
while (cuttextlen+nextlen<textlen+3) do
if(cuttextlen+nextlen>limit and set) then
set = true
cuttext = cuttext.."%@%"
else
cuttext = cuttext.." "
end
i = i + 1
cuttext = cuttext..nextwo
nextwo = stext[i]
nextlen = string.len(nextwo)
cuttextlen = string.len(cuttext)
end
return cuttext
end
end
return p