Manialib\Formatting: manipulate styles with PHP

Open source, lightweight PHP framework for Manialink and Web development.

Moderator: NADEO

Post Reply
User avatar
gouxim
Nadeo
Nadeo
Posts: 1188
Joined: 14 Jun 2010, 17:20

Manialib\Formatting: manipulate styles with PHP

Post 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:
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
Xymph
Posts: 1426
Joined: 15 Jun 2010, 20:35
Contact:

Re: Manialib\Formatting: manipulate styles

Post 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. ;)
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub
User avatar
gouxim
Nadeo
Nadeo
Posts: 1188
Joined: 14 Jun 2010, 17:20

Re: Manialib\Formatting: manipulate styles

Post by gouxim »

Nice catch thx :thx:
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
Post Reply

Return to “ManiaLib”

Who is online

Users browsing this forum: No registered users and 0 guests