Модуль:Repeat
Документацію для цього модуля можна створити у Модуль:Repeat/документація
local p = {}
--
function p.out(frame)
local symbol = frame.args[1]
local n_skip = tonumber(frame.args[2])
local nmax = tonumber(frame.args[3])
local str, n, skip
skip = ''
str = symbol
if nmax == nil then
nmax = 100
end
for n =1, n_skip do
skip = skip .. ' '
end
for n = 1, nmax do
str = str .. skip .. symbol
end
return str
end
--
--
function p.symbol(frame)
local nmax = tonumber(frame.args[1])
local symbol = frame.args[2]
local str, n
if nmax == nil then
nmax = 0
end
if symbol == nil then
symbol = ' '
end
str = ''
for n = 1, nmax do
str = str .. symbol
end
return frame:preprocess(str)
end
--
function p.LetterSpacingExLast(frame)
local words = frame.args[1]
local sp = frame.args[2]
local str, last, prefix, nlen
if words == nil or words == '' then
str = ''
else
nlen = mw.ustring.len(words)
prefix = mw.ustring.sub(words, 1, nlen-1)
last = mw.ustring.sub(words, -1)
str = '<span style="letter-spacing:' .. sp .. ';">'
str = str .. prefix .. '</span>' .. last
end
return str
end
--
function p.BreakWordsIntoLetters(frame)
local words = frame.args[1]
local fsize = frame.args[2]
local str, last, letter, nlen
str = ''
if words ~= nil and words ~= '' then
nlen = mw.ustring.len(words)
last = mw.ustring.sub(words, -1)
for n = 1, nlen-1 do
letter = mw.ustring.sub(words, n, n)
if letter == ' ' then
letter = ' '
else
letter = letter .. ' '
end
str = str .. letter
end
str = str .. last
end
if fsize ~= nil and fsize ~= '' then
str = '{{' .. fsize .. '|' .. str .. '}}'
end
return frame:preprocess(str)
end
--
return p