![Swift version](https://img.shields.io/badge/Swift-2.1 | 2.2-blue.svg) ![GitHub license](https://img.shields.io/badge/license-LGPL v3-green.svg)
Full markdown support for Swift - wrapper over Discount (this actually is what GitHub uses deep down)
Markdown library was mainly introduced to fulfill the needs of Swift Express - web application server side framework for Swift.
Still we hope it will be useful for everybody else.
First of all you need to install Discount.
#this one install a static library, so don't worry about redistribution
brew install discount
sudo apt-get install libmarkdown2-dev
Add the following dependency to your Package.swift:
.Package(url: "https://github.com/crossroadlabs/Markdown.git", majorVersion: 0)
Run swift build
and build your app. Package manager is supported on OS X, but it's still recommended to be used on Linux only.
Add the following to your Cartfile:
github "crossroadlabs/Markdown"
Run carthage update
and follow the steps as described in Carthage's README.
let md = try Markdown(string:"# Hello Markdown")
let document = try md.document()
print(document)
The output will be the following:
<h1>Hello Markdown</h1>
let md = try Markdown(string:"% test\n% daniel\n% 02.03.2016\n")
let title = md.title!
let author = md.author!
let date = md.date
print("Title: ", title)
print("Author: ", author)
print("Date: ", date)
The output will be the following:
Title: test
Author: daniel
Date: 02.03.2016
let md = try Markdown(string:"# test header", options: .TableOfContents)
let toc = try md.tableOfContents()
print(toc)
The output will be the following:
<ul>
<li><a href=\"#test.header\">test header</a></li>
</ul>
let md = try Markdown(string:"<style>background-color: yellow;</style>\n# test header")
let css = try md.css()
print(css)
The output will be the following:
<style>background-color: yellow;</style>
To get started, sign the Contributor License Agreement.