iphone - Markdown 到 NSAttributedString 库?

标签 iphone ios nsstring markdown nsattributedstring

<分区>

既然 NSAttributedString 在 iOS 6 中得到了完全支持,是否有一个库可以将带有 markdown 的 NSString 转换为 NSAttributedString?

最佳答案

我刚刚将 NSString 添加到 NSAttributedString 轻量级标记解析器到 MGBoxKit .它不是 Markdown,但非常相似。到目前为止,它支持粗体、斜体、下划线、等宽、文本颜色、背景颜色和字距调整。

MGMushParser class 现在是一个独立的 pod,因此可以独立于 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];

关于iphone - Markdown 到 NSAttributedString 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12629219/

相关文章:

iphone - 在表格 View 中添加按钮

ios - 禁用 FScalendar swift 中的一些 future 日期选择

html - 如何计算html字符串的高度?

objective-c - 如何转义 NSString 以在 NSURL 中使用?

iphone - 对于通过我的 iphone 应用程序中的 slider 控件以编程方式设置的 iphone 亮度

iphone - 如何正确插入背景图片

iPhone iOS 6 UITabBarController 仅纵向,如何让模态视图 Controller 支持横向方向

iphone - 在 NSString 中将 NSData 显示为二进制

ios - UICollectionView 在自定义键盘扩展中不起作用

ios - 将扫描的条码值解码为int值