Swift cmark wrapper for SwiftPM
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources/SwiftMarkdown
Tests
.gitignore
.travis.yml
LICENSE
Package.swift
Package@swift-4.swift
README.md

README.md

Markdown

Language Build Status GitHub license

Very simple Swift wrapper of GitHub's fork of cmark. Uses a fork of cmark which has been adapted for building with SwiftPM.

Usage

markdown -> HTML

let markdown = "# Hello"
let html = try markdownToHTML(markdown)
print(html) // This will return "<h1>Hello</h1>\n"

Options

You can pass different options to the underlying cmark library. By default safe is passed, but this can be explicitly done with:

let html = try markdownToHTML(markdown, options: [.safe])

The available options are:

  • sourcePosition
  • hardBreaks
  • safe
  • noBreaks
  • normalize
  • validateUTF8
  • smartQuotes

For more information on the available options, see cmark.

Installation

Swift Package Manager

.package(url: "https://github.com/vapor-community/markdown.git", .upToNextMajor(from: "0.4.0"))