Modulo:Font to span: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Aggiunto trattino ai character set per attributi composti, + verifica che nei due style non ci siano ulteriori attributi identici e relativa rimozione da quello esterno.
m +workaround per evitare strani lavori sul background-color (quando sarebbe bastato un lookbehind, ma di meglio non so fare) e rinomina variabili in conflitto
Riga 110:
-- elimina parametri duplicati, lascia quello in style
if style~=nil then
style=string.gsub(style, "background%-color", "background%-clor") --workaround per evitare match sul bgcol
if color~=nil and string.match(style, "color:") then color=nil end
if size~=nil and string.match(style, "font%-size:") then size=nil end
if face~=nil and string.match(style, "font%-family:") then face=nil end
style=string.gsub(style, "background%-clor", "background%-color") --annullo il workaround
end
 
Line 160 ⟶ 162:
--estrazione parametri dal primo style
if x[4]~=nil then
x[4]=string.gsub(x[4], "background%-color", "background%-clor") --workaround per evitare match sul bgcol
c1=string.match(x[4], 'color:([^;"]+)')
s1=string.match(x[4], 'font%-size:([^;"]+)')
f1=string.match(x[4], 'font%-family:([^;"]+)')
x[4]=string.gsub(string.gsub(string.gsub(x[4], 'font%-family:([^;"]+)', ""), 'font%-size:([^;"]+)', ""), 'color:([^;"]+)', "")
x[4]=string.gsub(x[4], "background%-clor", "background%-color") --annullo il workaround
end
--estrazione parametri dal secondo style
if y[4]~=nil then
y[4]=string.gsub(y[4], "background%-color", "background%-clor") --workaround per evitare match sul bgcol
c2=string.match(y[4], 'color:([^;"]+)')
s2=string.match(y[4], 'font%-size:([^;"]+)')
f2=string.match(y[4], 'font%-family:([^;"]+)')
y[4]=string.gsub(string.gsub(string.gsub(y[4], 'font%-family:([^;"]+)', ""), 'font%-size:([^;"]+)', ""), 'color:([^;"]+)', "")
x[4]=string.gsub(x[4], "background%-clor", "background%-color") --annullo il workaround
end
--Parametro univoco, ordine di priorità: style dentro, tag dentro, style fuori, tag fuori
Line 188 ⟶ 194:
if x[4]~=nil and y[4]~=nil then
--liste di attributi
rit1= string.gmatch(x[4], "([%a-]+:)")
sit2= string.gmatch(y[4], "([%a-]+:)")
corr={}; --table vuota di corrispondenze
for i in rit1 do
for j in sit2 do
if i==j then table.insert(corr, i) end --aggiunge il match alle corrispondenze
end
sit2= string.gmatch(y[4], "([%a-]+:)") --ripristina iteratore per altri giri
end
--elimina le corrispondenze e relativo valore dal tag esterno