Differenze tra le versioni di "Modulo:Blackabbrev"

New Wikicode API support
(Il gioco viene cercato tra quelli per il testo chiaro in minuscolo)
(New Wikicode API support)
--[=[
-- Collegamenti ai giochi tramite le loro sigle: campo colorato e testo nero/bianco
 
This module creates link to games, displaying them in colored background.
local x = {}
 
Examples:
local txt = require('Modulo:Wikilib/strings')
local lib = require('Modulo:Wikilib/sigle')
local c = mw.loadData('Modulo:Colore/data')
local m = mw.loadData('Modulo:Sigle/data')
local wd = mw.loadData('Modulo:Wikilib/data')
 
{{#invoke: Blackabbrev | UL }}
--[=[
{{#invoke: Blackabbrev | RZS | RFVF}}
{{#invoke: Blackabbrev | HGSS | XY | ROZA }}
 
HINT: If you get an Errore Script, try to split an abbreviation into
Ritorna la sigla del gioco sullo sfondo
smaller parts. For example:
del colore corrispondente. Pair è una
coppia della subtable display degli
elementi di Sigle/data, ovvero:
- primo elemento: sigla del gioco
- secondo elemento: colore del gioco
 
{{#invoke: Blackabbrev | OACPtHGSS }} --> {{#invoke: Blackabbrev | OAC | Pt | HGSS }}
--]=]
 
--]=]
local singleDisplay = function(pair)
return string.interp([[<span style="padding: 0 0.3em; color:#${text}; background: #${colore};">'''${sigla}'''</span>]],
{
text = table.search(wd.whitetext, pair[2]:lower()) and c.background or '000',
colore = c[pair[2]].normale,
sigla = pair[1],
})
end
 
local libtab = require('Modulo:Wikilib/sigletables') -- luacheck: no unused
-- Crea la funzione d'interfaccia per ogni sigla
local txtlib = require('Modulo:Wikilib/stringssigle')
local cm = mw.loadData('Modulo:ColoreSigle/data')
 
-- Creates the links for a single abbreviation, as a single string
for abbr, data in pairs(m) do
x[abbr]local makeLinks = function(frame) return lib.abbrLinks(data, singleDisplay) end
return table.concat(lib.backgroundAbbrevLinks(data, lib.bolden))
end
 
-- Dynamically generated Wikicode interface
return x
return table.map(m, function(_, abbr)
 
--[[
Wikicode arguments are first processed one-by-one by makeLinks,
resulting in a table having a string for every argument, containing
all the links. These strings are then concatenated.
--]]
return lib.onMergedAbbrs(abbr, makeLinks)
end)