Swiftpack.co - Package - vapor-community/markdown-provider

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

Use

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

#markdown(myMarkdown)

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

# Hey #

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

Setup

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 {
    leaf.stem.register(Markdown())
}

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

Github

link
Stars: 20
Help us keep the lights on

Used By

Total:

Releases

1.1.1 - Oct 21, 2017

Markdown Provider 1.1.1

  • Fixes #6 with PR #7

1.1.0 - Sep 21, 2017

Markdown Provider 1.1.0

PR #5 - add Swift 4 support

1.0.0 - May 19, 2017

Markdown Provider 1.0.0

This is the first major release of the Markdown Provider for Vapor 2. It includes all of the work from the Broken Hands fork to make it use the latest Markdown package, including support for Github Flavoured Markdown. See the README for details on how to use.