## Down [![Build Status](https://travis-ci.com/johnxnguyen/Down.svg?branch=master)](https://travis-ci.com/johnxnguyen/Down) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/johnxnguyen/Down/blob/master/LICENSE) [![CocoaPods](https://img.shields.io/cocoapods/v/Down)](https://cocoapods.org/pods/Down) [![Swift 5](https://img.shields.io/badge/language-Swift-blue.svg)](https://swift.org) [![macOS](https://img.shields.io/badge/OS-macOS-orange.svg)](https://developer.apple.com/macos/) [![iOS](https://img.shields.io/badge/OS-iOS-orange.svg)](https://developer.apple.com/ios/) [![tvOS](https://img.shields.io/badge/OS-tvOS-orange.svg)](https://developer.apple.com/tvos/) [![Linux](https://img.shields.io/badge/OS-Linux-orange.svg)](https://www.linux.org/) [![Code Coverage](https://codecov.io/gh/johnxnguyen/Down/branch/master/graph/badge.svg)](https://codecov.io/gh/johnxnguyen/Down) Blazing fast Markdown (CommonMark) rendering in Swift, built upon [cmark v0.29.0](https://github.com/commonmark/cmark). Is your app using it? [Let us know!](mailto:polyxo@protonmail.com) If you're looking for `iwasrobbed/Down`, you found it! [Rob Phillips](https://github.com/iwasrobbed), the originator of this repository, has transferred it to me as I will be the primary maintainer from now on. Thanks to Rob for bringing Down as far as it has come and for entrusting me with its care. All existing references to `iwasrobbed/Down` should redirect to this repository. However, It is recommended to update those urls to point to this repository. #### Maintainers - [John Nguyen](https://github.com/johnxnguyen) - [Rob Phillips](https://github.com/iwasrobbed) - [Keaton Burleson](https://github.com/128keaton) - [phoney](https://github.com/phoney) - [Tony Arnold](https://github.com/tonyarnold) - [Ken Harris](https://github.com/kengruven) - [Chris Zielinski](https://github.com/chriszielinski) - [Other contributors](https://github.com/johnxnguyen/Down/graphs/contributors) 🙌 ### Installation Note: Swift support is summarized in the table below. |Swift Version|Tag| | --- | --- | | Swift 5.1 | >= 0.9.0 | | Swift 5.0 | >= 0.8.1 | | Swift 4 | >= 0.4.x | | Swift 3 | 0.3.x | now on the `master` branch and any tag >= 0.8.1 (Swift 4 is >= 0.4.x, Swift 3 is 0.3.x) #### Quickly install using [CocoaPods](https://cocoapods.org): ```ruby pod 'Down' ``` #### Install using [Carthage](https://github.com/Carthage/Carthage): ``` github "johnxnguyen/Down" ``` Due to limitations in Carthage regarding platform specification, you need to define the platform with Carthage. e.g. ```carthage update --platform iOS``` #### Install using [Swift Package Manager](https://github.com/apple/swift-package-manager): To add *Down* to your project, select `File → Swift Packages → Add Package Dependency` and enter the GitHub URL for *Down*. See [Adding Package Dependencies to Your App](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) for detailed instructions. #### Or manually install: 1. Clone this repository 2. Drag and drop the Down project into your workspace file, adding the framework in the embedded framework section 2. Build and run your app 4. ? 5. Profit ### Robust Performance >[cmark](https://github.com/commonmark/cmark) can render a Markdown version of War and Peace in the blink of an eye (127 milliseconds on a ten year old laptop, vs. 100-400 milliseconds for an eye blink). In our [benchmarks](https://github.com/commonmark/cmark/blob/master/benchmarks.md), cmark is 10,000 times faster than the original Markdown.pl, and on par with the very fastest available Markdown processors. > The library has been extensively fuzz-tested using [american fuzzy lop](http://lcamtuf.coredump.cx/afl). The test suite includes pathological cases that bring many other Markdown parsers to a crawl (for example, thousands-deep nested bracketed text or block quotes). ### Output Formats * Web View (see DownView class) * HTML * XML * LaTeX * groff man * CommonMark Markdown * NSAttributedString * AST (abstract syntax tree) ### View Rendering The `DownView` class offers a very simple way to parse a UTF-8 encoded string with Markdown and convert it to a web view that can be added to any view: ```swift let downView = try? DownView(frame: self.view.bounds, markdownString: "**Oh Hai**") { // Optional callback for loading finished } // Now add to view or constrain w/ Autolayout // Or you could optionally update the contents at some point: try? downView?.update(markdownString: "## [Google](https://google.com)") { // Optional callback for loading finished } ``` Meta example of rendering this README: ![Example gif](Images/ohhai.gif) ### Parsing API The `Down` struct has everything you need if you just want out-of-the-box setup for parsing and conversion. ```swift let down = Down(markdownString: "## [Down](https://github.com/johnxnguyen/Down)") // Convert to HTML let html = try? down.toHTML() // "