Modulo:String/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
fix2 |
test list to string |
||
Riga 401:
end
return mw.ustring.rep( frame.args[1] or '', repetitions )
end▼
function str.spacer(frame)▼
return ''▼
end▼
local spacer = new_args['spacer'] or ' ';▼
local characters={}▼
end
Line 605 ⟶ 581:
return pre .. mw.text.listToText(elements, separatore, congiunzione) .. post
end
local base_args = frame.args
if not base_args then return str._error('Lista parametri vuota') end
-- carico la lista dei parametri
local base_index = tonumber((base_args['base_index'] and base_args['base_index']) or '1')
local par_number = tonumber((base_args['par_number'] and base_args['par_number']) or '1')
local Nmax = tonumber((base_args['par_max_number'] and base_args['par_max_number']) or '0')
--carico il messaggio
local msg = base_args.msg or '$1'
local message = Message(msg)
elements = {}
-- carico gli altri parametri di formattazione
local index = base_index
local args = frame:getParent().args
-- elaboro i valori successivi
while found do
if Nmax > 0 and index > Nmax then break end
message:reset_values()
found = false
for i = index, index+par_number-1 do
if args[i] then
found = true
message:add_value(args[i])
end
if not found then break end
elements[#elements+1] = message:text()
index = index + par_number
▲ end
if #elements == 0 then return '' end
-- carico separatori, congiunzione, pre e postazione
local pre, post, separatore, congiunzione = '', '', '', ''
if lista == 'puntata' or (lista =='infobox' and #elements >1) then
pre = '<UL><LI>'
post = '</LI>\n</UL>'
separatore = '</LI>\n<LI>'
congiunzione = separatore
elseif lista == 'ordinata' then
pre = '<OL><LI>'
post = '</LI>\n</OL>'
separatore = '</LI>\n<LI>'
congiunzione = separatore
else
pre = base_args.pre or ''
post = base_args.post or ''
separatore = base_args.separatore or ''
congiunzione = base_args.congiunzione or separatore
end
return pre .. mw.text.listToText(elements, separatore, congiunzione) .. post
▲end
--[[
|