Page 1 of 1

Manialib\Formatting: manipulate styles with PHP

Posted: 03 Feb 2015, 13:12
by gouxim
Much hello,

We are soon releasing a little PHP package for manipulating styles in Maniaplanet strings. It's inspired from "StyleParser" in former manialib version, and also from TMFColorParser from back in the days :)

With our new approach to PHP and open source, we're now releasing it as a simple standalone PHP package, following modern PHP conventions.

Here's a little example:

Code: Select all

use Manialib\Formatting\String;

$nickname = '$l[https://github.com/manialib/formatting]$cfeg$fff๐u1 $666ツ$l';

$string = new String($nickname);
echo $string->stripColors()->stripLinks();
Will output:

Code: Select all

g๐u1 ツ
Convert a string to HTML:

Code: Select all

use Manialib\Formatting\String;

$string = new String('$cfeg$fff๐u1 $666ツ');

echo $string->toHtml();
Will output:

Code: Select all

<span style="color:#cfe;">g</span><span style="color:#fff;">๐u1 </span><span style="color:#666;">ツ</span>
You can find out more at https://github.com/manialib/formatting

Right now it is tagged as "4.0.0-beta2", so not stable. If you need to use this in a project, we might draft a stable 4.0.0 release.

Your feedback is welcome :thx:

Re: Manialib\Formatting: manipulate styles

Posted: 03 Feb 2015, 13:17
by Xymph
gouxim wrote:Here's a little example:

Code: Select all

use Manialib\Formatting\String;

$nickname = '$l[https://github.com/manialib/formatting]$cfeg$fff๐u1 $666ツ$l';

$string = new String($originalString);
echo $string->stripColors()->stripLinks();
Will output:

Code: Select all

g๐u1 ツ
Hmm, I'm expecting it will output an empty string or show an error: $originalString isn't defined, after all. ;)

Re: Manialib\Formatting: manipulate styles

Posted: 03 Feb 2015, 14:49
by gouxim
Nice catch thx :thx: