From c94b50726cf705c03e5fbb3aeed5241249a169d6 Mon Sep 17 00:00:00 2001 From: Tim <0xtimc@gmail.com> Date: Tue, 17 Nov 2020 10:10:40 +0000 Subject: [PATCH] Update the README --- README.md | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f416aa9..f74b79f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Leaf Markdown -[![Language](https://img.shields.io/badge/Swift-5.1-brightgreen.svg)](http://swift.org) -[![Build Status](https://github.com/vapor-community/leaf-markdown/workflows/CI/badge.svg?branch=master)](https://github.com/vapor-community/leaf-markdown/actions) -[![codecov](https://codecov.io/gh/vapor-community/leaf-markdown/branch/master/graph/badge.svg)](https://codecov.io/gh/vapor-community/leaf-markdown) -[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vapor-community/leaf-markdown/master/LICENSE) +[![Language](https://img.shields.io/badge/Swift-5.2-brightgreen.svg)](http://swift.org) +[![Build Status](https://github.com/vapor-community/leaf-markdown/workflows/CI/badge.svg?branch=main)](https://github.com/vapor-community/leaf-markdown/actions) +[![codecov](https://codecov.io/gh/vapor-community/leaf-markdown/branch/main/graph/badge.svg)](https://codecov.io/gh/vapor-community/leaf-markdown) +[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vapor-community/leaf-markdown/main/LICENSE) -A Markdown renderer for Vapor and Leaf. This uses the [Vapor Markdown](https://github.com/vapor/markdown) package to wrap [cmark](https://github.com/jgm/cmark) (though a [fork](https://github.com/brokenhandsio/cmark-gfm) is used to make it work with Swift PM), so it understands [Common Mark](http://commonmark.org). A quick reference guide for Common Mark can be found [here](http://commonmark.org/help/). It also supports [Github Flavored Markdown](https://guides.github.com/features/mastering-markdown/). +A Markdown renderer for Vapor and Leaf. This uses the [Vapor Markdown](https://github.com/vapor/markdown) package to wrap [cmark](https://github.com/github/cmark-gfm) (though a [fork](https://github.com/brokenhandsio/cmark-gfm) is used to make it work with Swift PM), so it understands [Common Mark](http://commonmark.org). A quick reference guide for Common Mark can be found [here](http://commonmark.org/help/). It also supports [Github Flavored Markdown](https://guides.github.com/features/mastering-markdown/). ## Usage @@ -32,21 +32,29 @@ Add Leaf Markdown as a dependency in your `Package.swift` file: ```swift dependencies: [ ..., - .package(url: "https://github.com/vapor-community/leaf-markdown.git", .upToNextMajor(from: "2.0.0")) + .package(name: "LeafMarkdown", url: "https://github.com/vapor-community/leaf-markdown.git", .upToNextMajor(from: "3.0.0")), ] ``` +Then add the dependency to your target: + +```swift +.target( + name: "App", + dependencies: [ + // ... + "LeafMarkdown" + ], + // ... +) +``` + ### Register with Leaf -To add the tag to Leaf, add it to your `LeafTagConfig`: +Register the tag with Leaf so Leaf knows about it: ```swift -try services.register(LeafProvider()) -var tags = LeafTagConfig.default() -tags.use(Markdown(), as: "markdown") -services.register(tags) +app.leaf.tags["markdown"] = Markdown() ``` -**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`.