Converting To Simple Machines From PhpBB 3.3.1

Started by Catsmother, August 25, 2020, 07:06:55 AM

Previous topic - Next topic

Antechinus

Hey hang on a minute. Re this conversion of font sizes, IanL added this to his phpBB => Elk 1.0 script (which should also work on SMF 2.0):

function percent_to_px($percent)
{
return intval(11 * (intval($percent) / 100.0));
}


With that applying to this bit where the size tags are defined:

'[size=' . percent_to_px("\1") . 'px]',
'[/size]',


Looking at the default Subs.php array for font size...

array(
'tag' => 'size',
'type' => 'unparsed_equals',
'test' => '([1-9][\d]?p[xt]|small(?:er)?|large[r]?|x[x]?-(?:small|large)|medium|(0\.[1-9]|[1-9](\.[\d][\d]?)?)?em)\]',
'before' => '<span style="font-size: $1;" class="bbc_size">',
'after' => '</span>',
),


Alrighty, as far as I can tell that says it will do sizes in pt, keyword, or em. Cool. However, I can't get it to parse if I use a < 1 decimal value of em. Using 1.00em or 1.15em works just fine, but for some reason using .85em or 0.85em doesn't work. It just spits out the raw BBC, instead of turning it into a span with font-size set inline. IOW, it renders exactly as if you had wrapped it in a .bbc_code tag.

Why? Decimal values < 1 are perfectly valid values in HTML. Surely Subs.php should  be able to handle them. If it can't handle them, what's stopping it?

Reason I'm asking is because if the SMF 2.0.x array can be made to handle < 1 decimal values of em, converting straight from phpBB values to SMF-compatible values would be a piece of cake. You'd just use a function like this:

function percent_to_em($percent)
{
return ($percent / 100.0);
}


With that applying to...

'[size=' . percent_to_em("\1") . 'em]',
'[/size]',


That would give an exact conversion regardless of what weird size someone had entered in phpBB (and they do enter weird sizes, coz I've looked in a save of the db I admin).

Advertisement: