Modulo:String/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
rimuovo funzione incompleta e rimpiazzata da Modulo:IP validator |
||
(6 versioni intermedie di un altro utente non mostrate) | |||
Riga 148:
]]
function str.match(
return str._match(frame.args)
local new_args = str._getParameters( frame.args, {'s', 'pattern', 'start', 'match', 'plain', 'nomatch'} );▼
end▼
--[[
Entry point per chiamata diretta da un modulo
]]
▲ local new_args = str._getParameters(
local s = new_args['s'] or '';
local start = tonumber( new_args['start'] ) or 1;
Line 425 ⟶ 432:
]]
local collation = {
{ '[áàăắằẵẳâấầẫẩǎåǻäǟãȧǡąāảȁȃạặậḁⱥᶏᴂɐᶐɒ]' , 'a'},
{'[ÁÀĂẮẰẴẲÂẤẦẪẨǍÅÅǺÄǞÃȦǠĄĀẢȀȂẠẶẬḀȺᴁ]', 'A'},
Line 433 ⟶ 441:
{'[ćĉčċçḉȼƈ]', 'c'},
{'[ĆĈČĊÇḈȻƇ]', 'C'},
{'[
{'[
{'[éèèêếềễểěëẽėȩḝęēḗḕẻȅȇẹệḙḛǝ]', 'e'},
{'[ÉÈÈÊẾỀỄỂĚËẼĖȨḜĘĒḖḔẺȄȆẸỆḘḚƎ]', 'E'},
Line 443 ⟶ 451:
{'[ĥȟḧḣḩħḥḫẖ]', 'h'},
{'[ĤȞḦḢḨĦḤḪ]', 'H'},
{'[
{'[
{'[ĵǰ]', 'j'},
{'[Ĵ]', 'J'},
Line 458 ⟶ 466:
{'[ÓÒŎÔỐỒỖỔǑÖȪŐÕṌṎȬȮȰØǾǪǬŌṒṐỎȌȎƠỚỜỠỞỢỌỘ]', 'O'},
{'[ṕṗ]', 'p'},
{'[
{'[ŕřṙŗȑȓṛṝṟ]', 'r'},
{'[ŔŘṘŖȐȒṚṜṞ]', 'R'},
Line 476 ⟶ 484:
{'[ŹẐŽŻẒẔƵȤʐⱫ]', 'Z'},
}
local new_args = str._getParameters(frame.args, {'source'})▼
local source = new_args['source'] or ''▼
--local source = mw.ustring.toNFC(source)▼
for _, el in ipairs(collation) do
source = mw.ustring.gsub( source, el[1], el[2])
end
return source
Line 483 ⟶ 496:
--[[
Funzione per estrarre da un titolo la stringa adatta all'ordinamento alfabetico.
]]
▲function str.collate( frame )
▲ local new_args = str._getParameters(frame.args, {'source'})
▲ local source = new_args['source'] or ''
▲ --local source = mw.ustring.toNFC(source)
▲end
function str.titolo_alfa(frame)
Line 506 ⟶ 511:
end
source = mw.ustring.gsub(source, ' %(.*%)$', '')
source =
source = mw.ustring.gsub(source, "^['%(%.¡¿ ]*", '')
for _,article in ipairs(articoli) do
Line 515 ⟶ 520:
return source
end
-- =================================================================
Line 620 ⟶ 626:
pre: eventuale stringa che precede l'unione delle stringhe
post: eventuale stringa che segue l'unione delle stringhe
indentazione: una stringa da ripetere cumulativamente per ogni messaggio (tipicamente ' ')
lista: se valorizzata a:
'puntata' imposta i parametri per una lista puntata
'ordinata' imposta i
'infobox' imposta l'unione come una lista, eccetto che nel caso ci sia
solo un elemento
Line 664 ⟶ 671:
local index = tonumber(base_args.Nmin) or tonumber(base_args.nmin) or base_index
local Nobbligatori = tonumber(base_args.Nobbligatori) or tonumber(base_args.nobbligatori) or base_index-1
local indentazione = base_args.indentazione or nil
local args = frame:getParent().args
-- estraggo il primo valore
Line 696 ⟶ 704:
if #elements == 0 then return '' end
-- carico separatori, congiunzione, pre e postazione
local pre, post, separatore, congiunzione, indent = '', '', '', '', ''
local lista = base_args.lista or ''
if lista == 'puntata' or (lista =='infobox' and #elements >1) then
Line 713 ⟶ 721:
separatore = base_args.separatore or ''
congiunzione = base_args.congiunzione or separatore
end
if indentazione then
local current_indentazione = indentazione
for i, msg in ipairs(elements) do
elements[i] = current_indentazione .. elements[i]
current_indentazione = current_indentazione .. indentazione
end
end
return pre .. mw.text.listToText(elements, separatore, congiunzione) .. post
Line 808 ⟶ 823:
return pre .. mw.text.listToText(elements, separatore, congiunzione) .. post
end
--[[
|