TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Apr 2015 |
Maintained by Jose Alcalá Correa, Renzo Crisóstomo, Martin Kim Dung-Pham.
This is a Markdown => NSAttributedString parser built on top of a flex parser. It takes an NSString and returns an NSAttributedString with markdown tags replaced by CoreText formatting attributes.
This project is a fork of NSAttributedMarkdownParser by NimbusKit: https://github.com/NimbusKit/markdown
*italics*
**bold**
***bold italic***
~~strikethrough~~
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
###### Header 6
Header 1
========
Header 2
--------
http://google.com urls
[Text] (http://google.com "alt text") urls
XNGMarkdownParser *parser = [[XNGMarkdownParser alloc] init];
NSAttributedString *string = [parser attributedStringFromMarkdownString:@"This is __rad__."];
// this parser initializes only once and customizes fonts, line height and link color
+ (XNGMarkdownParser *)titleMarkdownParser {
static dispatch_once_t onceToken;
static XNGMarkdownParser *parser;
dispatch_once(&onceToken, ^{
parser = [[XNGMarkdownParser alloc] init];
parser.paragraphFont = [UIFont xng_14Font];
parser.boldFontName = [UIFont xng_14Font].fontName;
parser.linkFontName = [UIFont xng_14Font].fontName;
const CGFloat lineHeight = 18;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.minimumLineHeight = lineHeight;
parser.topAttributes = @{
NSParagraphStyleAttributeName: paragraphStyle,
NSForegroundColorAttributeName: self.textColor
};
});
return parser;
}
See the included Example project and the tests to check for further options.