Latest 0.1.0
Homepage https://github.com/daltoniam/DCTextEngine
License Apache License, Version 2.0
Platforms ios 6.0, osx 10.8, requires ARC
Authors

An engine that convert text to attributed strings and attributed strings to text. Supports HTML and markdown by default. It is cross platform for iOS and OSX.

Dependencies

Requires CoreText.

Examples

NSString *string = @"#Dalton Cherryn##Dalton Cherryn*Lorem Ipsum* is simply _dummy_ text of the **printing** and typesetting industry. Lorem Ipsum has been the industry's standard *dummy* text ever since the 1500s. Here is a link to test with [Google](http://www.google.com/), should work fine. Here is a raw link: https://github.com. Hello at @austin, here is that email [email protected] youtube video: http://www.youtube.com/watch?v=XibDfYd83Zg here is more text. Some more text";

DCTextEngine *engine = [DCTextEngine engineWithMarkdown];
__weak blockEngine = engine;
[engine addPattern:@"more text." found:^DCTextOptions*(NSString *regex, NSString *text){
    DCTextOptions *opts = [DCTextOptions new];
    NSTextAttachment *attach = [[NSTextAttachment alloc] init];
    attach.image = [UIImage imageNamed:@"subways.png"];
    attach.bounds = CGRectMake(0, 0, self.view.frame.size.width, 100);
    opts.attachment = attach;
    return opts;
}];
[engine addPattern:@"(^|\s)@\w+" found:^DCTextOptions*(NSString *regex, NSString *text){
    DCTextOptions *opts = [DCTextOptions new];
    opts.color = [UIColor redColor];
    opts.font = [blockEngine boldFont];
    return opts;
}];

alt tag

Notes

As the example shows, the engine has a very powerful parsing via regex, yet still being very simple to create the proper style. This engine will work on iOS 6, but you will be very limited on the style that can be applied. I strongly recommend using iOS 7 or above or at least 10.7 or above.

Contact

Dalton Cherry

Latest podspec

{
    "name": "DCTextEngine",
    "version": "0.1.0",
    "summary": "An engine that convert text to attributed strings and attributed strings to text. Supports HTML and markdown by default.",
    "homepage": "https://github.com/daltoniam/DCTextEngine",
    "license": "Apache License, Version 2.0",
    "authors": {
        "Dalton Cherry": "[email protected]"
    },
    "source": {
        "git": "https://github.com/daltoniam/DCTextEngine.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "6.0",
        "osx": "10.8"
    },
    "source_files": "*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This