Skip to content

lbFlyBoy/LeafMarkdown

 
 

Repository files navigation

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.

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 somthing like:

# Hey #

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

Setup

Add as dependency

Add LeafMarkdown as a dependency in your Package.swift file:

    dependencies: [
        ...,
        .Package(url: "https://github.com/brokenhandsio/LeafMarkdown", majorVersion: 0)
    ]

Add the Provider

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

let drop = Droplet()
try drop.addProvider(LeafMarkdown.Provider.self)

Register with Leaf

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

if let leaf = drop.view as? LeafRenderer {
    leaf.stem.register(Markdown())
}

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

About

Leaf Markdown - Markdown renderer for Vapor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 100.0%