Differenze tra le versioni di "Modulo:Sup"

456 byte rimossi ,  15:48, 13 lug 2018
nessun oggetto della modifica
m (Hmmm)
-- Collegamenti in apice ai giochi tramite le sigle colorate
--[[
 
local x = {}
This module creates link to games, displaying them in superscripts
with colored abbreviations.
 
local libtxt = require('Modulo:Wikilib/siglestrings')
Examples:
local mlib = require('Modulo:SigleWikilib/datasigle')
local c = mw.loadData('Modulo:Colore/data')
local m = mw.loadData('Modulo:Sigle/data')
 
--[=[
{{#invoke: Sup | UL }}
{{#invoke: Sup | RZS | RFVF}}
{{#invoke: Sup | HGSS | XY | ROZA }}
 
Ritorna la sigla del gioco in apice e
HINT: If you get an Errore Script, try to split an abbreviation into
colorata del colore corrispondente.
smaller parts. For example:
Pair è una coppia della subtable
display degli elementi di Sigle/data,
ovvero:
- primo elemento: sigla del gioco
- secondo elemento: colore del gioco
 
--]=]
{{#invoke: Sup | OACPtHGSS }} --> {{#invoke: Sup | OAC | Pt | HGSS }}
 
local makeSupsingleDisplay = function(linkspair)
--]]
return string.interp([[<sup style="color:#${color};">'''${abbr}'''</sup>]],
{
color = c[pair[2]].normale,
abbr = pair[1]
})
end
 
-- Crea la funzione d'interfaccia per ogni sigla
local tab = require('Modulo:Wikilib/tables') -- luacheck: no unused
local lib = require('Modulo:Wikilib/sigle')
local m = require('Modulo:Sigle/data')
 
for abbr, data in pairs(m) do
-- Creates the links for a single abbreviation, as a single string
local makeLinks x[abbr] = function(frame) return lib.abbrLinks(data, singleDisplay) end
return table.concat(lib.coloredAbbrevLinks(data, lib.bolden))
end
 
return x
-- Wraps a list of links content in sup tags
local makeSup = function(links)
table.insert(links, 1, '<sup>')
table.insert(links, '</sup>')
return table.concat(links)
end
 
-- Dynamically generated Wikicode interface
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 and wrapped in sup
tags by makeSup.
--]]
return lib.onMergedAbbrs(abbr, makeLinks, makeSup)
end)