/WEBBCode

Lean and mean SAX style parser for BBCode written in Objective C/C with support for various conversions

Primary LanguageObjective-CMIT LicenseMIT

WEBBCode

CI Status Version License Platform

This is a lean and mean SAX style parser for BBCode written in Objective C/C.

It has support for output to HTML and NSAttributedString (work in progress) for simple BBCode.

It is totally pluggable and extensible to allow for full customization.

The pod has two sub specs:

Core: which contains the BBCode parser and model classes. HTML: which contains support for transformation to HTML.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Example usage to parse:

WEBBCodeParser *parser = [WEBBCodeParser new];
parser.encoding = NSUTF8StringEncoding;
parser.delegate = self;

NSData *data = [NSData dataWithContentsOfFile:@"somefile"];
[parser parseData:data error:nil];

Example to convert BBCode to HTML:

WEBBCodeHtmlConverter *converter = [WEBBCodeHtmlConverter new];
converter.transformer = [WEBBCodeHtmlDefaultTagTransformer new];
converter.useParagraphs = NO;

NSString *input = @"some [b]bb code[/b]"";
NSError *error = nil;
NSString *output = [converter htmlFromBBCode:input error:&error];

if (output == nil) {
    NSLog(@"Error occurred: %@", error);
}

Also see the test cases for more code examples.

Requirements

Installation

WEBBCode is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "WEBBCode"

Author

Werner Altewischer

License

WEBBCode is available under the MIT license. See the LICENSE file for more info.