Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown to NSAttributedString library? [closed]

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?

like image 328
Jason Avatar asked Sep 27 '12 20:09

Jason


2 Answers

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];
like image 180
sobri Avatar answered Nov 04 '22 04:11

sobri


I just open-sourced a project that takes raw markdown and converts it into an NSAttributedString:

https://github.com/dreamwieber/AttributedMarkdown

It's a work-in-progress and includes a demo application which shows how to assign attributes to the various markdown elements.

like image 6
Dreamwieber Avatar answered Nov 04 '22 03:11

Dreamwieber