Modulo:Font to span: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
+size in pt
m -errore grave, chissà quante pagine ci sono scappate...
 
(7 versioni intermedie di uno stesso utente non sono mostrate)
Riga 4:
--funzione di estrazione per utilizzo multiplo
local function extract(x)
face=string.match(x, "face%s*=%s*([%d%aæ,]+)") or string.match(x, 'face%s*=%s*"%s*([^"]+)"')
size=string.match(x, 'size%s*=%s*"?%s*([-+]?%d+[pxtem%%]*)"?') or string.match(x, 'size%s*=%s*"?%s*([%a-]+)"?')
color=string.match(x, 'color%s*=%s*"?%s*(rgb%([^)]+%))"?') or string.match(x, 'color%s*=%s*"?%s*(#?%w+)"?')
Riga 29:
if type=="size" then
--riporto valori fantasiosi di size a quelli reali
if z=tonumber(string.match(a, "(%d+) *pt")) thenor tonumber(a)
if z~=nil then
z=string.match(a, "(%d+)")
if z>7 then a="7"
a=math.floor(z * 4 / 3) .. "px"
elseif z<-2 then a="-2"
else
elseif z>4 and string.match(a, "^%+%d$") then a="+4" end
z=tonumber(a)
if z~=nil then
if z>7 then a="7"
elseif z<-2 then a="-2"
elseif z>4 and string.match(a, "^%+%d$") then a="+4" end
end
end
--tabella conversione size
Line 60 ⟶ 55:
 
if type=="color" then
--via gli spazi messi fantasiosamente e l'ancor più fantasioso "solid"
z a = string.matchgsub(a, "(%d+) ", "");
a = string.gsub(a, "solid", "");
--aggiunge cancelletto a colore se in formato hex e sottinteso. Il pattern è molto brutale ma funziona perché non esistono nomi di colore che lo rispettano
if string.match(a, "^[a-f0-9]+$") then a = "#" .. a end
Line 90 ⟶ 88:
if string.match(str, "<font[^>]+>%[%[[^%]]+]]<%/font>") then
substype=1; --solo wikilink
elseif string.match(str, "<font[^>]+>%[http[^%]]+ [^%]]+]<%/font>") or string.match(str, "<font[^>]+>%[\{\{fullurl[^%]]+ [^%]]+]<%/font>") then
substype=2; --solo link esterno CON TITOLO
elseif string.match(str, "<font[^>]+>%[http[^%] ]+]<%/font>") or string.match(str, "<font[^>]+>%[\{\{fullurl[^%] ]+]<%/font>") then
return str; --solo link esterno SENZA TITOLO: il font colora il numero progressivo dall'esterno, lo span no; non ho trovato un modo per colorarlo con span interno.
end --negli altri casi i risultati sono equivalenti