Swiftpack.co - Package -

Markdown Provider

Language Build Status codecov GitHub license

A Markdown renderer for Vapor and Leaf. This uses the Vapor Markdown package to wrap cmark (though a fork is used to make it work with Swift PM), so it understands Common Mark. A quick reference guide for Common Mark can be found here. It also support Github Flavored Markdown


Once set up, you can use it in your Leaf template files like any other tag:


Where you have passed myMarkdown into the view as something like:

# Hey #

Check out my *awesome* markdown! It is easy to use in `tags`


Add as dependency

Add Markdown Provider as a dependency in your Package.swift file:

    dependencies: [
        .package(url: "https://github.com/vapor-community/markdown-provider.git", .upToNextMajor(from: "1.1.0"))

Add the Provider

You can add a provider to you Config, which will do all of the setup for you and register your tag. Just add it as so:

let config = try Config()
try config.addProvider(MarkdownProvider.Provider.self)
let drop = try Droplet(config)

Register with Leaf

Alternatively, you can also directly add the Tag onto your LeafRenderer if desired. During your setup (for example, in Droplet+Setup.swift), register your tag as so:

if let leaf = drop.view as? LeafRenderer {

Don't forget to import MarkdownProvider in the file you register the tag or add the provider in with import MarkdownProvider