Markdown renderer for Vapor
Switch branches/tags
Nothing to show
Clone or download
Latest commit 1e34264 Aug 10, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources/LeafMarkdown Remove provider and update README May 4, 2018
Tests Fix tests on Linux May 4, 2018
.codecov.yml Add files for travis Jan 30, 2017
.gitignore Add Swift 4 manifest Sep 21, 2017
.swiftlint.yml Swiftlint Jan 2, 2018
.travis.yml update to Xcode 9.4 Aug 10, 2018
LICENSE Initial commit Aug 30, 2016
Package.swift Use Leaf release Aug 10, 2018
README.md Remove provider and update README May 4, 2018

README.md

Leaf Markdown

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 supports Github Flavored Markdown.

Usage

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 Leaf Markdown as a dependency in your Package.swift file:

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

Register with Leaf

To add the tag to Leaf, add it to your LeafTagConfig:

try services.register(LeafProvider())
var tags = LeafTagConfig.default()
tags.use(Markdown(), as: "markdown")
services.register(tags)

Note: it's important that you register the LeafProvider first otherwise this will override your LeafTagConfig.

Don't forget to import LeafMarkdown in the file you register the tag with import LeafMarkdown.