Markdown to NSAttributedString library?

Jason picture Jason · Sep 27, 2012 · Viewed 7.3k times · Source

Now that NSAttributedString is fully supported in iOS 6, is there a library that will take an NSString with markdown, and convert it to NSAttributedString?

Answer

sobri picture sobri · Nov 20, 2012

I've just added an NSString to NSAttributedString lightweight markup parser to MGBoxKit. It's not Markdown but it's very similar. So far it supports bold, italics, underline, monospacing, text colour, background colour, and kerning.

The MGMushParser class is now a standalone pod, so can easily be used independent of MGBoxKit.

NSString *markup = @"**bold**, //italics//, __underlining__, `monospacing`, and {#0000FF|text colour}";

UIFont *baseFont = [UIFont fontWithName:@"HelveticaNeue" size:18];
UIColor *textColor = UIColor.whiteColor;

myLabel.attributedString = [MGMushParser attributedStringFromMush:markup
                               font:baseFont color:textColor];