(Frame) |
Aucun résumé des modifications |
||
(2 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 4 : | Ligne 4 : | ||
− | function p.titre( |
+ | function p.titre( police, texte, taille ) |
+ | return require( 'Module:Text' ).title{ police, texte, taille } |
||
− | local police = f:getParent().args[1] |
||
− | local |
+ | --[[local caracteres = {} |
− | local taille = f:getParent().args[3] |
||
− | local caracteres = {} |
||
local caracteresExistent = {} |
local caracteresExistent = {} |
||
local i = 1 |
local i = 1 |
||
Ligne 28 : | Ligne 26 : | ||
infos.height = math.floor( infos.height * taille ) |
infos.height = math.floor( infos.height * taille ) |
||
infos.width = math.floor( infos.width * taille ) |
infos.width = math.floor( infos.width * taille ) |
||
− | _t = _t .. ' |
+ | _t = _t .. 'Image:' .. nomFichier .. '|' .. tostring( infos.width ) .. 'x' .. tostring( infos.height ) .. 'px|lien=' |
end |
end |
||
i = i + 1 |
i = i + 1 |
||
end |
end |
||
− | return _t .. '</span>' |
+ | return _t .. '</span>']] |
end |
end |
||
Dernière version du 1 mai 2018 à 17:30
La documentation ci-haut est transcluse de Module:Police/doc. (modifier | historique)
local p = {}
local modElements = require( 'Module:Elements' )
function p.titre( police, texte, taille )
return require( 'Module:Text' ).title{ police, texte, taille }
--[[local caracteres = {}
local caracteresExistent = {}
local i = 1
local _t = '<span style="white-space:nowrap">'
texte:gsub( ".", function(c) table.insert( caracteres, c ) end )
while caracteres[i] do
if caracteres[i] == ' ' then
_t = _t .. '</span> <span style="white-space:nowrap">'
else
for index, objet in pairs( p.caracteresSpeciaux() ) do
if not caracteresExistent[i] and caracteres[i] == index then
caracteres[i] = objet
caracteresExistent[i] = true
end
end
local nomFichier = 'Font_' .. police .. '_' .. caracteres[i] .. '.png'
local infos = mw.title.new( nomFichier, 'Fichier' ).file
infos.height = math.floor( infos.height * taille )
infos.width = math.floor( infos.width * taille )
_t = _t .. 'Image:' .. nomFichier .. '|' .. tostring( infos.width ) .. 'x' .. tostring( infos.height ) .. 'px|lien='
end
i = i + 1
end
return _t .. '</span>']]
end
function p.gras( police, texte, var1, var2, var3 )
local _p = police .. '-Bold'
return p.standard( _p, texte, var1, var2, var3 )
end
function p.standard( police, texte, var1, var2, var3 )
local caracteres = {}
local caracteresExistent = {}
local i = 1
local _t = ''
local car1 = {}
if var1 then car1 = mw.text.split( var1, '-' ) end
local car2 = {}
if var2 then car2 = mw.text.split( var2, '-' ) end
local car3 = {}
if var3 then car3 = mw.text.split( var3, '-' ) end
texte:gsub( ".", function(c) table.insert( caracteres, c ) end )
while caracteres[i] do
if caracteres[i] == ' ' then
_t = _t .. ' '
else
for index, objet in pairs( p.caracteresSpeciaux() ) do
if not caracteresExistent[i] and caracteres[i] == index then
caracteres[i] = objet
caracteresExistent[i] = true
end
end
local carPers = false
if var1 then if caracteres[i] == car1[1] then _t = _t .. '<div class="font-' .. police .. ' font-' .. police .. '-' .. car1[2] .. '"></div>' carPers = true end end
if var2 then if caracteres[i] == car2[1] then _t = _t .. '<div class="font-' .. police .. ' font-' .. police .. '-' .. car2[2] .. '"></div>' carPers = true end end
if var3 then if caracteres[i] == car3[1] then _t = _t .. '<div class="font-' .. police .. ' font-' .. police .. '-' .. car3[2] .. '"></div>' carPers = true end end
if not carPers then
_t = _t .. '<div class="font-' .. police .. ' font-' .. police .. '-' .. caracteres[i] .. '"></div>'
end
end
i = i + 1
end
return _t
end
function p.caracteresSpeciaux()
return {
["“"] = "oquote",
["”"] = "cquote",
["*"] = "star",
["%+"] = "plus",
["±"] = "pm",
["="] = "equal",
["~"] = "tilde",
[":"] = "colon",
[";"] = "scolon",
["."] = "point",
["!"] = "emark",
["?"] = "qmark",
["/"] = "slash",
["|"] = "vbar",
["\\"] = "bslash",
["%("] = "oparen",
["%)"] = "cparen",
["%["] = "obrkt",
["%]"] = "cbrkt",
["{"] = "obrace",
["}"] = "cbrace",
["<"] = "lthan",
[">"] = "gthan",
["¶"] = "pilcrow",
["&"] = "and",
["§"] = "ss",
["%%"] = "percent",
["†"] = "dagger",
["‡"] = "diesis",
["#"] = "hash",
["°"] = "degree",
["%$"] = "dol",
["€"] = "euro",
["¢"] = "cent",
["£"] = "pound",
["@"] = "at",
["©"] = "copy",
["®"] = "regtm",
["¤"] = "curren",
}
end
return p