Binding of Isaac: Rebirth Wiki
Binding of Isaac: Rebirth Wiki

local p = {}

local w_frame = require( 'module:frame' )
local w_title = require( 'module:title' )


-- DEPRECATED
p.pageName     = w_title.main
p.rootPageName = w_title.root
p.subPageName  = w_title.subpage


function p.toNumber( f )
	local args = w_frame.args( f )
	return tonumber( args[1], args.base or 10 )
end


-- DEPRECATED : Use "template:font" instead
function p.font( f )
    local args = w_frame.args( f )
    return '<span class="custom-font custom-font-' .. args[ 1 ] .. ( args.title and '" title="' .. args.title or '' ) .. '">' .. args[ 2 ] .. '</span>'
end


function p.title( f )
    local args  = w_frame.args( f )
    local scale = tonumber( args[ 3 ] or 1 )
    local space = '</span> ' .. ( scale > 1.5 and '&nbsp;' or '' ) .. ' <span style="white-space: nowrap">'
    local width = mw.loadData( 'module:text/' .. args[ 1 ] )
    local intro = '[[file:font_' .. args[ 1 ] .. '_'
    local outro = 'px|link=' .. ( args.link or '' ) .. '|' .. ( args.desc or '' ) .. ']]'
    local text  = '<span style="white-space:nowrap">'
    local specialCharacters = mw.loadData( 'module:text/special' )
    for c in mw.text.gsplit( args[ 2 ], '' ) do
        text = text .. ( c == ' ' and space or intro .. ( specialCharacters[ c ] or c ) .. '.png|alt=' .. c .. '|' .. math.floor( width[ c ] * scale ) .. outro )
    end
    return text .. '</span>'
end


return p