Page 1 of 1

ManiaPlanet style Swift parser

Posted: 03 Mar 2015, 13:49
by toffe
Image Image

Hello,
I started a Swift Maniaplanet style formatter. Inputs a string, returns a NSAttributedString for style usage on labels and more.
I will use the framework myself in the Maniaplanet Toolkit in later versions for faster parsing of styles. Currently it's using the NSAttributedString HTML parser that is very slow (because it uses webviews on the background, and because of that it isn't threadable, needs to be on main/ui thread).

Code: Select all

let nickname = "$F80$i$S$oToffe$z$06FSmurf $z$n$l[http://goo.gl/y4M9VK][App]$l"
let styledNickname = MPFormatter().parse(nickname).getAttributedString()
Will result in Image

Install and usage instructions are in the github readme.md.
Cocoapods definition:

Code: Select all

pod 'MPFormatter', '~> 1.2.0'
Github: https://github.com/tomvlk/MPFormatter_swift

Announcement: Version 1.x.x freezed, from now 1.x.x will only get bugfixes.

Toffe

Re: ManiaPlanet style Swift parser

Posted: 08 Mar 2015, 11:20
by toffe
The library is now updated, can now strip styles,links and colors on the parse() return.
See github for examples.

Toffe

Re: ManiaPlanet style Swift parser

Posted: 23 Mar 2015, 12:38
by toffe
New version released on github. Has a fix for $h links.

Toffe

Re: ManiaPlanet style Swift parser

Posted: 09 Apr 2015, 21:17
by toffe
The github master is updated to Swift 1.2 for the new XCode (and Swift) support.
(Build is still failing at travis because of the lack of support for the new xcode at travis).

Toffe

Re: ManiaPlanet style Swift parser

Posted: 09 Apr 2015, 22:05
by novationx
great work mate!
Can i ask for what this is used?

Is it to display maniaplanet-nicknames correctly on ios devices?

Re: ManiaPlanet style Swift parser

Posted: 09 Apr 2015, 22:08
by toffe
Its used in the ManiaPlanet toolkit app for iOS. To display the server names and the nicknames of the players. Also used for making links, and colors in news items.
And working great. :)

Toffe

Re: ManiaPlanet style Swift parser

Posted: 18 Sep 2015, 10:28
by toffe
Just updated to Swift 2.0!

Toffe

Re: ManiaPlanet style Swift parser

Posted: 07 Nov 2015, 18:01
by toffe
Now also supports tvOS.
And added Cocoapods support:



Make sure you got the Podfile header for using Swift code:

Code: Select all

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
Then add the pod

Code: Select all

pod 'MPFormatter', '~> 1.1.1'

Re: ManiaPlanet style Swift parser

Posted: 14 Feb 2017, 19:31
by toffe
Lib has been converted and updated to support Swift 3!.

1.x.x will only get bugfixes from now.