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.
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`Add LeafMarkdown as a dependency in your Package.swift file:
dependencies: [
...,
.Package(url: "https://github.com/brokenhandsio/LeafMarkdown", majorVersion: 0)
]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)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