Module:Police

De Binding of Isaac: Rebirth Wiki
Aller à : navigation, rechercher
Template-info.png Documentation

Fonction titre( police, texte, taille ) [modifier le wikicode]

ArgumentsRenvois
Aucun Aucun

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> &nbsp;&nbsp;<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