github

SimonFairbairn / SwiftyMarkdown

  • четверг, 7 апреля 2016 г. в 03:13:27
https://github.com/SimonFairbairn/SwiftyMarkdown

Swift
Converts Markdown files and strings into NSAttributedString



SwiftyMarkdown

SwiftyMarkdown converts Markdown files and strings into NSAttributedString using sensible defaults and a Swift-style syntax. It uses dynamic type to set the font size correctly with whatever font you'd like to use

Usage

Text string

let md = SwiftyMarkdown(string: "# Heading\nMy *Markdown* string")
md.attributedString()

URL

if let url = NSBundle.mainBundle().URLForResource("file", withExtension: "md"), md = SwiftyMarkdown(url: url ) {
    md.attributedString()
}

Customisation

md.body.fontName = "AvenirNextCondensed-Medium"

md.h1.color = UIColor.redColor()
md.h1.fontName = "AvenirNextCondensed-Bold"
md.italic.color = UIColor.blueColor()

Screenshot

Screenshot